ReactOS  0.4.12-dev-919-gfc3b8d5
api.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for api.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

KSDDKAPI NTSTATUS NTAPI KsAcquireResetValue (IN PIRP Irp, OUT KSRESET *ResetValue)
 
KSDDKAPI VOID NTAPI KsAcquireDeviceSecurityLock (IN KSDEVICE_HEADER DevHeader, IN BOOLEAN Exclusive)
 
KSDDKAPI VOID NTAPI KsReleaseDeviceSecurityLock (IN KSDEVICE_HEADER DevHeader)
 
KSDDKAPI NTSTATUS NTAPI KsDefaultDispatchPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
KSDDKAPI NTSTATUS NTAPI KsDefaultDispatchPower (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
KSDDKAPI NTSTATUS NTAPI KsDefaultForwardIrp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
KSDDKAPI VOID NTAPI KsSetDevicePnpAndBaseObject (IN KSDEVICE_HEADER Header, IN PDEVICE_OBJECT PnpDeviceObject, IN PDEVICE_OBJECT BaseDevice)
 
KSDDKAPI PDEVICE_OBJECT NTAPI KsQueryDevicePnpObject (IN KSDEVICE_HEADER Header)
 
KSDDKAPI ACCESS_MASK NTAPI KsQueryObjectAccessMask (IN KSOBJECT_HEADER Header)
 
KSDDKAPI VOID NTAPI KsRecalculateStackDepth (IN KSDEVICE_HEADER Header, IN BOOLEAN ReuseStackLocation)
 
KSDDKAPI VOID NTAPI KsSetTargetState (IN KSOBJECT_HEADER Header, IN KSTARGET_STATE TargetState)
 
KSDDKAPI VOID NTAPI KsSetTargetDeviceObject (IN KSOBJECT_HEADER Header, IN PDEVICE_OBJECT TargetDevice OPTIONAL)
 
KSDDKAPI VOID NTAPI KsSetPowerDispatch (IN KSOBJECT_HEADER Header, IN PFNKSCONTEXT_DISPATCH PowerDispatch OPTIONAL, IN PVOID PowerContext OPTIONAL)
 
KSDDKAPI PKSOBJECT_CREATE_ITEM NTAPI KsQueryObjectCreateItem (IN KSOBJECT_HEADER Header)
 
NTSTATUS KspAddCreateItemToList (OUT PLIST_ENTRY ListHead, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList)
 
VOID KspFreeCreateItems (PLIST_ENTRY ListHead)
 
KSDDKAPI NTSTATUS NTAPI KsAllocateDeviceHeader (OUT KSDEVICE_HEADER *OutHeader, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList OPTIONAL)
 
KSDDKAPI VOID NTAPI KsFreeDeviceHeader (IN KSDEVICE_HEADER DevHeader)
 
KSDDKAPI NTSTATUS NTAPI KsAllocateObjectHeader (OUT KSOBJECT_HEADER *Header, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList OPTIONAL, IN PIRP Irp, IN KSDISPATCH_TABLE *Table)
 
KSDDKAPI VOID NTAPI KsFreeObjectHeader (IN PVOID Header)
 
NTSTATUS KspAddObjectCreateItemToList (PLIST_ENTRY ListHead, IN PDRIVER_DISPATCH Create, IN PVOID Context, IN PWCHAR ObjectClass, IN PSECURITY_DESCRIPTOR SecurityDescriptor)
 
KSDDKAPI NTSTATUS NTAPI KsAddObjectCreateItemToDeviceHeader (IN KSDEVICE_HEADER DevHeader, IN PDRIVER_DISPATCH Create, IN PVOID Context, IN PWCHAR ObjectClass, IN PSECURITY_DESCRIPTOR SecurityDescriptor)
 
KSDDKAPI NTSTATUS NTAPI KsAddObjectCreateItemToObjectHeader (IN KSOBJECT_HEADER ObjectHeader, IN PDRIVER_DISPATCH Create, IN PVOID Context, IN PWCHAR ObjectClass, IN PSECURITY_DESCRIPTOR SecurityDescriptor)
 
KSDDKAPI NTSTATUS NTAPI KsAllocateObjectCreateItem (IN KSDEVICE_HEADER DevHeader, IN PKSOBJECT_CREATE_ITEM CreateItem, IN BOOLEAN AllocateEntry, IN PFNKSITEMFREECALLBACK ItemFreeCallback OPTIONAL)
 
NTSTATUS KspObjectFreeCreateItems (IN KSDEVICE_HEADER Header, IN PKSOBJECT_CREATE_ITEM CreateItem)
 
KSDDKAPI NTSTATUS NTAPI KsFreeObjectCreateItem (IN KSDEVICE_HEADER Header, IN PUNICODE_STRING CreateItem)
 
KSDDKAPI NTSTATUS NTAPI KsFreeObjectCreateItemsByContext (IN KSDEVICE_HEADER Header, IN PVOID Context)
 
KSDDKAPI NTSTATUS NTAPI KsCreateDefaultSecurity (IN PSECURITY_DESCRIPTOR ParentSecurity OPTIONAL, OUT PSECURITY_DESCRIPTOR *DefaultSecurity)
 
KSDDKAPI NTSTATUS NTAPI KsForwardIrp (IN PIRP Irp, IN PFILE_OBJECT FileObject, IN BOOLEAN ReuseStackLocation)
 
KSDDKAPI NTSTATUS NTAPI KsForwardAndCatchIrp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PFILE_OBJECT FileObject, IN KSSTACK_USE StackUse)
 
NTSTATUS NTAPI KspSynchronousIoControlDeviceCompletion (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
 
KSDDKAPI NTSTATUS NTAPI KsSynchronousIoControlDevice (IN PFILE_OBJECT FileObject, IN KPROCESSOR_MODE RequestorMode, IN ULONG IoControl, IN PVOID InBuffer, IN ULONG InSize, OUT PVOID OutBuffer, IN ULONG OutSize, OUT PULONG BytesReturned)
 
KSDDKAPI NTSTATUS NTAPI KsUnserializeObjectPropertiesFromRegistry (IN PFILE_OBJECT FileObject, IN HANDLE ParentKey OPTIONAL, IN PUNICODE_STRING RegistryPath OPTIONAL)
 
KSDDKAPI NTSTATUS NTAPI KsCacheMedium (IN PUNICODE_STRING SymbolicLink, IN PKSPIN_MEDIUM Medium, IN ULONG PinDirection)
 
NTSTATUS NTAPI DllInitialize (PUNICODE_STRING RegistryPath)
 
NTSTATUS NTAPI KopDispatchClose (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI KopDispatchCreate (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI KopAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
 
COMDDKAPI NTSTATUS NTAPI KoDeviceInitialize (IN PDEVICE_OBJECT DeviceObject)
 
COMDDKAPI NTSTATUS NTAPI KoDriverInitialize (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPathName, IN KoCreateObjectHandler CreateObjectHandler)
 
COMDDKAPI VOID NTAPI KoRelease (IN REFCLSID ClassId)
 
KSDDKAPI VOID NTAPI KsAcquireControl (IN PVOID Object)
 
VOID NTAPI KsReleaseControl (IN PVOID Object)
 
KSDDKAPI VOID NTAPI KsAcquireDevice (IN PKSDEVICE Device)
 
VOID NTAPI KsReleaseDevice (IN PKSDEVICE Device)
 
KSDDKAPI VOID NTAPI KsTerminateDevice (IN PDEVICE_OBJECT DeviceObject)
 
KSDDKAPI VOID NTAPI KsCompletePendingRequest (IN PIRP Irp)
 
NTSTATUS NTAPI KspSetGetBusDataCompletion (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
 
NTSTATUS KspDeviceSetGetBusData (IN PDEVICE_OBJECT DeviceObject, IN ULONG DataType, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length, IN BOOL bGet)
 
KSDDKAPI ULONG NTAPI KsDeviceSetBusData (IN PKSDEVICE Device, IN ULONG DataType, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
KSDDKAPI ULONG NTAPI KsDeviceGetBusData (IN PKSDEVICE Device, IN ULONG DataType, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
KSDDKAPI void NTAPI KsDeviceRegisterAdapterObject (IN PKSDEVICE Device, IN PADAPTER_OBJECT AdapterObject, IN ULONG MaxMappingsByteCount, IN ULONG MappingTableStride)
 
KSDDKAPI PVOID NTAPI KsGetFirstChild (IN PVOID Object)
 
KSDDKAPI PVOID NTAPI KsGetNextSibling (IN PVOID Object)
 
ULONG KspCountMethodSets (IN PKSAUTOMATION_TABLE AutomationTableA OPTIONAL, IN PKSAUTOMATION_TABLE AutomationTableB OPTIONAL)
 
ULONG KspCountEventSets (IN PKSAUTOMATION_TABLE AutomationTableA OPTIONAL, IN PKSAUTOMATION_TABLE AutomationTableB OPTIONAL)
 
ULONG KspCountPropertySets (IN PKSAUTOMATION_TABLE AutomationTableA OPTIONAL, IN PKSAUTOMATION_TABLE AutomationTableB OPTIONAL)
 
NTSTATUS KspCopyMethodSets (OUT PKSAUTOMATION_TABLE Table, IN PKSAUTOMATION_TABLE AutomationTableA OPTIONAL, IN PKSAUTOMATION_TABLE AutomationTableB OPTIONAL)
 
VOID KspAddPropertyItem (OUT PKSPROPERTY_SET OutPropertySet, IN PKSPROPERTY_ITEM PropertyItem, IN ULONG PropertyItemSize)
 
NTSTATUS KspMergePropertySet (OUT PKSAUTOMATION_TABLE Table, OUT PKSPROPERTY_SET OutPropertySet, IN PKSPROPERTY_SET PropertySetA, IN PKSPROPERTY_SET PropertySetB, IN KSOBJECT_BAG Bag OPTIONAL)
 
NTSTATUS KspCopyPropertySets (OUT PKSAUTOMATION_TABLE Table, IN PKSAUTOMATION_TABLE AutomationTableA OPTIONAL, IN PKSAUTOMATION_TABLE AutomationTableB OPTIONAL, IN KSOBJECT_BAG Bag OPTIONAL)
 
NTSTATUS KspCopyEventSets (OUT PKSAUTOMATION_TABLE Table, IN PKSAUTOMATION_TABLE AutomationTableA OPTIONAL, IN PKSAUTOMATION_TABLE AutomationTableB OPTIONAL)
 
NTSTATUS NTAPI KsMergeAutomationTables (OUT PKSAUTOMATION_TABLE *AutomationTableAB, IN PKSAUTOMATION_TABLE AutomationTableA OPTIONAL, IN PKSAUTOMATION_TABLE AutomationTableB OPTIONAL, IN KSOBJECT_BAG Bag OPTIONAL)
 
KSDDKAPI PUNKNOWN NTAPI KsRegisterAggregatedClientUnknown (IN PVOID Object, IN PUNKNOWN ClientUnknown)
 
NTSTATUS NTAPI KsRegisterFilterWithNoKSPins (IN PDEVICE_OBJECT DeviceObject, IN const GUID *InterfaceClassGUID, IN ULONG PinCount, IN BOOL *PinDirection, IN KSPIN_MEDIUM *MediumList, IN GUID *CategoryList OPTIONAL)
 

Variables

const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}
 
const GUID KSMEDIUMSETID_Standard = {0x4747B320L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
 
static KSDISPATCH_TABLE KoDispatchTable
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file api.c.

Function Documentation

◆ DllInitialize()

NTSTATUS NTAPI DllInitialize ( PUNICODE_STRING  RegistryPath)

Definition at line 1299 of file api.c.

1301 {
1302  return STATUS_SUCCESS;
1303 }
return STATUS_SUCCESS
Definition: btrfs.c:2725

◆ KoDeviceInitialize()

COMDDKAPI NTSTATUS NTAPI KoDeviceInitialize ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 1513 of file api.c.

1515 {
1516  PDEVICE_EXTENSION DeviceExtension;
1517 
1518  /* get device extension */
1519  DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
1520 
1522 }
NTSTATUS NTAPI KopDispatchCreate(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: api.c:1360
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
KSDDKAPI NTSTATUS NTAPI KsAddObjectCreateItemToDeviceHeader(IN KSDEVICE_HEADER DevHeader, IN PDRIVER_DISPATCH Create, IN PVOID Context, IN PWCHAR ObjectClass, IN PSECURITY_DESCRIPTOR SecurityDescriptor)
Definition: api.c:798
#define KOSTRING_CreateObject
Definition: kcom.h:34
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION

◆ KoDriverInitialize()

COMDDKAPI NTSTATUS NTAPI KoDriverInitialize ( IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegistryPathName,
IN KoCreateObjectHandler  CreateObjectHandler 
)

Definition at line 1530 of file api.c.

1534 {
1535  PKO_DRIVER_EXTENSION DriverObjectExtension;
1536  NTSTATUS Status;
1537 
1538  /* allocate driver object extension */
1540 
1541  /* did it work */
1542  if (NT_SUCCESS(Status))
1543  {
1544  /* store create handler */
1545  DriverObjectExtension->CreateObjectHandler = CreateObjectHandler;
1546 
1547  /* Setting our IRP handlers */
1551 
1552  /* The driver unload routine */
1554 
1555  /* The driver-supplied AddDevice */
1557 
1558  /* KS handles these */
1559  DPRINT1("Setting KS function handlers\n");
1563 
1564  }
1565 
1566  return Status;
1567 }
KSDDKAPI NTSTATUS NTAPI KsDefaultDispatchPower(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: api.c:166
KSDDKAPI NTSTATUS NTAPI KsDefaultDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: api.c:110
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
NTSTATUS NTAPI IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
Definition: driver.c:1755
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
KSDDKAPI VOID NTAPI KsNullDriverUnload(IN PDRIVER_OBJECT DriverObject)
Definition: irp.c:1145
NTSTATUS NTAPI KopAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: api.c:1441
KSDDKAPI NTSTATUS NTAPI KsSetMajorFunctionHandler(IN PDRIVER_OBJECT DriverObject, IN ULONG MajorFunction)
Definition: irp.c:2017
PDRIVER_EXTENSION DriverExtension
Definition: iotypes.h:2173
KoCreateObjectHandler CreateObjectHandler
Definition: kstypes.h:5
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MJ_POWER
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
PDRIVER_UNLOAD DriverUnload
Definition: iotypes.h:2179
#define IRP_MJ_SYSTEM_CONTROL
Status
Definition: gdiplustypes.h:24
PDRIVER_ADD_DEVICE AddDevice
Definition: iotypes.h:2111
KSDDKAPI NTSTATUS NTAPI KsDefaultForwardIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: api.c:227
COMDDKAPI NTSTATUS NTAPI KoDriverInitialize(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPathName, IN KoCreateObjectHandler CreateObjectHandler)
Definition: api.c:1530
#define DPRINT1
Definition: precomp.h:8
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2180
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

Referenced by KoDriverInitialize(), and KopDispatchCreate().

◆ KopAddDevice()

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

Definition at line 1441 of file api.c.

1444 {
1448  PDEVICE_EXTENSION DeviceExtension;
1449  PKSOBJECT_CREATE_ITEM CreateItem;
1450 
1451  /* create the device object */
1453  if (!NT_SUCCESS(Status))
1454  return Status;
1455 
1456  /* allocate the create item */
1457  CreateItem = AllocateItem(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM));
1458 
1459  if (!CreateItem)
1460  {
1461  /* not enough memory */
1464  }
1465 
1466  /* initialize create item */
1467  CreateItem->Create = KopDispatchCreate;
1468  RtlInitUnicodeString(&CreateItem->ObjectClass, KOSTRING_CreateObject);
1469 
1470  /* get device extension */
1472 
1473  /* now allocate the device header */
1474  Status = KsAllocateDeviceHeader((KSDEVICE_HEADER*)&DeviceExtension->DeviceHeader, 1, CreateItem);
1475  if (!NT_SUCCESS(Status))
1476  {
1477  /* failed */
1479  FreeItem(CreateItem);
1480  return Status;
1481  }
1482 
1483  /* now attach to device stack */
1485  if (NextDeviceObject)
1486  {
1487  /* store pnp base object */
1489  /* set device flags */
1492  }
1493  else
1494  {
1495  /* failed */
1496  KsFreeDeviceHeader((KSDEVICE_HEADER)DeviceExtension->DeviceHeader);
1497  FreeItem(CreateItem);
1500  }
1501 
1502  /* return result */
1503  return Status;
1504 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define DO_POWER_PAGABLE
#define STATUS_DEVICE_REMOVED
Definition: ntstatus.h:795
#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
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KopDispatchCreate(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: api.c:1360
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT * NextDeviceObject
Definition: ndis.h:4622
KSDDKAPI VOID NTAPI KsFreeDeviceHeader(IN KSDEVICE_HEADER DevHeader)
Definition: api.c:590
#define KOSTRING_CreateObject
Definition: kcom.h:34
Status
Definition: gdiplustypes.h:24
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1250
#define FILE_DEVICE_KS
Definition: winioctl.h:152
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT * FunctionalDeviceObject
Definition: ndis.h:4622
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 FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION

Referenced by KoDriverInitialize().

◆ KopDispatchClose()

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

Definition at line 1308 of file api.c.

1311 {
1313  PIO_STACK_LOCATION IoStack;
1314  PDEVICE_EXTENSION DeviceExtension;
1315 
1316  /* get current irp stack location */
1317  IoStack = IoGetCurrentIrpStackLocation(Irp);
1318 
1319  /* get ko object header */
1320  Header = (PKO_OBJECT_HEADER)IoStack->FileObject->FsContext2;
1321 
1322  /* free ks object header */
1323  KsFreeObjectHeader(Header->ObjectHeader);
1324 
1325  /* free ko object header */
1326  FreeItem(Header);
1327 
1328  /* get device extension */
1329  DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
1330 
1331  /* release bus object */
1332  KsDereferenceBusObject((KSDEVICE_HEADER)DeviceExtension->DeviceHeader);
1333 
1334  /* complete request */
1335  Irp->IoStatus.Status = STATUS_SUCCESS;
1337 
1338  return STATUS_SUCCESS;
1339 }
_In_ PIRP Irp
Definition: csq.h:116
KSDDKAPI VOID NTAPI KsFreeObjectHeader(IN PVOID Header)
Definition: api.c:720
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
Definition: Header.h:8
PVOID DeviceExtension
Definition: env_spec_w32.h:418
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: dispatch.c:19
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:2812
#define IO_NO_INCREMENT
Definition: iotypes.h:565
return STATUS_SUCCESS
Definition: btrfs.c:2725
struct KO_OBJECT_HEADER * PKO_OBJECT_HEADER
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION
KSDDKAPI VOID NTAPI KsDereferenceBusObject(IN KSDEVICE_HEADER Header)
Definition: device.c:854

◆ KopDispatchCreate()

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

Definition at line 1360 of file api.c.

1363 {
1365  PIO_STACK_LOCATION IoStack;
1366  PKO_DRIVER_EXTENSION DriverObjectExtension;
1367  NTSTATUS Status;
1368 
1369  /* get current irp stack location */
1370  IoStack = IoGetCurrentIrpStackLocation(Irp);
1371 
1372  if (!IoStack->FileObject)
1373  {
1374  DPRINT1("FileObject not attached!\n");
1376  goto cleanup;
1377  }
1378 
1379  /* get driver object extension */
1380  DriverObjectExtension = (PKO_DRIVER_EXTENSION)IoGetDriverObjectExtension(DeviceObject->DriverObject, (PVOID)KoDriverInitialize);
1381  if (!DriverObjectExtension)
1382  {
1383  DPRINT1("No DriverObjectExtension!\n");
1385  goto cleanup;
1386  }
1387 
1388  /* allocate ko object header */
1390  if (!Header)
1391  {
1392  DPRINT1("failed to allocate KO_OBJECT_HEADER\n");
1394  goto cleanup;
1395  }
1396 
1397  /* initialize create item */
1398  Header->CreateItem.Create = KopDispatchCreate;
1399  RtlInitUnicodeString(&Header->CreateItem.ObjectClass, KOSTRING_CreateObject);
1400 
1401 
1402  /* now allocate the object header */
1403  Status = KsAllocateObjectHeader(&Header->ObjectHeader, 1, &Header->CreateItem, Irp, &KoDispatchTable);
1404  if (!NT_SUCCESS(Status))
1405  {
1406  /* failed */
1407  goto cleanup;
1408  }
1409 
1410  /* FIXME
1411  * extract clsid and interface id from irp
1412  * call the standard create handler
1413  */
1414 
1415  UNIMPLEMENTED;
1416 
1417  IoStack->FileObject->FsContext2 = (PVOID)Header;
1418 
1419  Irp->IoStatus.Status = Status;
1421 
1422  return Status;
1423 
1424 cleanup:
1425 
1426  if (Header && Header->ObjectHeader)
1427  KsFreeObjectHeader(Header->ObjectHeader);
1428 
1429  if (Header)
1430  FreeItem(Header);
1431 
1432  Irp->IoStatus.Status = Status;
1434  return Status;
1435 }
#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
NTSTATUS NTAPI KopDispatchCreate(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: api.c:1360
KSDDKAPI VOID NTAPI KsFreeObjectHeader(IN PVOID Header)
Definition: api.c:720
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
Definition: Header.h:8
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: dispatch.c:19
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
struct KO_DRIVER_EXTENSION * PKO_DRIVER_EXTENSION
static KSDISPATCH_TABLE KoDispatchTable
Definition: api.c:1343
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1833
#define KOSTRING_CreateObject
Definition: kcom.h:34
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:2812
COMDDKAPI NTSTATUS NTAPI KoDriverInitialize(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPathName, IN KoCreateObjectHandler CreateObjectHandler)
Definition: api.c:1530
#define DPRINT1
Definition: precomp.h:8
KSDDKAPI NTSTATUS NTAPI KsAllocateObjectHeader(OUT KSOBJECT_HEADER *Header, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList OPTIONAL, IN PIRP Irp, IN KSDISPATCH_TABLE *Table)
Definition: api.c:610
#define IO_NO_INCREMENT
Definition: iotypes.h:565
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNIMPLEMENTED
Definition: debug.h:114
char * cleanup(char *str)
Definition: wpickclick.c:99
struct KO_OBJECT_HEADER * PKO_OBJECT_HEADER

Referenced by KoDeviceInitialize(), and KopAddDevice().

◆ KoRelease()

COMDDKAPI VOID NTAPI KoRelease ( IN REFCLSID  ClassId)

Definition at line 1575 of file api.c.

1577 {
1578 
1579 }

◆ KsAcquireControl()

KSDDKAPI VOID NTAPI KsAcquireControl ( IN PVOID  Object)

Definition at line 1587 of file api.c.

1589 {
1590  PKSBASIC_HEADER BasicHeader = (PKSBASIC_HEADER)((ULONG_PTR)Object - sizeof(KSBASIC_HEADER));
1591 
1592  /* sanity check */
1593  ASSERT(BasicHeader->Type == KsObjectTypeFilter || BasicHeader->Type == KsObjectTypePin);
1594 
1596 
1597 }
struct KSBASIC_HEADER * PKSBASIC_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
uint32_t ULONG_PTR
Definition: typedefs.h:63
PRKMUTEX ControlMutex
Definition: kstypes.h:58
smooth NULL
Definition: ftsmooth.c:416
KSOBJECTTYPE Type
Definition: kstypes.h:56
static IUnknown Object
Definition: main.c:512
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

Referenced by IKsPin_DispatchCreateClock().

◆ KsAcquireDevice()

KSDDKAPI VOID NTAPI KsAcquireDevice ( IN PKSDEVICE  Device)

Definition at line 1623 of file api.c.

1625 {
1626  IKsDevice *KsDevice;
1627  PKSIDEVICE_HEADER DeviceHeader;
1628 
1629  DPRINT("KsAcquireDevice\n");
1630  DeviceHeader = (PKSIDEVICE_HEADER)CONTAINING_RECORD(Device, KSIDEVICE_HEADER, KsDevice);
1631 
1632  /* get device interface*/
1633  KsDevice = (IKsDevice*)&DeviceHeader->BasicHeader.OuterUnknown;
1634 
1635  /* acquire device mutex */
1636  KsDevice->lpVtbl->AcquireDevice(KsDevice);
1637 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
PUNKNOWN OuterUnknown
Definition: kstypes.h:62
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
KSBASIC_HEADER BasicHeader
Definition: kstypes.h:87

◆ KsAcquireDeviceSecurityLock()

KSDDKAPI VOID NTAPI KsAcquireDeviceSecurityLock ( IN KSDEVICE_HEADER  DevHeader,
IN BOOLEAN  Exclusive 
)

Definition at line 69 of file api.c.

72 {
74 
76 
77  if (Exclusive)
78  {
80  }
81  else
82  {
83  ExAcquireResourceSharedLite(&Header->SecurityLock, TRUE);
84  }
85 }
#define TRUE
Definition: types.h:120
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
Definition: Header.h:8
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885

Referenced by KsSetPowerDispatch(), and KsSetTargetDeviceObject().

◆ KsAcquireResetValue()

KSDDKAPI NTSTATUS NTAPI KsAcquireResetValue ( IN PIRP  Irp,
OUT KSRESET ResetValue 
)

Definition at line 23 of file api.c.

26 {
27  PIO_STACK_LOCATION IoStack;
28  KSRESET* Value;
30 
31  /* get current irp stack */
33 
34  /* check if there is reset value provided */
35  if (IoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(KSRESET))
37 
38  if (Irp->RequestorMode == UserMode)
39  {
40  /* need to probe the buffer */
41  _SEH2_TRY
42  {
43  ProbeForRead(IoStack->Parameters.DeviceIoControl.Type3InputBuffer, sizeof(KSRESET), sizeof(UCHAR));
44  Value = (KSRESET*)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
45  *ResetValue = *Value;
46  }
48  {
49  /* Exception, get the error code */
51  }
52  _SEH2_END;
53  }
54  else
55  {
56  Value = (KSRESET*)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
57  *ResetValue = *Value;
58  }
59 
60  return Status;
61 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char UCHAR
Definition: xmlstorage.h:181
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_SEH2_END
Definition: create.c:4424
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2725
KSRESET
Definition: ks.h:1256

◆ KsAddObjectCreateItemToDeviceHeader()

KSDDKAPI NTSTATUS NTAPI KsAddObjectCreateItemToDeviceHeader ( IN KSDEVICE_HEADER  DevHeader,
IN PDRIVER_DISPATCH  Create,
IN PVOID  Context,
IN PWCHAR  ObjectClass,
IN PSECURITY_DESCRIPTOR  SecurityDescriptor 
)

Definition at line 798 of file api.c.

804 {
807 
808  Header = (PKSIDEVICE_HEADER)DevHeader;
809 
810  DPRINT("KsAddObjectCreateItemToDeviceHeader entered\n");
811 
812  /* check if a device header has been provided */
813  if (!DevHeader)
815 
816  /* check if a create item has been provided */
817  if (!Create)
819 
820  /* check if a object class has been provided */
821  if (!ObjectClass)
823 
824  /* let others do the work */
826 
827  if (NT_SUCCESS(Status))
828  {
829  /* increment create item count */
830  InterlockedIncrement(&Header->ItemListCount);
831  }
832  DPRINT("KsAddObjectCreateItemToDeviceHeader Status %x\n", Status);
833  return Status;
834 }
NTSTATUS KspAddObjectCreateItemToList(PLIST_ENTRY ListHead, IN PDRIVER_DISPATCH Create, IN PVOID Context, IN PWCHAR ObjectClass, IN PSECURITY_DESCRIPTOR SecurityDescriptor)
Definition: api.c:748
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
Definition: wsk.h:182
_In_ BOOLEAN Create
Definition: pstypes.h:511
LONG NTSTATUS
Definition: precomp.h:26
Definition: Header.h:8
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:461
Status
Definition: gdiplustypes.h:24
#define InterlockedIncrement
Definition: armddk.h:53
#define STATUS_INVALID_PARAMETER_4
Definition: ntstatus.h:464

Referenced by KoDeviceInitialize(), and PcRegisterSubdevice().

◆ KsAddObjectCreateItemToObjectHeader()

KSDDKAPI NTSTATUS NTAPI KsAddObjectCreateItemToObjectHeader ( IN KSOBJECT_HEADER  ObjectHeader,
IN PDRIVER_DISPATCH  Create,
IN PVOID  Context,
IN PWCHAR  ObjectClass,
IN PSECURITY_DESCRIPTOR  SecurityDescriptor 
)

Definition at line 842 of file api.c.

848 {
851 
852  Header = (PKSIOBJECT_HEADER)ObjectHeader;
853 
854  DPRINT("KsAddObjectCreateItemToDeviceHeader entered\n");
855 
856  /* check if a device header has been provided */
857  if (!Header)
859 
860  /* check if a create item has been provided */
861  if (!Create)
863 
864  /* check if a object class has been provided */
865  if (!ObjectClass)
867 
868  /* let's work */
870 
871  if (NT_SUCCESS(Status))
872  {
873  /* increment create item count */
874  InterlockedIncrement(&Header->ItemListCount);
875  }
876 
877  return Status;
878 }
NTSTATUS KspAddObjectCreateItemToList(PLIST_ENTRY ListHead, IN PDRIVER_DISPATCH Create, IN PVOID Context, IN PWCHAR ObjectClass, IN PSECURITY_DESCRIPTOR SecurityDescriptor)
Definition: api.c:748
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
Definition: wsk.h:182
_In_ BOOLEAN Create
Definition: pstypes.h:511
struct KSIOBJECT_HEADER * PKSIOBJECT_HEADER
LONG NTSTATUS
Definition: precomp.h:26
Definition: Header.h:8
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:461
Status
Definition: gdiplustypes.h:24
#define InterlockedIncrement
Definition: armddk.h:53
#define STATUS_INVALID_PARAMETER_4
Definition: ntstatus.h:464

◆ KsAllocateDeviceHeader()

KSDDKAPI NTSTATUS NTAPI KsAllocateDeviceHeader ( OUT KSDEVICE_HEADER OutHeader,
IN ULONG  ItemsCount,
IN PKSOBJECT_CREATE_ITEM ItemsList  OPTIONAL 
)

Definition at line 522 of file api.c.

526 {
529 
530  if (!OutHeader)
532 
533  /* allocate a device header */
535 
536  /* check for success */
537  if (!Header)
539 
540  /* clear all memory */
542 
543  /* initialize device mutex */
544  KeInitializeMutex(&Header->DeviceMutex, 0);
545 
546  /* initialize target device list */
547  InitializeListHead(&Header->TargetDeviceList);
548  /* initialize power dispatch list */
549  InitializeListHead(&Header->PowerDispatchList);
550  /* initialize object bag lists */
551  InitializeListHead(&Header->ObjectBags);
552 
553  /* initialize create item list */
554  InitializeListHead(&Header->ItemList);
555 
556  /* initialize basic header */
557  Header->BasicHeader.Type = KsObjectTypeDevice;
558  Header->BasicHeader.KsDevice = &Header->KsDevice;
559  Header->BasicHeader.Parent.KsDevice = &Header->KsDevice;
560 
561  /* are there any create items provided */
562  if (ItemsCount && ItemsList)
563  {
564  Status = KspAddCreateItemToList(&Header->ItemList, ItemsCount, ItemsList);
565 
566  if (NT_SUCCESS(Status))
567  {
568  /* store item count */
569  Header->ItemListCount = ItemsCount;
570  }
571  else
572  {
573  /* release create items */
574  KspFreeCreateItems(&Header->ItemList);
575  }
576  }
577 
578  /* store result */
579  *OutHeader = Header;
580 
581  return Status;
582 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
Definition: Header.h:8
NTSTATUS KspAddCreateItemToList(OUT PLIST_ENTRY ListHead, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList)
Definition: api.c:458
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
VOID KspFreeCreateItems(PLIST_ENTRY ListHead)
Definition: api.c:489
Status
Definition: gdiplustypes.h:24
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by KMixAllocateDeviceHeader(), KopAddDevice(), KsInitializeDevice(), PcAddAdapterDevice(), StreamClassAddDevice(), SysAudioAllocateDeviceHeader(), and WdmaudAddDevice().

◆ KsAllocateObjectCreateItem()

KSDDKAPI NTSTATUS NTAPI KsAllocateObjectCreateItem ( IN KSDEVICE_HEADER  DevHeader,
IN PKSOBJECT_CREATE_ITEM  CreateItem,
IN BOOLEAN  AllocateEntry,
IN PFNKSITEMFREECALLBACK ItemFreeCallback  OPTIONAL 
)

Definition at line 886 of file api.c.

891 {
892  PCREATE_ITEM_ENTRY CreateEntry;
894  PKSOBJECT_CREATE_ITEM Item;
895 
896  Header = (PKSIDEVICE_HEADER)DevHeader;
897 
898  if (!DevHeader)
900 
901  if (!CreateItem)
903 
904  /* first allocate a create entry */
905  CreateEntry = AllocateItem(NonPagedPool, sizeof(CREATE_ITEM_ENTRY));
906 
907  /* check for allocation success */
908  if (!CreateEntry)
909  {
910  /* not enough resources */
912  }
913 
914 
915  if (AllocateEntry)
916  {
917  /* allocate create item */
918  Item = AllocateItem(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM));
919  if (!Item)
920  {
921  /* no memory */
922  FreeItem(CreateEntry);
924  }
925 
926  /* initialize descriptor */
927  Item->Context = CreateItem->Context;
928  Item->Create = CreateItem->Create;
929  Item->Flags = CreateItem->Flags;
930  Item->SecurityDescriptor = CreateItem->SecurityDescriptor;
931  Item->ObjectClass.Length = 0;
932  Item->ObjectClass.MaximumLength = CreateItem->ObjectClass.MaximumLength;
933 
934  /* copy object class */
935  Item->ObjectClass.Buffer = AllocateItem(NonPagedPool, Item->ObjectClass.MaximumLength);
936  if (!Item->ObjectClass.Buffer)
937  {
938  /* release resources */
939  FreeItem(Item);
940  FreeItem(CreateEntry);
941 
943  }
944  RtlCopyUnicodeString(&Item->ObjectClass, &CreateItem->ObjectClass);
945  }
946  else
947  {
948  if (ItemFreeCallback)
949  {
950  /* callback is only accepted when the create item is copied */
951  ItemFreeCallback = NULL;
952  }
953  /* use passed create item */
954  Item = CreateItem;
955  }
956 
957  /* initialize create item entry */
958  InitializeListHead(&CreateEntry->ObjectItemList);
959  CreateEntry->ItemFreeCallback = ItemFreeCallback;
960  CreateEntry->CreateItem = Item;
961  CreateEntry->ReferenceCount = 0;
962 
963  /* now insert the create item entry */
964  InsertTailList(&Header->ItemList, &CreateEntry->Entry);
965 
966  /* increment item count */
967  InterlockedIncrement(&Header->ItemListCount);
968 
969  return STATUS_SUCCESS;
970 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
#define InsertTailList(ListHead, Entry)
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
Definition: kstypes.h:45
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
Definition: Header.h:8
PFNKSITEMFREECALLBACK ItemFreeCallback
Definition: kstypes.h:49
PKSOBJECT_CREATE_ITEM CreateItem
Definition: kstypes.h:48
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
LIST_ENTRY Entry
Definition: kstypes.h:47
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:461
#define InterlockedIncrement
Definition: armddk.h:53
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
LIST_ENTRY ObjectItemList
Definition: kstypes.h:51
LONG ReferenceCount
Definition: kstypes.h:50
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by IKsFilterFactory_fnInitialize(), and KsFilterFactoryAddCreateItem().

◆ KsAllocateObjectHeader()

KSDDKAPI NTSTATUS NTAPI KsAllocateObjectHeader ( OUT KSOBJECT_HEADER Header,
IN ULONG  ItemsCount,
IN PKSOBJECT_CREATE_ITEM ItemsList  OPTIONAL,
IN PIRP  Irp,
IN KSDISPATCH_TABLE *  Table 
)

Definition at line 610 of file api.c.

616 {
617  PIO_STACK_LOCATION IoStack;
618  //PDEVICE_EXTENSION DeviceExtension;
619  //PKSIDEVICE_HEADER DeviceHeader;
620  PKSIOBJECT_HEADER ObjectHeader;
621  //PKSOBJECT_CREATE_ITEM CreateItem;
623 
624  if (!Header)
626 
627  if (!Irp)
629 
630  if (!Table)
632 
633  /* get current stack location */
635  /* get device extension */
636  //DeviceExtension = (PDEVICE_EXTENSION)IoStack->DeviceObject->DeviceExtension;
637  /* get device header */
638  //DeviceHeader = DeviceExtension->DeviceHeader;
639 
640  /* sanity check */
641  ASSERT(IoStack->FileObject);
642  /* check for an file object */
643 
644  /* allocate the object header */
645  ObjectHeader = AllocateItem(NonPagedPool, sizeof(KSIOBJECT_HEADER));
646  if (!ObjectHeader)
648 
649  /* initialize object header */
650  RtlZeroMemory(ObjectHeader, sizeof(KSIOBJECT_HEADER));
651 
652  /* initialize create item list */
653  InitializeListHead(&ObjectHeader->ItemList);
654 
655  /* get create item */
656  //CreateItem = KSCREATE_ITEM_IRP_STORAGE(Irp);
657 
658  /* do we have a name */
659  if (IoStack->FileObject->FileName.Buffer)
660  {
661  /* copy object class */
662  ObjectHeader->ObjectClass.MaximumLength = IoStack->FileObject->FileName.MaximumLength;
663  ObjectHeader->ObjectClass.Buffer = AllocateItem(NonPagedPool, ObjectHeader->ObjectClass.MaximumLength);
664  if (!ObjectHeader->ObjectClass.Buffer)
665  {
666  FreeItem(ObjectHeader);
668  }
669  RtlCopyUnicodeString(&ObjectHeader->ObjectClass, &IoStack->FileObject->FileName);
670  }
671 
672  /* copy dispatch table */
673  RtlCopyMemory(&ObjectHeader->DispatchTable, Table, sizeof(KSDISPATCH_TABLE));
674 
675  /* store create items */
676  if (ItemsCount && ItemsList)
677  {
678  Status = KspAddCreateItemToList(&ObjectHeader->ItemList, ItemsCount, ItemsList);
679 
680  if (NT_SUCCESS(Status))
681  {
682  /* store item count */
683  ObjectHeader->ItemListCount = ItemsCount;
684  }
685  else
686  {
687  /* destroy header*/
688  KsFreeObjectHeader(ObjectHeader);
689  return Status;
690  }
691  }
692  /* store the object in the file object */
693  IoStack->FileObject->FsContext2 = ObjectHeader;
694 
695  /* store parent device */
696  ObjectHeader->ParentDeviceObject = IoGetRelatedDeviceObject(IoStack->FileObject);
697 
698  /* store originating create item */
699  ObjectHeader->OriginalCreateItem = KSCREATE_ITEM_IRP_STORAGE(Irp);
700 
701  /* FIXME store access mask see KsQueryObjectAccessMask */
702  ObjectHeader->AccessMask = IoStack->Parameters.Create.SecurityContext->DesiredAccess;
703 
704 
705  /* store result */
706  *Header = ObjectHeader;
707 
708  DPRINT("KsAllocateObjectHeader ObjectClass %S FileObject %p, ObjectHeader %p\n", ObjectHeader->ObjectClass.Buffer, IoStack->FileObject, ObjectHeader);
709 
710  return STATUS_SUCCESS;
711 
712 }
ASMGENDATA Table[]
Definition: genincdata.c:61
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
ACCESS_MASK AccessMask
Definition: kstypes.h:41
USHORT MaximumLength
Definition: env_spec_w32.h:370
_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
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1538
KSDDKAPI VOID NTAPI KsFreeObjectHeader(IN PVOID Header)
Definition: api.c:720
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
Definition: Header.h:8
NTSTATUS KspAddCreateItemToList(OUT PLIST_ENTRY ListHead, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList)
Definition: api.c:458
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_INVALID_PARAMETER_5
Definition: ntstatus.h:465
PDEVICE_OBJECT ParentDeviceObject
Definition: kstypes.h:35
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
KSDISPATCH_TABLE DispatchTable
Definition: kstypes.h:22
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PKSOBJECT_CREATE_ITEM OriginalCreateItem
Definition: kstypes.h:40
LIST_ENTRY ItemList
Definition: kstypes.h:26
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:461
UNICODE_STRING ObjectClass
Definition: kstypes.h:28
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
LONG ItemListCount
Definition: kstypes.h:25
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
#define STATUS_INVALID_PARAMETER_4
Definition: ntstatus.h:464
return STATUS_SUCCESS
Definition: btrfs.c:2725
HRESULT Create([out]ITransactionReceiver **ppReceiver)

Referenced by CreatePin(), DispatchCreateKMix(), DispatchCreateSysAudio(), DispatchCreateSysAudioPin(), InitializeFilterWithKs(), KopDispatchCreate(), KsCreateDefaultAllocatorEx(), KsCreateDefaultClock(), KspCreateFilter(), KspCreatePin(), and NewDispatchObject().

◆ KsCacheMedium()

KSDDKAPI NTSTATUS NTAPI KsCacheMedium ( IN PUNICODE_STRING  SymbolicLink,
IN PKSPIN_MEDIUM  Medium,
IN ULONG  PinDirection 
)

Definition at line 1210 of file api.c.

1214 {
1215  HANDLE hKey;
1217  UNICODE_STRING BasePath = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\MediumCache\\");
1219  NTSTATUS Status;
1221  BOOLEAN PathAdjusted = FALSE;
1222  ULONG Value = 0;
1223 
1224  /* first check if the medium is standard */
1225  if (IsEqualGUIDAligned(&KSMEDIUMSETID_Standard, &Medium->Set) ||
1226  IsEqualGUIDAligned(&GUID_NULL, &Medium->Set))
1227  {
1228  /* no need to cache that */
1229  return STATUS_SUCCESS;
1230  }
1231 
1232  /* convert guid to string */
1233  Status = RtlStringFromGUID(&Medium->Set, &GuidString);
1234  if (!NT_SUCCESS(Status))
1235  return Status;
1236 
1237  /* allocate path buffer */
1238  Path.Length = 0;
1239  Path.MaximumLength = BasePath.MaximumLength + GuidString.MaximumLength + 10 * sizeof(WCHAR);
1240  Path.Buffer = AllocateItem(PagedPool, Path.MaximumLength);
1241  if (!Path.Buffer)
1242  {
1243  /* not enough resources */
1246  }
1247 
1248  RtlAppendUnicodeStringToString(&Path, &BasePath);
1251  /* FIXME append real instance id */
1254  /* FIXME append real instance id */
1256 
1257  /* free guid string */
1259 
1260  /* initialize object attributes */
1262  /* create the key */
1263  Status = ZwCreateKey(&hKey, GENERIC_WRITE, &ObjectAttributes, 0, NULL, 0, NULL);
1264 
1265  /* free path buffer */
1266  FreeItem(Path.Buffer);
1267 
1268  if (NT_SUCCESS(Status))
1269  {
1270  /* store symbolic link */
1271  if (SymbolicLink->Buffer[1] == L'?' && SymbolicLink->Buffer[2] == L'?')
1272  {
1273  /* replace kernel path with user mode path */
1274  SymbolicLink->Buffer[1] = L'\\';
1275  PathAdjusted = TRUE;
1276  }
1277 
1278  /* store the key */
1279  Status = ZwSetValueKey(hKey, SymbolicLink, 0, REG_DWORD, &Value, sizeof(ULONG));
1280 
1281  if (PathAdjusted)
1282  {
1283  /* restore kernel path */
1284  SymbolicLink->Buffer[1] = L'?';
1285  }
1286 
1287  ZwClose(hKey);
1288  }
1289 
1290  /* done */
1291  return Status;
1292 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
static PWSTR GuidString
Definition: apphelp.c:91
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
USHORT MaximumLength
Definition: env_spec_w32.h:370
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
const GUID KSMEDIUMSETID_Standard
Definition: api.c:15
#define GENERIC_WRITE
Definition: nt_native.h:90
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static const WCHAR L[]
Definition: oid.c:1250
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
Status
Definition: gdiplustypes.h:24
PRTL_UNICODE_STRING_BUFFER Path
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
const GUID GUID_NULL
Definition: api.c:14
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define REG_DWORD
Definition: sdbapi.c:596
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
static const WCHAR SymbolicLink[]
Definition: interface.c:31
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by KsRegisterFilterWithNoKSPins().

◆ KsCompletePendingRequest()

KSDDKAPI VOID NTAPI KsCompletePendingRequest ( IN PIRP  Irp)

Definition at line 1693 of file api.c.

1695 {
1696  PIO_STACK_LOCATION IoStack;
1697 
1698  /* get current irp stack location */
1699  IoStack = IoGetCurrentIrpStackLocation(Irp);
1700 
1701  /* sanity check */
1702  ASSERT(Irp->IoStatus.Status != STATUS_PENDING);
1703 
1704  if (IoStack->MajorFunction != IRP_MJ_CLOSE)
1705  {
1706  /* can be completed immediately */
1708  return;
1709  }
1710 
1711  /* did close operation fail */
1712  if (!NT_SUCCESS(Irp->IoStatus.Status))
1713  {
1714  /* closing failed, complete irp */
1716  return;
1717  }
1718 
1719  /* FIXME
1720  * delete object / device header
1721  * remove dead pin / filter instance
1722  */
1723  UNIMPLEMENTED;
1724 
1725 }
_In_ PIRP Irp
Definition: csq.h:116
#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)
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#define UNIMPLEMENTED
Definition: debug.h:114

◆ KsCreateDefaultSecurity()

KSDDKAPI NTSTATUS NTAPI KsCreateDefaultSecurity ( IN PSECURITY_DESCRIPTOR ParentSecurity  OPTIONAL,
OUT PSECURITY_DESCRIPTOR DefaultSecurity 
)

Definition at line 1025 of file api.c.

1028 {
1031  NTSTATUS Status;
1032 
1033  /* start capturing security context of calling thread */
1035  /* get generic mapping */
1037  /* build new descriptor */
1038  Status = SeAssignSecurity(ParentSecurity, NULL, DefaultSecurity, FALSE, &SubjectContext, Mapping, NonPagedPool);
1039  /* release security descriptor */
1041  /* done */
1042  return Status;
1043 }
PGENERIC_MAPPING NTAPI IoGetFileObjectGenericMapping(VOID)
Definition: file.c:3266
VOID NTAPI SeCaptureSubjectContext(OUT PSECURITY_SUBJECT_CONTEXT SubjectContext)
Definition: access.c:301
_Inout_ PLIST_ENTRY _In_ PVOID _In_ PSTRING _In_ BOOLEAN _In_ BOOLEAN _In_ ULONG _In_ PFLT_CALLBACK_DATA _In_opt_ PCHECK_FOR_TRAVERSE_ACCESS _In_opt_ PSECURITY_SUBJECT_CONTEXT SubjectContext
Definition: fltkernel.h:2239
VOID NTAPI SeReleaseSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext)
Definition: access.c:360
static PVOID Mapping[EMS_PHYSICAL_PAGES]
Definition: emsdrv.c:41
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
Status
Definition: gdiplustypes.h:24

◆ KsDefaultDispatchPnp()

KSDDKAPI NTSTATUS NTAPI KsDefaultDispatchPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 110 of file api.c.

113 {
114  PDEVICE_EXTENSION DeviceExtension;
115  PKSIDEVICE_HEADER DeviceHeader;
116  PIO_STACK_LOCATION IoStack;
117  PDEVICE_OBJECT PnpDeviceObject;
120 
121  /* get current irp stack */
123 
124  /* caller wants to add the target device */
125  DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
126 
127  /* get device header */
128  DeviceHeader = (PKSIDEVICE_HEADER)DeviceExtension->DeviceHeader;
129 
130  /* backup PnpBaseObject */
131  PnpDeviceObject = DeviceHeader->PnpDeviceObject;
132 
133 
134  /* backup minor function code */
135  MinorFunction = IoStack->MinorFunction;
136 
138  {
139  /* remove the device */
140  KsFreeDeviceHeader((KSDEVICE_HEADER)DeviceHeader);
141  }
142 
143  /* skip current irp stack */
145 
146  /* call attached pnp device object */
147  Status = IoCallDriver(PnpDeviceObject, Irp);
148 
150  {
151  /* time is over */
152  IoDetachDevice(PnpDeviceObject);
153  /* delete device */
155  }
156  /* done */
157  return Status;
158 }
#define IRP_MN_REMOVE_DEVICE
PDEVICE_OBJECT PnpDeviceObject
Definition: kstypes.h:97
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1295
PVOID DeviceExtension
Definition: env_spec_w32.h:418
KSDDKAPI VOID NTAPI KsFreeDeviceHeader(IN KSDEVICE_HEADER DevHeader)
Definition: api.c:590
_In_ UCHAR MinorFunction
Definition: pofuncs.h:42
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
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1250
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
unsigned int ULONG
Definition: retypes.h:1
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION

Referenced by KMix_Pnp(), KoDriverInitialize(), KsDispatchIrp(), KspDispatchIrp(), SysAudio_Pnp(), and WdmAudPnp().

◆ KsDefaultDispatchPower()

KSDDKAPI NTSTATUS NTAPI KsDefaultDispatchPower ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 166 of file api.c.

169 {
170  PDEVICE_EXTENSION DeviceExtension;
171  PKSIDEVICE_HEADER DeviceHeader;
172  PKSIOBJECT_HEADER ObjectHeader;
173  //PIO_STACK_LOCATION IoStack;
174  PLIST_ENTRY ListEntry;
176 
177  /* get current irp stack */
178  //IoStack = IoGetCurrentIrpStackLocation(Irp);
179 
180  /* caller wants to add the target device */
181  DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
182 
183  /* get device header */
184  DeviceHeader = (PKSIDEVICE_HEADER)DeviceExtension->DeviceHeader;
185 
186  /* FIXME locks */
187 
188  /* loop our power dispatch list and call registered notification functions */
189  ListEntry = DeviceHeader->PowerDispatchList.Flink;
190  /* let's go */
191  while(ListEntry != &DeviceHeader->PowerDispatchList)
192  {
193  /* get object header */
194  ObjectHeader = (PKSIOBJECT_HEADER)CONTAINING_RECORD(ListEntry, KSIOBJECT_HEADER, PowerDispatchEntry);
195 
196  /* does it have still a cb */
197  if (ObjectHeader->PowerDispatch)
198  {
199  /* call the power cb */
200  Status = ObjectHeader->PowerDispatch(ObjectHeader->PowerContext, Irp);
202  }
203 
204  /* iterate to next entry */
205  ListEntry = ListEntry->Flink;
206  }
207 
208  /* start next power irp */
210 
211  /* skip current irp stack location */
213 
214  /* let's roll */
215  Status = PoCallDriver(DeviceHeader->PnpDeviceObject, Irp);
216 
217  /* done */
218  return Status;
219 }
NTSTATUS NTAPI PoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: power.c:478
PDEVICE_OBJECT PnpDeviceObject
Definition: kstypes.h:97
_In_ PIRP Irp
Definition: csq.h:116
struct KSIOBJECT_HEADER * PKSIOBJECT_HEADER
LONG NTSTATUS
Definition: precomp.h:26
PVOID PowerContext
Definition: kstypes.h:38
PFNKSCONTEXT_DISPATCH PowerDispatch
Definition: kstypes.h:37
PVOID DeviceExtension
Definition: env_spec_w32.h:418
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
LIST_ENTRY PowerDispatchList
Definition: kstypes.h:106
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:619
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION

Referenced by DriverEntry(), KoDriverInitialize(), and KsDispatchIrp().

◆ KsDefaultForwardIrp()

KSDDKAPI NTSTATUS NTAPI KsDefaultForwardIrp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 227 of file api.c.

230 {
231  PDEVICE_EXTENSION DeviceExtension;
232  PKSIDEVICE_HEADER DeviceHeader;
233  //PIO_STACK_LOCATION IoStack;
235 
236  /* get current irp stack */
237  //IoStack = IoGetCurrentIrpStackLocation(Irp);
238 
239  /* caller wants to add the target device */
240  DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
241 
242  /* get device header */
243  DeviceHeader = (PKSIDEVICE_HEADER)DeviceExtension->DeviceHeader;
244 
245  /* forward the request to the PDO */
246  Status = IoCallDriver(DeviceHeader->PnpDeviceObject, Irp);
247 
248  return Status;
249 }
PDEVICE_OBJECT PnpDeviceObject
Definition: kstypes.h:97
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
PVOID DeviceExtension
Definition: env_spec_w32.h:418
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION

Referenced by DriverEntry(), KoDriverInitialize(), KsDispatchIrp(), and KsInitializeDriver().

◆ KsDeviceGetBusData()

KSDDKAPI ULONG NTAPI KsDeviceGetBusData ( IN PKSDEVICE  Device,
IN ULONG  DataType,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)

Definition at line 1823 of file api.c.

1829 {
1830  return KspDeviceSetGetBusData(Device->PhysicalDeviceObject, /* is this right? */
1832 
1833 }
#define TRUE
Definition: types.h:120
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
NTSTATUS KspDeviceSetGetBusData(IN PDEVICE_OBJECT DeviceObject, IN ULONG DataType, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length, IN BOOL bGet)
Definition: api.c:1743
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: bufpool.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_ ULONG DataType
Definition: iotypes.h:787

◆ KsDeviceRegisterAdapterObject()

KSDDKAPI void NTAPI KsDeviceRegisterAdapterObject ( IN PKSDEVICE  Device,
IN PADAPTER_OBJECT  AdapterObject,
IN ULONG  MaxMappingsByteCount,
IN ULONG  MappingTableStride 
)

Definition at line 1841 of file api.c.

1846 {
1848 
1849  DeviceHeader->AdapterObject = AdapterObject;
1850  DeviceHeader->MaxMappingsByteCount = MaxMappingsByteCount;
1851  DeviceHeader->MappingTableStride = MappingTableStride;
1852 
1853 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
ULONG MappingTableStride
Definition: kstypes.h:111
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
ULONG MaxMappingsByteCount
Definition: kstypes.h:110
PADAPTER_OBJECT AdapterObject
Definition: kstypes.h:109

◆ KsDeviceSetBusData()

KSDDKAPI ULONG NTAPI KsDeviceSetBusData ( IN PKSDEVICE  Device,
IN ULONG  DataType,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)

Definition at line 1805 of file api.c.

1811 {
1812  return KspDeviceSetGetBusData(Device->PhysicalDeviceObject, /* is this right? */
1814 }
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
NTSTATUS KspDeviceSetGetBusData(IN PDEVICE_OBJECT DeviceObject, IN ULONG DataType, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length, IN BOOL bGet)
Definition: api.c:1743
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: bufpool.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_ ULONG DataType
Definition: iotypes.h:787

◆ KsForwardAndCatchIrp()

KSDDKAPI NTSTATUS NTAPI KsForwardAndCatchIrp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PFILE_OBJECT  FileObject,
IN KSSTACK_USE  StackUse 
)

Definition at line 1067 of file api.c.

1072 {
1073  UNIMPLEMENTED;
1074  return STATUS_UNSUCCESSFUL;
1075 }
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define UNIMPLEMENTED
Definition: debug.h:114

◆ KsForwardIrp()

KSDDKAPI NTSTATUS NTAPI KsForwardIrp ( IN PIRP  Irp,
IN PFILE_OBJECT  FileObject,
IN BOOLEAN  ReuseStackLocation 
)

Definition at line 1051 of file api.c.

1055 {
1056  UNIMPLEMENTED;
1057  return STATUS_UNSUCCESSFUL;
1058 }
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define UNIMPLEMENTED
Definition: debug.h:114

◆ KsFreeDeviceHeader()

KSDDKAPI VOID NTAPI KsFreeDeviceHeader ( IN KSDEVICE_HEADER  DevHeader)

Definition at line 590 of file api.c.

592 {
594 
595  Header = (PKSIDEVICE_HEADER)DevHeader;
596 
597  if (!DevHeader)
598  return;
599 
600  KspFreeCreateItems(&Header->ItemList);
601  FreeItem(Header);
602 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
Definition: Header.h:8
VOID KspFreeCreateItems(PLIST_ENTRY ListHead)
Definition: api.c:489

Referenced by KopAddDevice(), KsDefaultDispatchPnp(), KsInitializeDevice(), KsTerminateDevice(), and PcAddAdapterDevice().

◆ KsFreeObjectCreateItem()

KSDDKAPI NTSTATUS NTAPI KsFreeObjectCreateItem ( IN KSDEVICE_HEADER  Header,
IN PUNICODE_STRING  CreateItem 
)

Definition at line 987 of file api.c.

990 {
991  KSOBJECT_CREATE_ITEM Item;
992 
993  RtlZeroMemory(&Item, sizeof(KSOBJECT_CREATE_ITEM));
994  RtlInitUnicodeString(&Item.ObjectClass, CreateItem->Buffer);
995 
996  return KspObjectFreeCreateItems(Header, &Item);
997 }
Definition: Header.h:8
NTSTATUS KspObjectFreeCreateItems(IN KSDEVICE_HEADER Header, IN PKSOBJECT_CREATE_ITEM CreateItem)
Definition: api.c:973
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

◆ KsFreeObjectCreateItemsByContext()

KSDDKAPI NTSTATUS NTAPI KsFreeObjectCreateItemsByContext ( IN KSDEVICE_HEADER  Header,
IN PVOID  Context 
)

Definition at line 1006 of file api.c.

1009 {
1010  KSOBJECT_CREATE_ITEM Item;
1011 
1012  RtlZeroMemory(&Item, sizeof(KSOBJECT_CREATE_ITEM));
1013 
1014  Item.Context = Context;
1015 
1016  return KspObjectFreeCreateItems(Header, &Item);
1017 }
Definition: Header.h:8
NTSTATUS KspObjectFreeCreateItems(IN KSDEVICE_HEADER Header, IN PKSOBJECT_CREATE_ITEM CreateItem)
Definition: api.c:973
struct tagContext Context
Definition: acpixf.h:1012
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

◆ KsFreeObjectHeader()

KSDDKAPI VOID NTAPI KsFreeObjectHeader ( IN PVOID  Header)

Definition at line 720 of file api.c.

722 {
723  PKSIOBJECT_HEADER ObjectHeader = (PKSIOBJECT_HEADER) Header;
724 
725  DPRINT("KsFreeObjectHeader Header %p Class %wZ\n", Header, &ObjectHeader->ObjectClass);
726 
727  if (ObjectHeader->ObjectClass.Buffer)
728  {
729  /* release object class buffer */
730  FreeItem(ObjectHeader->ObjectClass.Buffer);
731  }
732 
733  if (ObjectHeader->Unknown)
734  {
735  /* release associated object */
736  ObjectHeader->Unknown->lpVtbl->Release(ObjectHeader->Unknown);
737  }
738 
739  /* free create items */
740  KspFreeCreateItems(&ObjectHeader->ItemList);
741 
742  /* free object header */
743  FreeItem(ObjectHeader);
744 
745 }
PUNKNOWN Unknown
Definition: kstypes.h:29
struct KSIOBJECT_HEADER * PKSIOBJECT_HEADER
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
Definition: Header.h:8
ULONG Release()
void DPRINT(...)
Definition: polytest.cpp:61
LIST_ENTRY ItemList
Definition: kstypes.h:26
UNICODE_STRING ObjectClass
Definition: kstypes.h:28
VOID KspFreeCreateItems(PLIST_ENTRY ListHead)
Definition: api.c:489

Referenced by Dispatch_fnClose(), DispatchCreateSysAudioPin(), IKsAllocator_fnClose(), IKsFilter_DispatchClose(), KopDispatchClose(), KopDispatchCreate(), KsAllocateObjectHeader(), KsCreateDefaultAllocatorEx(), and KspCreatePin().

◆ KsGetFirstChild()

KSDDKAPI PVOID NTAPI KsGetFirstChild ( IN PVOID  Object)

Definition at line 1862 of file api.c.

1864 {
1865  PKSBASIC_HEADER BasicHeader;
1866 
1867  /* get the basic header */
1868  BasicHeader = (PKSBASIC_HEADER)((ULONG_PTR)Object - sizeof(KSBASIC_HEADER));
1869 
1870  /* type has to be either a device or a filter factory */
1871  ASSERT(BasicHeader->Type == KsObjectTypeDevice || BasicHeader->Type == KsObjectTypeFilterFactory);
1872 
1873  return (PVOID)BasicHeader->FirstChild.Filter;
1874 }
struct KSBASIC_HEADER * PKSBASIC_HEADER
uint32_t ULONG_PTR
Definition: typedefs.h:63
KSOBJECTTYPE Type
Definition: kstypes.h:56
union KSBASIC_HEADER::@955 FirstChild
static IUnknown Object
Definition: main.c:512
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PKSFILTER Filter
Definition: kstypes.h:73

◆ KsGetNextSibling()

KSDDKAPI PVOID NTAPI KsGetNextSibling ( IN PVOID  Object)

Definition at line 1882 of file api.c.

1884 {
1885  PKSBASIC_HEADER BasicHeader;
1886 
1887  /* get the basic header */
1888  BasicHeader = (PKSBASIC_HEADER)((ULONG_PTR)Object - sizeof(KSBASIC_HEADER));
1889 
1890  ASSERT(BasicHeader->Type == KsObjectTypeDevice || BasicHeader->Type == KsObjectTypeFilterFactory ||
1891  BasicHeader->Type == KsObjectTypeFilter || BasicHeader->Type == KsObjectTypePin);
1892 
1893  return (PVOID)BasicHeader->Next.Pin;
1894 }
struct KSBASIC_HEADER * PKSBASIC_HEADER
uint32_t ULONG_PTR
Definition: typedefs.h:63
KSOBJECTTYPE Type
Definition: kstypes.h:56
PKSPIN Pin
Definition: kstypes.h:74
static IUnknown Object
Definition: main.c:512
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
union KSBASIC_HEADER::@954 Next

Referenced by KsPinGetNextSiblingPin().

◆ KsMergeAutomationTables()

NTSTATUS NTAPI KsMergeAutomationTables ( OUT PKSAUTOMATION_TABLE *  AutomationTableAB,
IN PKSAUTOMATION_TABLE AutomationTableA  OPTIONAL,
IN PKSAUTOMATION_TABLE AutomationTableB  OPTIONAL,
IN KSOBJECT_BAG Bag  OPTIONAL 
)

Definition at line 2303 of file api.c.

2308 {
2309  PKSAUTOMATION_TABLE Table;
2311 
2312  if (!AutomationTableA && !AutomationTableB)
2313  {
2314  /* nothing to merge */
2315  return STATUS_SUCCESS;
2316  }
2317 
2318  /* allocate an automation table */
2319  Table = AllocateItem(NonPagedPool, sizeof(KSAUTOMATION_TABLE));
2320  if (!Table)
2322 
2323  if (Bag)
2324  {
2325  /* add table to object bag */
2327  /* check for success */
2328  if (!NT_SUCCESS(Status))
2329  {
2330  /* free table */
2331  FreeItem(Table);
2332  return Status;
2333  }
2334  }
2335 
2336  /* count property sets */
2337  Table->PropertySetsCount = KspCountPropertySets(AutomationTableA, AutomationTableB);
2338 
2339  if (Table->PropertySetsCount)
2340  {
2341  if (AutomationTableA)
2342  {
2343  /* use item size from dominant automation table */
2344  Table->PropertyItemSize = AutomationTableA->PropertyItemSize;
2345  }
2346  else
2347  {
2348  /* use item size from 2nd automation table */
2349  Table->PropertyItemSize = AutomationTableB->PropertyItemSize;
2350  }
2351 
2352  if (AutomationTableA && AutomationTableB)
2353  {
2354  // FIXME handle different property item sizes
2355  ASSERT(AutomationTableA->PropertyItemSize == AutomationTableB->PropertyItemSize);
2356  }
2357 
2358  /* now allocate the property sets */
2359  Table->PropertySets = AllocateItem(NonPagedPool, sizeof(KSPROPERTY_SET) * Table->PropertySetsCount);
2360 
2361  if (!Table->PropertySets)
2362  {
2363  /* not enough memory */
2364  goto cleanup;
2365  }
2366 
2367  if (Bag)
2368  {
2369  /* add set to property bag */
2370  Status = KsAddItemToObjectBag(Bag, (PVOID)Table->PropertySets, NULL);
2371  /* check for success */
2372  if (!NT_SUCCESS(Status))
2373  {
2374  /* cleanup table */
2375  goto cleanup;
2376  }
2377  }
2378  /* now copy the property sets */
2379  Status = KspCopyPropertySets(Table, AutomationTableA, AutomationTableB, Bag);
2380  if(!NT_SUCCESS(Status))
2381  goto cleanup;
2382 
2383  }
2384 
2385  /* now count the method sets */
2386  Table->MethodSetsCount = KspCountMethodSets(AutomationTableA, AutomationTableB);
2387 
2388  if (Table->MethodSetsCount)
2389  {
2390  if (AutomationTableA)
2391  {
2392  /* use item size from dominant automation table */
2393  Table->MethodItemSize = AutomationTableA->MethodItemSize;
2394  }
2395  else
2396  {
2397  /* use item size from 2nd automation table */
2398  Table->MethodItemSize = AutomationTableB->MethodItemSize;
2399  }
2400 
2401  /* now allocate the property sets */
2402  Table->MethodSets = AllocateItem(NonPagedPool, sizeof(KSMETHOD_SET) * Table->MethodSetsCount);
2403 
2404  if (!Table->MethodSets)
2405  {
2406  /* not enough memory */
2407  goto cleanup;
2408  }
2409 
2410  if (Bag)
2411  {
2412  /* add set to property bag */
2413  Status = KsAddItemToObjectBag(Bag, (PVOID)Table->MethodSets, NULL);
2414  /* check for success */
2415  if (!NT_SUCCESS(Status))
2416  {
2417  /* cleanup table */
2418  goto cleanup;
2419  }
2420  }
2421  /* now copy the property sets */
2422  Status = KspCopyMethodSets(Table, AutomationTableA, AutomationTableB);
2423  if(!NT_SUCCESS(Status))
2424  goto cleanup;
2425  }
2426 
2427 
2428  /* now count the event sets */
2429  Table->EventSetsCount = KspCountEventSets(AutomationTableA, AutomationTableB);
2430 
2431  if (Table->EventSetsCount)
2432  {
2433  if (AutomationTableA)
2434  {
2435  /* use item size from dominant automation table */
2436  Table->EventItemSize = AutomationTableA->EventItemSize;
2437  }
2438  else
2439  {
2440  /* use item size from 2nd automation table */
2441  Table->EventItemSize = AutomationTableB->EventItemSize;
2442  }
2443 
2444  /* now allocate the property sets */
2445  Table->EventSets = AllocateItem(NonPagedPool, sizeof(KSEVENT_SET) * Table->EventSetsCount);
2446 
2447  if (!Table->EventSets)
2448  {
2449  /* not enough memory */
2450  goto cleanup;
2451  }
2452 
2453  if (Bag)
2454  {
2455  /* add set to property bag */
2456  Status = KsAddItemToObjectBag(Bag, (PVOID)Table->EventSets, NULL);
2457  /* check for success */
2458  if (!NT_SUCCESS(Status))
2459  {
2460  /* cleanup table */
2461  goto cleanup;
2462  }
2463  }
2464  /* now copy the property sets */
2465  Status = KspCopyEventSets(Table, AutomationTableA, AutomationTableB);
2466  if(!NT_SUCCESS(Status))
2467  goto cleanup;
2468  }
2469 
2470  /* store result */
2471  *AutomationTableAB = Table;
2472 
2473  return Status;
2474 
2475 
2476 cleanup:
2477 
2478  if (Table)
2479  {
2480  if (Table->PropertySets)
2481  {
2482  /* clean property sets */
2483  if (!Bag || !NT_SUCCESS(KsRemoveItemFromObjectBag(Bag, (PVOID)Table->PropertySets, TRUE)))
2484  FreeItem((PVOID)Table->PropertySets);
2485  }
2486 
2487  if (Table->MethodSets)
2488  {
2489  /* clean property sets */
2490  if (!Bag || !NT_SUCCESS(KsRemoveItemFromObjectBag(Bag, (PVOID)Table->MethodSets, TRUE)))
2491  FreeItem((PVOID)Table->MethodSets);
2492  }
2493 
2494  if (Table->EventSets)
2495  {
2496  /* clean property sets */
2497  if (!Bag || !NT_SUCCESS(KsRemoveItemFromObjectBag(Bag, (PVOID)Table->EventSets, TRUE)))
2498  FreeItem((PVOID)Table->EventSets);
2499  }
2500 
2501  if (!Bag || !NT_SUCCESS(KsRemoveItemFromObjectBag(Bag, Table, TRUE)))
2502  FreeItem(Table);
2503  }
2504 
2506 }
ULONG KspCountEventSets(IN PKSAUTOMATION_TABLE AutomationTableA OPTIONAL, IN PKSAUTOMATION_TABLE AutomationTableB OPTIONAL)
Definition: api.c:1946
ASMGENDATA Table[]
Definition: genincdata.c:61
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS NTAPI KsAddItemToObjectBag(IN KSOBJECT_BAG ObjectBag, IN PVOID Item, IN PFNKSFREE Free OPTIONAL)
Definition: bag.c:86
ULONG KspCountMethodSets(IN PKSAUTOMATION_TABLE AutomationTableA OPTIONAL, IN PKSAUTOMATION_TABLE AutomationTableB OPTIONAL)
Definition: api.c:1897
ULONG KspCountPropertySets(IN PKSAUTOMATION_TABLE AutomationTableA OPTIONAL, IN PKSAUTOMATION_TABLE AutomationTableB OPTIONAL)
Definition: api.c:1995
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
KSDDKAPI ULONG NTAPI KsRemoveItemFromObjectBag(IN KSOBJECT_BAG ObjectBag, IN PVOID Item, IN BOOLEAN Free)
Definition: bag.c:179
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
NTSTATUS KspCopyEventSets(OUT PKSAUTOMATION_TABLE Table, IN PKSAUTOMATION_TABLE AutomationTableA OPTIONAL, IN PKSAUTOMATION_TABLE AutomationTableB OPTIONAL)
Definition: api.c:2244
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS KspCopyMethodSets(OUT PKSAUTOMATION_TABLE Table, IN PKSAUTOMATION_TABLE AutomationTableA OPTIONAL, IN PKSAUTOMATION_TABLE AutomationTableB OPTIONAL)
Definition: api.c:2039
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
NTSTATUS KspCopyPropertySets(OUT PKSAUTOMATION_TABLE Table, IN PKSAUTOMATION_TABLE AutomationTableA OPTIONAL, IN PKSAUTOMATION_TABLE AutomationTableB OPTIONAL, IN KSOBJECT_BAG Bag OPTIONAL)
Definition: api.c:2177
char * cleanup(char *str)
Definition: wpickclick.c:99
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by BdaCreateFilterFactoryEx(), BdaCreatePin(), IKsFilter_CopyFilterDescriptor(), and KspCreatePin().

◆ KspAddCreateItemToList()

NTSTATUS KspAddCreateItemToList ( OUT PLIST_ENTRY  ListHead,
IN ULONG  ItemsCount,
IN PKSOBJECT_CREATE_ITEM  ItemsList 
)

Definition at line 458 of file api.c.

462 {
463  ULONG Index;
465 
466  /* add the items */
467  for(Index = 0; Index < ItemsCount; Index++)
468  {
469  /* allocate item */
471  if (!Entry)
472  {
473  /* no memory */
475  }
476 
477  /* initialize entry */
478  InitializeListHead(&Entry->ObjectItemList);
479  Entry->CreateItem = &ItemsList[Index];
480  Entry->ReferenceCount = 0;
481  Entry->ItemFreeCallback = NULL;
482 
483  InsertTailList(ListHead, &Entry->Entry);
484  }
485  return STATUS_SUCCESS;
486 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _Entry Entry
Definition: kefuncs.h:640
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
#define InsertTailList(ListHead, Entry)
Definition: kstypes.h:45
Entry(ENTRY_TYPE etype)
Definition: entries.cpp:35
smooth NULL
Definition: ftsmooth.c:416
static const UCHAR Index[8]
Definition: usbohci.c:18
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2725
base of all file and directory entries
Definition: entries.h:82

Referenced by KsAllocateDeviceHeader(), and KsAllocateObjectHeader().

◆ KspAddObjectCreateItemToList()

NTSTATUS KspAddObjectCreateItemToList ( PLIST_ENTRY  ListHead,
IN PDRIVER_DISPATCH  Create,
IN PVOID  Context,
IN PWCHAR  ObjectClass,
IN PSECURITY_DESCRIPTOR  SecurityDescriptor 
)

Definition at line 748 of file api.c.

754 {
756  PCREATE_ITEM_ENTRY CreateEntry;
757 
758  /* point to first entry */
759  Entry = ListHead->Flink;
760 
761  while(Entry != ListHead)
762  {
763  /* get create entry */
765  /* if the create item has no create routine, then it is free to use */
766  if (CreateEntry->CreateItem->Create == NULL)
767  {
768  /* sanity check */
769  ASSERT(IsListEmpty(&CreateEntry->ObjectItemList));
770  ASSERT(CreateEntry->ReferenceCount == 0);
771  /* use free entry */
772  CreateEntry->CreateItem->Context = Context;
773  CreateEntry->CreateItem->Create = Create;
774  RtlInitUnicodeString(&CreateEntry->CreateItem->ObjectClass, ObjectClass);
775  CreateEntry->CreateItem->SecurityDescriptor = SecurityDescriptor;
776 
777  return STATUS_SUCCESS;
778  }
779 
780  if (!wcsicmp(ObjectClass, CreateEntry->CreateItem->ObjectClass.Buffer))
781  {
782  /* the same object class already exists */
784  }
785 
786  /* iterate to next entry */
787  Entry = Entry->Flink;
788  }
790 }
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
struct _Entry Entry
Definition: kefuncs.h:640
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
Definition: wsk.h:182
_In_ BOOLEAN Create
Definition: pstypes.h:511
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
Definition: kstypes.h:45
PKSOBJECT_CREATE_ITEM CreateItem
Definition: kstypes.h:48
smooth NULL
Definition: ftsmooth.c:416
struct CREATE_ITEM_ENTRY * PCREATE_ITEM_ENTRY
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define STATUS_ALLOTTED_SPACE_EXCEEDED
Definition: ntstatus.h:375
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: typedefs.h:117
#define wcsicmp
Definition: string.h:1152
LIST_ENTRY ObjectItemList
Definition: kstypes.h:51
LONG ReferenceCount
Definition: kstypes.h:50
struct tagContext Context
Definition: acpixf.h:1012
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
return STATUS_SUCCESS
Definition: btrfs.c:2725
base of all file and directory entries
Definition: entries.h:82

Referenced by KsAddObjectCreateItemToDeviceHeader(), and KsAddObjectCreateItemToObjectHeader().

◆ KspAddPropertyItem()

VOID KspAddPropertyItem ( OUT PKSPROPERTY_SET  OutPropertySet,
IN PKSPROPERTY_ITEM  PropertyItem,
IN ULONG  PropertyItemSize 
)

Definition at line 2093 of file api.c.

2097 {
2098  PKSPROPERTY_ITEM CurrentPropertyItem;
2099  ULONG Index;
2100 
2101  // check if the property item is already present
2102  CurrentPropertyItem = (PKSPROPERTY_ITEM)OutPropertySet->PropertyItem;
2103  for(Index = 0; Index < OutPropertySet->PropertiesCount; Index++)
2104  {
2105  if (CurrentPropertyItem->PropertyId == PropertyItem->PropertyId)
2106  {
2107  // item already present
2108  return;
2109  }
2110 
2111  // next item
2112  CurrentPropertyItem = (PKSPROPERTY_ITEM)((ULONG_PTR)CurrentPropertyItem + PropertyItemSize);
2113  }
2114  // add item
2115  RtlCopyMemory(CurrentPropertyItem, PropertyItem, PropertyItemSize);
2116  OutPropertySet->PropertiesCount++;
2117 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
uint32_t ULONG_PTR
Definition: typedefs.h:63
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned int ULONG
Definition: retypes.h:1

Referenced by KspMergePropertySet().

◆ KspCopyEventSets()

NTSTATUS KspCopyEventSets ( OUT PKSAUTOMATION_TABLE  Table,
IN PKSAUTOMATION_TABLE AutomationTableA  OPTIONAL,
IN PKSAUTOMATION_TABLE AutomationTableB  OPTIONAL 
)

Definition at line 2244 of file api.c.

2248 {
2249  ULONG Index, SubIndex, Count;
2250  BOOL bFound;
2251 
2252  if (!AutomationTableA)
2253  {
2254  /* copy of Event set */
2255  RtlMoveMemory((PVOID)Table->EventSets, AutomationTableB->EventSets, sizeof(KSEVENT_SET) * AutomationTableB->EventSetsCount);
2256  return STATUS_SUCCESS;
2257  }
2258  else if (!AutomationTableB)
2259  {
2260  /* copy of Event set */
2261  RtlMoveMemory((PVOID)Table->EventSets, AutomationTableA->EventSets, sizeof(KSEVENT_SET) * AutomationTableA->EventSetsCount);
2262  return STATUS_SUCCESS;
2263  }
2264 
2265  /* first copy all Event items from dominant table */
2266  RtlMoveMemory((PVOID)Table->EventSets, AutomationTableA->EventSets, sizeof(KSEVENT_SET) * AutomationTableA->EventSetsCount);
2267  /* set counter */
2268  Count = AutomationTableA->EventSetsCount;
2269 
2270  /* now copy entries which aren't available in the dominant table */
2271  for(Index = 0; Index < AutomationTableB->EventSetsCount; Index++)
2272  {
2273  /* set found to false */
2274  bFound = FALSE;
2275 
2276  for(SubIndex = 0; SubIndex < AutomationTableA->EventSetsCount; SubIndex++)
2277  {
2278  if (IsEqualGUIDAligned(AutomationTableB->EventSets[Index].Set, AutomationTableA->EventSets[SubIndex].Set))
2279  {
2280  /* same Event set found */
2281  bFound = TRUE;
2282  break;
2283  }
2284  }
2285 
2286  if (!bFound)
2287  {
2288  /* copy new Event item set */
2289  RtlMoveMemory((PVOID)&Table->EventSets[Count], &AutomationTableB->EventSets[Index], sizeof(KSEVENT_SET));
2290  Count++;
2291  }
2292  }
2293 
2294  return STATUS_SUCCESS;
2295 }
ASMGENDATA Table[]
Definition: genincdata.c:61
#define TRUE
Definition: types.h:120
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
unsigned int BOOL
Definition: ntddk_ex.h:94
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by KsMergeAutomationTables().

◆ KspCopyMethodSets()

NTSTATUS KspCopyMethodSets ( OUT PKSAUTOMATION_TABLE  Table,
IN PKSAUTOMATION_TABLE AutomationTableA  OPTIONAL,
IN PKSAUTOMATION_TABLE AutomationTableB  OPTIONAL 
)

Definition at line 2039 of file api.c.

2043 {
2044  ULONG Index, SubIndex, Count;
2045  BOOL bFound;
2046 
2047  if (!AutomationTableA)
2048  {
2049  /* copy of property set */
2050  RtlMoveMemory((PVOID)Table->MethodSets, AutomationTableB->MethodSets, sizeof(KSMETHOD_SET) * AutomationTableB->MethodSetsCount);
2051  return STATUS_SUCCESS;
2052  }
2053  else if (!AutomationTableB)
2054  {
2055  /* copy of property set */
2056  RtlMoveMemory((PVOID)Table->MethodSets, AutomationTableA->MethodSets, sizeof(KSMETHOD_SET) * AutomationTableA->MethodSetsCount);
2057  return STATUS_SUCCESS;
2058  }
2059 
2060  /* first copy all property items from dominant table */
2061  RtlMoveMemory((PVOID)Table->MethodSets, AutomationTableA->MethodSets, sizeof(KSMETHOD_SET) * AutomationTableA->MethodSetsCount);
2062  /* set counter */
2063  Count = AutomationTableA->MethodSetsCount;
2064 
2065  /* now copy entries which aren't available in the dominant table */
2066  for(Index = 0; Index < AutomationTableB->MethodSetsCount; Index++)
2067  {
2068  /* set found to false */
2069  bFound = FALSE;
2070 
2071  for(SubIndex = 0; SubIndex < AutomationTableA->MethodSetsCount; SubIndex++)
2072  {
2073  if (IsEqualGUIDAligned(AutomationTableB->MethodSets[Index].Set, AutomationTableA->MethodSets[SubIndex].Set))
2074  {
2075  /* same property set found */
2076  bFound = TRUE;
2077  break;
2078  }
2079  }
2080 
2081  if (!bFound)
2082  {
2083  /* copy new property item set */
2084  RtlMoveMemory((PVOID)&Table->MethodSets[Count], &AutomationTableB->MethodSets[Index], sizeof(KSMETHOD_SET));
2085  Count++;
2086  }
2087  }
2088 
2089  return STATUS_SUCCESS;
2090 }
ASMGENDATA Table[]
Definition: genincdata.c:61
#define TRUE
Definition: types.h:120
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
unsigned int BOOL
Definition: ntddk_ex.h:94
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by KsMergeAutomationTables().

◆ KspCopyPropertySets()

NTSTATUS KspCopyPropertySets ( OUT PKSAUTOMATION_TABLE  Table,
IN PKSAUTOMATION_TABLE AutomationTableA  OPTIONAL,
IN PKSAUTOMATION_TABLE AutomationTableB  OPTIONAL,
IN KSOBJECT_BAG Bag  OPTIONAL 
)

Definition at line 2177 of file api.c.

2182 {
2183  ULONG Index, SubIndex, Count;
2184  BOOL bFound;
2185  NTSTATUS Status;
2186 
2187  if (!AutomationTableA)
2188  {
2189  /* copy of property set */
2190  RtlMoveMemory((PVOID)Table->PropertySets, AutomationTableB->PropertySets, sizeof(KSPROPERTY_SET) * AutomationTableB->PropertySetsCount);
2191  return STATUS_SUCCESS;
2192  }
2193  else if (!AutomationTableB)
2194  {
2195  /* copy of property set */
2196  RtlMoveMemory((PVOID)Table->PropertySets, AutomationTableA->PropertySets, sizeof(KSPROPERTY_SET) * AutomationTableA->PropertySetsCount);
2197  return STATUS_SUCCESS;
2198  }
2199 
2200  /* first copy all property items from dominant table */
2201  RtlMoveMemory((PVOID)Table->PropertySets, AutomationTableA->PropertySets, sizeof(KSPROPERTY_SET) * AutomationTableA->PropertySetsCount);
2202  /* set counter */
2203  Count = AutomationTableA->PropertySetsCount;
2204 
2205  /* now copy entries which aren't available in the dominant table */
2206  for(Index = 0; Index < AutomationTableB->PropertySetsCount; Index++)
2207  {
2208  /* set found to false */
2209  bFound = FALSE;
2210 
2211  for(SubIndex = 0; SubIndex < AutomationTableA->PropertySetsCount; SubIndex++)
2212  {
2213  if (IsEqualGUIDAligned(AutomationTableB->PropertySets[Index].Set, AutomationTableA->PropertySets[SubIndex].Set))
2214  {
2215  /* same property set found */
2216  bFound = TRUE;
2217  break;
2218  }
2219  }
2220 
2221  if (!bFound)
2222  {
2223  /* copy new property item set */
2224  RtlMoveMemory((PVOID)&Table->PropertySets[Count], &AutomationTableB->PropertySets[Index], sizeof(KSPROPERTY_SET));
2225  Count++;
2226  }
2227  else
2228  {
2229  // merge property sets
2230  Status = KspMergePropertySet(Table, (PKSPROPERTY_SET)&Table->PropertySets[SubIndex], (PKSPROPERTY_SET)&AutomationTableA->PropertySets[SubIndex], (PKSPROPERTY_SET)&AutomationTableB->PropertySets[Index], Bag);
2231  if (!NT_SUCCESS(Status))
2232  {
2233  // failed to merge
2234  DPRINT1("[KS] Failed to merge %x\n", Status);
2235  return Status;
2236  }
2237  }
2238  }
2239 
2240  return STATUS_SUCCESS;
2241 }
ASMGENDATA Table[]
Definition: genincdata.c:61
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
unsigned int BOOL
Definition: ntddk_ex.h:94
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
NTSTATUS KspMergePropertySet(OUT PKSAUTOMATION_TABLE Table, OUT PKSPROPERTY_SET OutPropertySet, IN PKSPROPERTY_SET PropertySetA, IN PKSPROPERTY_SET PropertySetB, IN KSOBJECT_BAG Bag OPTIONAL)
Definition: api.c:2120
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by KsMergeAutomationTables().

◆ KspCountEventSets()

ULONG KspCountEventSets ( IN PKSAUTOMATION_TABLE AutomationTableA  OPTIONAL,
IN PKSAUTOMATION_TABLE AutomationTableB  OPTIONAL 
)

Definition at line 1946 of file api.c.

1949 {
1950  ULONG Index, SubIndex, Count;
1951  BOOL bFound;
1952 
1953  if (!AutomationTableA)
1954  return AutomationTableB->EventSetsCount;
1955 
1956  if (!AutomationTableB)
1957  return AutomationTableA->EventSetsCount;
1958 
1959  DPRINT("AutomationTableA EventItemSize %lu EventSetsCount %lu\n", AutomationTableA->EventItemSize, AutomationTableA->EventSetsCount);
1960  DPRINT("AutomationTableB EventItemSize %lu EventSetsCount %lu\n", AutomationTableB->EventItemSize, AutomationTableB->EventSetsCount);
1961 
1962  if (AutomationTableA->EventItemSize && AutomationTableB->EventItemSize)
1963  {
1964  /* sanity check */
1965  ASSERT(AutomationTableA->EventItemSize == AutomationTableB->EventItemSize);
1966  }
1967 
1968  /* now iterate all Event sets and compare their guids */
1969  Count = AutomationTableA->EventSetsCount;
1970 
1971  for(Index = 0; Index < AutomationTableB->EventSetsCount; Index++)
1972  {
1973  /* set found to false */
1974  bFound = FALSE;
1975 
1976  for(SubIndex = 0; SubIndex < AutomationTableA->EventSetsCount; SubIndex++)
1977  {
1978  if (IsEqualGUIDAligned(AutomationTableB->EventSets[Index].Set, AutomationTableA->EventSets[SubIndex].Set))
1979  {
1980  /* same Event set found */
1981  bFound = TRUE;
1982  break;
1983  }
1984  }
1985 
1986  if (!bFound)
1987  Count++;
1988  }
1989 
1990  return Count;
1991 }
#define TRUE
Definition: types.h:120
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
unsigned int BOOL
Definition: ntddk_ex.h:94
void DPRINT(...)
Definition: polytest.cpp:61
static const UCHAR Index[8]
Definition: usbohci.c:18
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned int ULONG
Definition: retypes.h:1

Referenced by KsMergeAutomationTables().

◆ KspCountMethodSets()

ULONG KspCountMethodSets ( IN PKSAUTOMATION_TABLE AutomationTableA  OPTIONAL,
IN PKSAUTOMATION_TABLE AutomationTableB  OPTIONAL 
)

Definition at line 1897 of file api.c.

1900 {
1901  ULONG Index, SubIndex, Count;
1902  BOOL bFound;
1903 
1904  if (!AutomationTableA)
1905  return AutomationTableB->MethodSetsCount;
1906 
1907  if (!AutomationTableB)
1908  return AutomationTableA->MethodSetsCount;
1909 
1910 
1911  DPRINT("AutomationTableA MethodItemSize %lu MethodSetsCount %lu\n", AutomationTableA->MethodItemSize, AutomationTableA->MethodSetsCount);
1912  DPRINT("AutomationTableB MethodItemSize %lu MethodSetsCount %lu\n", AutomationTableB->MethodItemSize, AutomationTableB->MethodSetsCount);
1913 
1914  if (AutomationTableA->MethodItemSize && AutomationTableB->MethodItemSize)
1915  {
1916  /* sanity check */
1917  ASSERT(AutomationTableA->MethodItemSize == AutomationTableB->MethodItemSize);
1918  }
1919 
1920  /* now iterate all property sets and compare their guids */
1921  Count = AutomationTableA->MethodSetsCount;
1922 
1923  for(Index = 0; Index < AutomationTableB->MethodSetsCount; Index++)
1924  {
1925  /* set found to false */
1926  bFound = FALSE;
1927 
1928  for(SubIndex = 0; SubIndex < AutomationTableA->MethodSetsCount; SubIndex++)
1929  {
1930  if (IsEqualGUIDAligned(AutomationTableB->MethodSets[Index].Set, AutomationTableA->MethodSets[SubIndex].Set))
1931  {
1932  /* same property set found */
1933  bFound = TRUE;
1934  break;
1935  }
1936  }
1937 
1938  if (!bFound)
1939  Count++;
1940  }
1941 
1942  return Count;
1943 }
#define TRUE
Definition: types.h:120
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
unsigned int BOOL
Definition: ntddk_ex.h:94
void DPRINT(...)
Definition: polytest.cpp:61
static const UCHAR Index[8]
Definition: usbohci.c:18
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned int ULONG
Definition: retypes.h:1

Referenced by KsMergeAutomationTables().

◆ KspCountPropertySets()

ULONG KspCountPropertySets ( IN PKSAUTOMATION_TABLE AutomationTableA  OPTIONAL,
IN PKSAUTOMATION_TABLE AutomationTableB  OPTIONAL 
)

Definition at line 1995 of file api.c.

1998 {
1999  ULONG Index, SubIndex, Count;
2000  BOOL bFound;
2001 
2002  if (!AutomationTableA)
2003  return AutomationTableB->PropertySetsCount;
2004 
2005  if (!AutomationTableB)
2006  return AutomationTableA->PropertySetsCount;
2007 
2008  /* sanity check */
2009  DPRINT("AutomationTableA PropertyItemSize %lu PropertySetsCount %lu\n", AutomationTableA->PropertyItemSize, AutomationTableA->PropertySetsCount);
2010  DPRINT("AutomationTableB PropertyItemSize %lu PropertySetsCount %lu\n", AutomationTableB->PropertyItemSize, AutomationTableB->PropertySetsCount);
2011  ASSERT(AutomationTableA->PropertyItemSize == AutomationTableB->PropertyItemSize);
2012 
2013  /* now iterate all property sets and compare their guids */
2014  Count = AutomationTableA->PropertySetsCount;
2015 
2016  for(Index = 0; Index < AutomationTableB->PropertySetsCount; Index++)
2017  {
2018  /* set found to false */
2019  bFound = FALSE;
2020 
2021  for(SubIndex = 0; SubIndex < AutomationTableA->PropertySetsCount; SubIndex++)
2022  {
2023  if (IsEqualGUIDAligned(AutomationTableB->PropertySets[Index].Set, AutomationTableA->PropertySets[SubIndex].Set))
2024  {
2025  /* same property set found */
2026  bFound = TRUE;
2027  break;
2028  }
2029  }
2030 
2031  if (!bFound)
2032  Count++;
2033  }
2034 
2035  return Count;
2036 }
#define TRUE
Definition: types.h:120
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
unsigned int BOOL
Definition: ntddk_ex.h:94
void DPRINT(...)
Definition: polytest.cpp:61
static const UCHAR Index[8]
Definition: usbohci.c:18
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned int ULONG
Definition: retypes.h:1

Referenced by KsMergeAutomationTables().

◆ KspDeviceSetGetBusData()

NTSTATUS KspDeviceSetGetBusData ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  DataType,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length,
IN BOOL  bGet 
)

Definition at line 1743 of file api.c.

1750 {
1751  PIO_STACK_LOCATION IoStack;
1752  PIRP Irp;
1753  NTSTATUS Status;
1754  KEVENT Event;
1755 
1756  /* allocate the irp */
1757  Irp = IoAllocateIrp(1, /*FIXME */
1758  FALSE);
1759 
1760  if (!Irp)
1762 
1763  /* initialize the event */
1765 
1766  /* get next stack location */
1767  IoStack = IoGetNextIrpStackLocation(Irp);
1768 
1769  /* setup a completion routine */
1771 
1772  /* setup parameters */
1773  IoStack->Parameters.ReadWriteConfig.Buffer = Buffer;
1774  IoStack->Parameters.ReadWriteConfig.Length = Length;
1775  IoStack->Parameters.ReadWriteConfig.Offset = Offset;
1776  IoStack->Parameters.ReadWriteConfig.WhichSpace = DataType;
1777  /* setup function code */
1778  IoStack->MajorFunction = IRP_MJ_PNP;
1780 
1781  /* lets call the driver */
1783 
1784  /* is the request still pending */
1785  if (Status == STATUS_PENDING)
1786  {
1787  /* have a nap */
1789  /* update status */
1790  Status = Irp->IoStatus.Status;
1791  }
1792 
1793  /* free the irp */
1794  IoFreeIrp(Irp);
1795  /* done */
1796  return Status;
1797 }
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_WRITE_CONFIG
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
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:515
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
smooth NULL
Definition: ftsmooth.c:416
#define IRP_MN_READ_CONFIG
#define STATUS_PENDING
Definition: ntstatus.h:82
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
_In_ ULONG DataType
Definition: iotypes.h:787
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
NTSTATUS NTAPI KspSetGetBusDataCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: api.c:1729

Referenced by KsDeviceGetBusData(), and KsDeviceSetBusData().

◆ KspFreeCreateItems()

VOID KspFreeCreateItems ( PLIST_ENTRY  ListHead)

Definition at line 489 of file api.c.

491 {
493 
494  while(!IsListEmpty(ListHead))
495  {
496  /* remove create item from list */
498 
499  /* caller shouldnt have any references */
500  //ASSERT(Entry->ReferenceCount == 0);
501  //ASSERT(IsListEmpty(&Entry->ObjectItemList));
502 
503  /* does the creator wish notification */
504  if (Entry->ItemFreeCallback)
505  {
506  /* notify creator */
507  Entry->ItemFreeCallback(Entry->CreateItem);
508  }
509 
510  /* free create item entry */
511  FreeItem(Entry);
512  }
513 
514 }
struct _Entry Entry
Definition: kefuncs.h:640
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
Definition: kstypes.h:45
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
struct CREATE_ITEM_ENTRY * PCREATE_ITEM_ENTRY
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
base of all file and directory entries
Definition: entries.h:82

Referenced by KsAllocateDeviceHeader(), KsFreeDeviceHeader(), and KsFreeObjectHeader().

◆ KspMergePropertySet()

NTSTATUS KspMergePropertySet ( OUT PKSAUTOMATION_TABLE  Table,
OUT PKSPROPERTY_SET  OutPropertySet,
IN PKSPROPERTY_SET  PropertySetA,
IN PKSPROPERTY_SET  PropertySetB,
IN KSOBJECT_BAG Bag  OPTIONAL 
)

Definition at line 2120 of file api.c.

2126 {
2127  ULONG PropertyCount, Index;
2128  PKSPROPERTY_ITEM PropertyItem, CurrentPropertyItem;
2129  NTSTATUS Status;
2130 
2131  // max properties
2132  PropertyCount = PropertySetA->PropertiesCount + PropertySetB->PropertiesCount;
2133 
2134  // allocate items
2135  PropertyItem = AllocateItem(NonPagedPool, Table->PropertyItemSize * PropertyCount);
2136  if (!PropertyItem)
2138 
2139  if (Bag)
2140  {
2141  /* add table to object bag */
2143  /* check for success */
2144  if (!NT_SUCCESS(Status))
2145  {
2146  /* free table */
2147  FreeItem(Table);
2148  return Status;
2149  }
2150  }
2151 
2152  // copy entries from dominant table
2153  RtlCopyMemory(PropertyItem, PropertySetA->PropertyItem, Table->PropertyItemSize * PropertySetA->PropertiesCount);
2154 
2155  // init property set
2156  OutPropertySet->PropertiesCount = PropertySetA->PropertiesCount;
2157  OutPropertySet->PropertyItem = PropertyItem;
2158 
2159  // copy other entries
2160  CurrentPropertyItem = (PKSPROPERTY_ITEM)PropertySetB->PropertyItem;
2161  for(Index = 0; Index < PropertySetB->PropertiesCount; Index++)
2162  {
2163 
2164  // add entries
2165  KspAddPropertyItem(OutPropertySet, CurrentPropertyItem, Table->PropertyItemSize);
2166 
2167  // next entry
2168  CurrentPropertyItem = (PKSPROPERTY_ITEM)((ULONG_PTR)CurrentPropertyItem + Table->PropertyItemSize);
2169  }
2170 
2171  // done
2172  return STATUS_SUCCESS;
2173 }
VOID KspAddPropertyItem(OUT PKSPROPERTY_SET OutPropertySet, IN PKSPROPERTY_ITEM PropertyItem, IN ULONG PropertyItemSize)
Definition: api.c:2093
ASMGENDATA Table[]
Definition: genincdata.c:61
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS NTAPI KsAddItemToObjectBag(IN KSOBJECT_BAG ObjectBag, IN PVOID Item, IN PFNKSFREE Free OPTIONAL)
Definition: bag.c:86
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
uint32_t ULONG_PTR
Definition: typedefs.h:63
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
struct PropertyItem PropertyItem
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by KspCopyPropertySets().

◆ KspObjectFreeCreateItems()

NTSTATUS KspObjectFreeCreateItems ( IN KSDEVICE_HEADER  Header,
IN PKSOBJECT_CREATE_ITEM  CreateItem 
)

Definition at line 973 of file api.c.

976 {
978  return STATUS_NOT_IMPLEMENTED;
979 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by KsFreeObjectCreateItem(), and KsFreeObjectCreateItemsByContext().

◆ KspSetGetBusDataCompletion()

NTSTATUS NTAPI KspSetGetBusDataCompletion ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  Context 
)

Definition at line 1729 of file api.c.

1733 {
1734  /* signal completion */
1736 
1737  /* more work needs be done, so dont free the irp */
1739 
1740 }
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:63
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define IO_NO_INCREMENT
Definition: iotypes.h:565

Referenced by KspDeviceSetGetBusData().

◆ KspSynchronousIoControlDeviceCompletion()

NTSTATUS NTAPI KspSynchronousIoControlDeviceCompletion ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  Context 
)

Definition at line 1080 of file api.c.

1084 {
1086 
1087  IoStatusBlock->Information = Irp->IoStatus.Information;
1088  IoStatusBlock->Status = Irp->IoStatus.Status;
1089 
1090  return STATUS_SUCCESS;
1091 }
_In_ PIRP Irp
Definition: csq.h:116
struct _IO_STATUS_BLOCK * PIO_STATUS_BLOCK
Definition: change.c:34
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by KsSynchronousIoControlDevice().

◆ KsQueryDevicePnpObject()

KSDDKAPI PDEVICE_OBJECT NTAPI KsQueryDevicePnpObject ( IN KSDEVICE_HEADER  Header)

Definition at line 274 of file api.c.

276 {
278 
279  /* return PnpDeviceObject */
280  return DeviceHeader->PnpDeviceObject;
281 
282 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
PDEVICE_OBJECT PnpDeviceObject
Definition: kstypes.h:97
Definition: Header.h:8

◆ KsQueryObjectAccessMask()

KSDDKAPI ACCESS_MASK NTAPI KsQueryObjectAccessMask ( IN KSOBJECT_HEADER  Header)

Definition at line 290 of file api.c.

292 {
294 
295  /* return access mask */
296  return ObjectHeader->AccessMask;
297 
298 }
ACCESS_MASK AccessMask
Definition: kstypes.h:41
struct KSIOBJECT_HEADER * PKSIOBJECT_HEADER
Definition: Header.h:8

◆ KsQueryObjectCreateItem()

KSDDKAPI PKSOBJECT_CREATE_ITEM NTAPI KsQueryObjectCreateItem ( IN KSOBJECT_HEADER  Header)

Definition at line 450 of file api.c.

452 {
454  return ObjectHeader->OriginalCreateItem;
455 }
struct KSIOBJECT_HEADER * PKSIOBJECT_HEADER
Definition: Header.h:8
PKSOBJECT_CREATE_ITEM OriginalCreateItem
Definition: kstypes.h:40

◆ KsRecalculateStackDepth()

KSDDKAPI VOID NTAPI KsRecalculateStackDepth ( IN KSDEVICE_HEADER  Header,
IN BOOLEAN  ReuseStackLocation 
)

Definition at line 306 of file api.c.

309 {
311 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ KsRegisterAggregatedClientUnknown()

KSDDKAPI PUNKNOWN NTAPI KsRegisterAggregatedClientUnknown ( IN PVOID  Object,
IN PUNKNOWN  ClientUnknown 
)

Definition at line 2514 of file api.c.

2517 {
2518  PKSBASIC_HEADER BasicHeader = (PKSBASIC_HEADER)((ULONG_PTR)Object - sizeof(KSBASIC_HEADER));
2519 
2520  /* sanity check */
2521  ASSERT(BasicHeader->Type == KsObjectTypeDevice || BasicHeader->Type == KsObjectTypeFilterFactory ||
2522  BasicHeader->Type == KsObjectTypeFilter || BasicHeader->Type == KsObjectTypePin);
2523 
2524  if (BasicHeader->ClientAggregate)
2525  {
2526  /* release existing aggregate */
2527  BasicHeader->ClientAggregate->lpVtbl->Release(BasicHeader->ClientAggregate);
2528  }
2529 
2530  /* increment reference count */
2531  ClientUnknown->lpVtbl->AddRef(ClientUnknown);
2532 
2533  /* store client aggregate */
2534  BasicHeader->ClientAggregate = ClientUnknown;
2535 
2536  /* return objects outer unknown */
2537  return BasicHeader->OuterUnknown;
2538 }
struct KSBASIC_HEADER * PKSBASIC_HEADER
PUNKNOWN OuterUnknown
Definition: kstypes.h:62
uint32_t ULONG_PTR
Definition: typedefs.h:63
ULONG Release()
KSOBJECTTYPE Type
Definition: kstypes.h:56
PUNKNOWN ClientAggregate
Definition: kstypes.h:61
static IUnknown Object
Definition: main.c:512
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

◆ KsRegisterFilterWithNoKSPins()

NTSTATUS NTAPI KsRegisterFilterWithNoKSPins ( IN PDEVICE_OBJECT  DeviceObject,
IN const GUID InterfaceClassGUID,
IN ULONG  PinCount,
IN BOOL PinDirection,
IN KSPIN_MEDIUM MediumList,
IN GUID *CategoryList  OPTIONAL 
)

Definition at line 2545 of file api.c.

2552 {
2553  ULONG Size, Index;
2554  NTSTATUS Status;
2556  //PUCHAR Buffer;
2557  HANDLE hKey;
2558  UNICODE_STRING InterfaceString;
2559  //UNICODE_STRING FilterData = RTL_CONSTANT_STRING(L"FilterData");
2560 
2561  if (!InterfaceClassGUID || !PinCount || !PinDirection || !MediumList)
2562  {
2563  /* all these parameters are required */
2564  return STATUS_INVALID_PARAMETER;
2565  }
2566 
2567  /* calculate filter data value size */
2568  Size = PinCount * sizeof(KSPIN_MEDIUM);
2569  if (CategoryList)
2570  {
2571  /* add category list */
2572  Size += PinCount * sizeof(GUID);
2573  }
2574 
2575  /* FIXME generate filter data blob */
2576  UNIMPLEMENTED;
2577 
2578  /* get symbolic link list */
2580  if (NT_SUCCESS(Status))
2581  {
2582  /* initialize first symbolic link */
2583  RtlInitUnicodeString(&InterfaceString, SymbolicLinkList);
2584 
2585  /* open first device interface registry key */
2586  Status = IoOpenDeviceInterfaceRegistryKey(&InterfaceString, GENERIC_WRITE, &hKey);
2587 
2588  if (NT_SUCCESS(Status))
2589  {
2590  /* write filter data */
2591  //Status = ZwSetValueKey(hKey, &FilterData, 0, REG_BINARY, Buffer, Size);
2592 
2593  /* close the key */
2594  ZwClose(hKey);
2595  }
2596 
2597  if (PinCount)
2598  {
2599  /* update medium cache */
2600  for(Index = 0; Index < PinCount; Index++)
2601  {
2602  KsCacheMedium(&InterfaceString, &MediumList[Index], PinDirection[Index]);
2603  }
2604  }
2605 
2606  /* free the symbolic link list */
2608  }
2609 
2610  return Status;
2611 }
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList
NTSTATUS NTAPI IoOpenDeviceInterfaceRegistryKey(IN PUNICODE_STRING SymbolicLinkName, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DeviceInterfaceKey)
Definition: deviface.c:246
KSIDENTIFIER KSPIN_MEDIUM
Definition: ks.h:274
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
uint16_t * PWSTR
Definition: typedefs.h:54
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid, IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN ULONG Flags, OUT PWSTR *SymbolicLinkList)
Definition: deviface.c:459
_In_ const GUID _In_ ULONG PinCount
Definition: strmini.h:504
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
#define GENERIC_WRITE
Definition: nt_native.h:90
KSDDKAPI NTSTATUS NTAPI KsCacheMedium(IN PUNICODE_STRING SymbolicLink, IN PKSPIN_MEDIUM Medium, IN ULONG PinDirection)
Definition: api.c:1210
#define DEVICE_INTERFACE_INCLUDE_NONACTIVE
Definition: iofuncs.h:2808
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ const GUID * InterfaceClassGUID
Definition: strmini.h:504
static const UCHAR Index[8]
Definition: usbohci.c:18
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
struct _GUID GUID
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNIMPLEMENTED
Definition: debug.h:114

◆ KsReleaseControl()

VOID NTAPI KsReleaseControl ( IN PVOID  Object)

Definition at line 1604 of file api.c.

1606 {
1607  PKSBASIC_HEADER BasicHeader = (PKSBASIC_HEADER)((ULONG_PTR)Object - sizeof(KSBASIC_HEADER));
1608 
1609  /* sanity check */
1610  ASSERT(BasicHeader->Type == KsObjectTypeFilter || BasicHeader->Type == KsObjectTypePin);
1611 
1612  KeReleaseMutex(BasicHeader->ControlMutex, FALSE);
1613 }
struct KSBASIC_HEADER * PKSBASIC_HEADER
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
Definition: mutex.c:189
uint32_t ULONG_PTR
Definition: typedefs.h:63
PRKMUTEX ControlMutex
Definition: kstypes.h:58
KSOBJECTTYPE Type
Definition: kstypes.h:56
static IUnknown Object
Definition: main.c:512
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

Referenced by IKsPin_DispatchCreateClock().

◆ KsReleaseDevice()

VOID NTAPI KsReleaseDevice ( IN PKSDEVICE  Device)

Definition at line 1644 of file api.c.

1646 {
1647  IKsDevice *KsDevice;
1649 
1650  /* get device interface*/
1651  KsDevice = (IKsDevice*)&DeviceHeader->BasicHeader.OuterUnknown;
1652 
1653  /* release device mutex */
1654  KsDevice->lpVtbl->ReleaseDevice(KsDevice);
1655 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
PUNKNOWN OuterUnknown
Definition: kstypes.h:62
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
KSBASIC_HEADER BasicHeader
Definition: kstypes.h:87

◆ KsReleaseDeviceSecurityLock()

KSDDKAPI VOID NTAPI KsReleaseDeviceSecurityLock ( IN KSDEVICE_HEADER  DevHeader)

Definition at line 93 of file api.c.

95 {
97 
98  DPRINT("KsReleaseDevice\n");
99 
100  ExReleaseResourceLite(&Header->SecurityLock);
102 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
Definition: Header.h:8
void DPRINT(...)
Definition: polytest.cpp:61
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114

Referenced by KsSetPowerDispatch(), and KsSetTargetDeviceObject().

◆ KsSetDevicePnpAndBaseObject()

KSDDKAPI VOID NTAPI KsSetDevicePnpAndBaseObject ( IN KSDEVICE_HEADER  Header,
IN PDEVICE_OBJECT  PnpDeviceObject,
IN PDEVICE_OBJECT  BaseDevice 
)

Definition at line 257 of file api.c.

261 {
263 
264  DeviceHeader->PnpDeviceObject = PnpDeviceObject;
265  DeviceHeader->BaseDevice = BaseDevice;
266 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
PDEVICE_OBJECT PnpDeviceObject
Definition: kstypes.h:97
Definition: Header.h:8
PDEVICE_OBJECT BaseDevice
Definition: kstypes.h:98

Referenced by KMix_AddDevice(), KopAddDevice(), KsInitializeDevice(), SysAudio_AddDevice(), and WdmaudAddDevice().

◆ KsSetPowerDispatch()

KSDDKAPI VOID NTAPI KsSetPowerDispatch ( IN KSOBJECT_HEADER  Header,
IN PFNKSCONTEXT_DISPATCH PowerDispatch  OPTIONAL,
IN PVOID PowerContext  OPTIONAL 
)

Definition at line 401 of file api.c.

405 {
406  PDEVICE_EXTENSION DeviceExtension;
407  PKSIDEVICE_HEADER DeviceHeader;
409 
410  /* caller wants to add the target device */
411  DeviceExtension = (PDEVICE_EXTENSION)ObjectHeader->ParentDeviceObject->DeviceExtension;
412 
413  /* get device header */
414  DeviceHeader = (PKSIDEVICE_HEADER)DeviceExtension->DeviceHeader;
415 
416  /* acquire lock */
418 
419  if (PowerDispatch)
420  {
421  /* add power dispatch entry */
422  InsertTailList(&DeviceHeader->PowerDispatchList, &ObjectHeader->PowerDispatchEntry);
423 
424  /* store function and context */
425  ObjectHeader->PowerDispatch = PowerDispatch;
426  ObjectHeader->PowerContext = PowerContext;
427  }
428  else
429  {
430  /* remove power dispatch entry */
431  RemoveEntryList(&ObjectHeader->PowerDispatchEntry);
432 
433  /* store function and context */
434  ObjectHeader->PowerDispatch = NULL;
435  ObjectHeader->PowerContext = NULL;
436 
437  }
438 
439  /* release lock */
441 }
struct KSIOBJECT_HEADER * PKSIOBJECT_HEADER
PVOID PowerContext
Definition: kstypes.h:38
#define InsertTailList(ListHead, Entry)
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
Definition: Header.h:8
PFNKSCONTEXT_DISPATCH PowerDispatch
Definition: kstypes.h:37
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
KSDDKAPI VOID NTAPI KsReleaseDeviceSecurityLock(IN KSDEVICE_HEADER DevHeader)
Definition: api.c:93
PDEVICE_OBJECT ParentDeviceObject
Definition: kstypes.h:35
KSDDKAPI VOID NTAPI KsAcquireDeviceSecurityLock(IN KSDEVICE_HEADER DevHeader, IN BOOLEAN Exclusive)
Definition: api.c:69
LIST_ENTRY PowerDispatchList
Definition: kstypes.h:106
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION
LIST_ENTRY PowerDispatchEntry
Definition: kstypes.h:39

◆ KsSetTargetDeviceObject()

KSDDKAPI VOID NTAPI KsSetTargetDeviceObject ( IN KSOBJECT_HEADER  Header,
IN PDEVICE_OBJECT TargetDevice  OPTIONAL 
)

Definition at line 336 of file api.c.

339 {
340  PDEVICE_EXTENSION DeviceExtension;
341  PKSIDEVICE_HEADER DeviceHeader;
343 
344  if(ObjectHeader->TargetDevice)
345  {
346  /* there is already a target device set */
347  if (!TargetDevice)
348  {
349  /* caller wants to remove the target device */
350  DeviceExtension = (PDEVICE_EXTENSION)ObjectHeader->TargetDevice->DeviceExtension;
351 
352  /* get device header */
353  DeviceHeader = (PKSIDEVICE_HEADER)DeviceExtension->DeviceHeader;
354 
355  /* acquire lock */
357 
358  /* remove entry */
359  RemoveEntryList(&ObjectHeader->TargetDeviceListEntry);
360 
361  /* remove device pointer */
362  ObjectHeader->TargetDevice = NULL;
363 
364  /* release lock */
366  }
367  }
368  else
369  {
370  /* no target device yet set */
371  if (TargetDevice)
372  {
373  /* caller wants to add the target device */
374  DeviceExtension = (PDEVICE_EXTENSION)TargetDevice->DeviceExtension;
375 
376  /* get device header */
377  DeviceHeader = (PKSIDEVICE_HEADER)DeviceExtension->DeviceHeader;
378 
379  /* acquire lock */
381 
382  /* insert list entry */
383  InsertTailList(&DeviceHeader->TargetDeviceList, &ObjectHeader->TargetDeviceListEntry);
384 
385  /* store target device */
386  ObjectHeader->TargetDevice = TargetDevice;
387 
388  /* release lock */
390  }
391  }
392 
393 }
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT _In_ PDEVICE_OBJECT TargetDevice
Definition: iofuncs.h:688
struct KSIOBJECT_HEADER * PKSIOBJECT_HEADER
#define InsertTailList(ListHead, Entry)
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
Definition: Header.h:8
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
KSDDKAPI VOID NTAPI KsReleaseDeviceSecurityLock(IN KSDEVICE_HEADER DevHeader)
Definition: api.c:93
KSDDKAPI VOID NTAPI KsAcquireDeviceSecurityLock(IN KSDEVICE_HEADER DevHeader, IN BOOLEAN Exclusive)
Definition: api.c:69
LIST_ENTRY TargetDeviceListEntry
Definition: kstypes.h:33
PDEVICE_OBJECT TargetDevice
Definition: kstypes.h:32
LIST_ENTRY TargetDeviceList
Definition: kstypes.h:101
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION

◆ KsSetTargetState()

KSDDKAPI VOID NTAPI KsSetTargetState ( IN KSOBJECT_HEADER  Header,
IN KSTARGET_STATE  TargetState 
)

Definition at line 320 of file api.c.

323 {
325 
326  /* set target state */
327  DeviceHeader->TargetState = TargetState;
328 }
struct KSIDEVICE_HEADER * PKSIDEVICE_HEADER
Definition: Header.h:8
KSTARGET_STATE TargetState
Definition: kstypes.h:100

◆ KsSynchronousIoControlDevice()

KSDDKAPI NTSTATUS NTAPI KsSynchronousIoControlDevice ( IN PFILE_OBJECT  FileObject,
IN KPROCESSOR_MODE  RequestorMode,
IN ULONG  IoControl,
IN PVOID  InBuffer,
IN ULONG  InSize,
OUT PVOID  OutBuffer,
IN ULONG  OutSize,
OUT PULONG  BytesReturned 
)

Definition at line 1099 of file api.c.

1108 {
1109  PKSIOBJECT_HEADER ObjectHeader;
1111  KEVENT Event;
1112  PIRP Irp;
1114  PIO_STACK_LOCATION IoStack;
1115  NTSTATUS Status;
1116 
1117  /* check for valid file object */
1118  if (!FileObject)
1119  return STATUS_INVALID_PARAMETER;
1120 
1121  /* get device object to send the request to */
1123  if (!DeviceObject)
1124  return STATUS_UNSUCCESSFUL;
1125 
1126 
1127  /* get object header */
1128  ObjectHeader = (PKSIOBJECT_HEADER)FileObject->FsContext2;
1129 
1130  /* check if there is fast device io function */
1131  if (ObjectHeader && ObjectHeader->DispatchTable.FastDeviceIoControl)
1132  {
1135 
1136  /* send the request */
1137  Status = ObjectHeader->DispatchTable.FastDeviceIoControl(FileObject, TRUE, InBuffer, InSize, OutBuffer, OutSize, IoControl, &IoStatusBlock, DeviceObject);
1138  /* check if the request was handled */
1139  //DPRINT("Handled %u Status %x Length %u\n", Status, IoStatusBlock.Status, IoStatusBlock.Information);
1140  if (Status)
1141  {
1142  /* store bytes returned */
1144  /* return status */
1145  return IoStatusBlock.Status;
1146  }
1147  }
1148 
1149  /* initialize the event */
1151 
1152  /* create the irp */
1153  Irp = IoBuildDeviceIoControlRequest(IoControl, DeviceObject, InBuffer, InSize, OutBuffer, OutSize, FALSE, &Event, &IoStatusBlock);
1154 
1155  if (!Irp)
1156  {
1157  /* no memory to allocate the irp */
1159  }
1160 
1161 
1162  /* Store Fileobject */
1163  IoStack = IoGetNextIrpStackLocation(Irp);
1164  IoStack->FileObject = FileObject;
1165 
1166  if (IoControl == IOCTL_KS_WRITE_STREAM)
1167  {
1168  Irp->AssociatedIrp.SystemBuffer = OutBuffer;
1169  }
1170  else if (IoControl == IOCTL_KS_READ_STREAM)
1171  {
1172  Irp->AssociatedIrp.SystemBuffer = InBuffer;
1173  }
1174 
1176 
1178  if (Status == STATUS_PENDING)
1179  {
1180  KeWaitForSingleObject(&Event, Executive, RequestorMode, FALSE, NULL);
1182  }
1183 
1185  return Status;
1186 }
#define IOCTL_KS_WRITE_STREAM
Definition: ks.h:157
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define IOCTL_KS_READ_STREAM
Definition: ks.h:164
struct KSIOBJECT_HEADER * PKSIOBJECT_HEADER
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1538
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
NTSTATUS NTAPI KspSynchronousIoControlDeviceCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: api.c:1080
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define STATUS_PENDING
Definition: ntstatus.h:82
KSDISPATCH_TABLE DispatchTable
Definition: kstypes.h:22
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
_In_ FILTER_INFORMATION_CLASS _In_ ULONG _Out_ PULONG BytesReturned
Definition: fltkernel.h:1716
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
unsigned int ULONG
Definition: retypes.h:1

Referenced by AudioPositionPropertyHandler(), ComputeCompatibleFormat(), Control(), CreatePinCallback(), GetPinInstanceCount(), GetSysAudioDeviceCount(), GetSysAudioDevicePnpName(), HandleSysAudioFilterPinProperties(), IKsControl_fnKsEvent(), IKsControl_fnKsMethod(), IKsControl_fnKsProperty(), IKsPin_PinMasterClock(), IKsReferenceClock_fnGetResolution(), IKsReferenceClock_fnGetState(), Pin_fnDeviceIoControl(), SetMixerInputOutputFormat(), SysAudioHandleProperty(), WdmAudControlDeviceState(), WdmAudFrameSize(), and WdmAudResetStream().

◆ KsTerminateDevice()

KSDDKAPI VOID NTAPI KsTerminateDevice ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 1663 of file api.c.

1665 {
1666  IKsDevice *KsDevice;
1667  PKSIDEVICE_HEADER DeviceHeader;
1669 
1670  /* get device header */
1671  DeviceHeader = DeviceExtension->DeviceHeader;
1672 
1673  /* get device interface*/
1674  KsDevice = (IKsDevice*)&DeviceHeader->BasicHeader.OuterUnknown;
1675 
1676  /* now free device header */
1677  KsFreeDeviceHeader((KSDEVICE_HEADER)DeviceHeader);
1678 
1679  /* release interface when available */
1680  if (KsDevice)
1681  {
1682  /* delete IKsDevice interface */
1683  KsDevice->lpVtbl->Release(KsDevice);
1684  }
1685 }
PUNKNOWN OuterUnknown
Definition: kstypes.h:62
PVOID DeviceExtension
Definition: env_spec_w32.h:418
KSBASIC_HEADER BasicHeader
Definition: kstypes.h:87
KSDDKAPI VOID NTAPI KsFreeDeviceHeader(IN KSDEVICE_HEADER DevHeader)
Definition: api.c:590
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
struct _BEEP_DEVICE_EXTENSION * PDEVICE_EXTENSION

◆ KsUnserializeObjectPropertiesFromRegistry()

KSDDKAPI NTSTATUS NTAPI KsUnserializeObjectPropertiesFromRegistry ( IN PFILE_OBJECT  FileObject,
IN HANDLE ParentKey  OPTIONAL,
IN PUNICODE_STRING RegistryPath  OPTIONAL 
)

Definition at line 1194 of file api.c.

1198 {
1199  UNIMPLEMENTED;
1200  return STATUS_NOT_IMPLEMENTED;
1201 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define UNIMPLEMENTED
Definition: debug.h:114

Variable Documentation

◆ GUID_NULL

const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}

Definition at line 14 of file api.c.

Referenced by KsCacheMedium().

◆ KoDispatchTable

KSDISPATCH_TABLE KoDispatchTable
static
Initial value:
=
{
}
KSDDKAPI NTSTATUS NTAPI KsDispatchSetSecurity(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:67
KSDDKAPI NTSTATUS NTAPI KsDispatchQuerySecurity(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:22
KSDDKAPI BOOLEAN NTAPI KsDispatchFastIoDeviceControlFailure(IN PFILE_OBJECT FileObject, IN BOOLEAN Wait, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength, IN ULONG IoControlCode, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: irp.c:1218
KSDDKAPI NTSTATUS NTAPI KsDispatchInvalidDeviceRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1156
KSDDKAPI BOOLEAN NTAPI KsDispatchFastReadFailure(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: irp.c:1238
NTSTATUS NTAPI KopDispatchClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: api.c:1308

Definition at line 1343 of file api.c.

Referenced by KopDispatchCreate().

◆ KSMEDIUMSETID_Standard

const GUID KSMEDIUMSETID_Standard = {0x4747B320L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}

Definition at line 15 of file api.c.

Referenced by KsCacheMedium().