Author: janderwald
Date: Mon Jan 26 04:05:46 2009
New Revision: 39104
URL:
http://svn.reactos.org/svn/reactos?rev=39104&view=rev
Log:
- Start implementing object bag support functions
- Implement KsCreateDevice, KsAddDevice, KsInitializeDriver
- Add KsDefaultForwardIrp stub
Added:
trunk/reactos/drivers/ksfilter/ks/bag.c (with props)
trunk/reactos/drivers/ksfilter/ks/device.c (with props)
trunk/reactos/drivers/ksfilter/ks/driver.c (with props)
trunk/reactos/drivers/ksfilter/ks/ksfunc.h (with props)
trunk/reactos/drivers/ksfilter/ks/ksiface.h (with props)
Modified:
trunk/reactos/drivers/ksfilter/ks/clocks.c
trunk/reactos/drivers/ksfilter/ks/irp.c
trunk/reactos/drivers/ksfilter/ks/ks.rbuild
trunk/reactos/drivers/ksfilter/ks/ks.spec
trunk/reactos/drivers/ksfilter/ks/misc.c
Added: trunk/reactos/drivers/ksfilter/ks/bag.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/bag.c?…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/bag.c (added)
+++ trunk/reactos/drivers/ksfilter/ks/bag.c [iso-8859-1] Mon Jan 26 04:05:46 2009
@@ -1,0 +1,58 @@
+#include <ntddk.h>
+#include <debug.h>
+#include <ks.h>
+#if 0
+typedef struct
+{
+ LIST_ENTRY Entry;
+ PVOID Item;
+ PFNKSFREE Free;
+ LONG ReferenceCount;
+}KSOBJECT_BAG_ENTRY;
+
+typedef struct
+{
+ LIST_ENTRY ListHead;
+ KMUTEX Lock;
+}KSOBJECT_BAG_IMPL;
+
+/*
+ @implemented
+*/
+KSDDKAPI
+NTSTATUS
+NTAPI
+KsAddItemToObjectBag(
+ IN KSOBJECT_BAG ObjectBag,
+ IN PVOID Item,
+ IN PFNKSFREE Free OPTIONAL)
+{
+ KSOBJECT_BAG_ENTRY * Entry;
+ KSOBJECT_BAG_IMPL * Bag = (KSOBJECT_BAG_IMPL)ObjectBag;
+
+ Entry = ExAllocatePool(NonPagedPool, sizeof(KSOBJECT_BAG_ENTRY));
+ if (!Entry)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ Entry->Free = Free;
+ Entry->Item = Item;
+
+ InsertTailList(&Bag->ListHead, &Entry->Entry);
+ return STATUS_SUCCESS;
+}
+
+KSDDKAPI
+ULONG
+NTAPI
+KsRemoveItemFromObjectBag(
+ IN KSOBJECT_BAG ObjectBag,
+ IN PVOID Item,
+ IN BOOLEAN Free)
+{
+ KSOBJECT_BAG_IMPL * Bag = (KSOBJECT_BAG_IMPL)ObjectBag;
+
+
+
+
+}
+#endif
Propchange: trunk/reactos/drivers/ksfilter/ks/bag.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/drivers/ksfilter/ks/clocks.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/clocks…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/clocks.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/clocks.c [iso-8859-1] Mon Jan 26 04:05:46 2009
@@ -5,6 +5,11 @@
#include <ntddk.h>
#include <debug.h>
#include <ks.h>
+
+typedef struct
+{
+
+}KS_DEFAULT_CLOCK;
/*
@unimplemented
@@ -27,19 +32,28 @@
IN PIRP Irp,
IN PKSDEFAULTCLOCK DefaultClock)
{
- UNIMPLEMENTED;
+ NTSTATUS Status;
+ PKSCLOCK_CREATE ClockCreate;
+
+ Status = KsValidateClockCreateRequest(Irp, &ClockCreate);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+// ExAllocatePoolWithTag(NonPagedPool, sizeof(KS_DEFAULT_CLOCK), 0);
+
+
+
return STATUS_UNSUCCESSFUL;
}
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI NTSTATUS NTAPI
KsAllocateDefaultClock(
OUT PKSDEFAULTCLOCK* DefaultClock)
{
- UNIMPLEMENTED;
- return STATUS_UNSUCCESSFUL;
+ return KsAllocateDefaultClockEx(DefaultClock, NULL, NULL, NULL, NULL, NULL, 0);
}
/*
Added: trunk/reactos/drivers/ksfilter/ks/device.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/device…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/device.c (added)
+++ trunk/reactos/drivers/ksfilter/ks/device.c [iso-8859-1] Mon Jan 26 04:05:46 2009
@@ -1,0 +1,34 @@
+#include <ntddk.h>
+#include <debug.h>
+#include <ks.h>
+
+#include "ksiface.h"
+#include "ksfunc.h"
+
+typedef struct
+{
+ IKsDeviceVtbl *lpVtbl;
+
+ LONG ref;
+
+
+}IKsDeviceImpl;
+
+
+NTSTATUS
+NTAPI
+NewIKsDevice(IKsDevice** OutDevice)
+{
+ IKsDeviceImpl * This;
+
+ This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IKsDeviceImpl), 0x12345678); //FIX
TAG
+ if (!This)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ This->ref = 1;
+ //This->lpVtbl = &vt_IKsDevice;
+
+ *OutDevice = (IKsDevice*)This;
+ return STATUS_SUCCESS;
+}
+
Propchange: trunk/reactos/drivers/ksfilter/ks/device.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/drivers/ksfilter/ks/driver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/driver…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/driver.c (added)
+++ trunk/reactos/drivers/ksfilter/ks/driver.c [iso-8859-1] Mon Jan 26 04:05:46 2009
@@ -1,0 +1,143 @@
+#include <ntddk.h>
+#include <debug.h>
+#include <ks.h>
+
+#include "ksfunc.h"
+
+
+/*
+ @unimplemented
+*/
+KSDDKAPI
+PKSDEVICE
+NTAPI
+KsGetDeviceForDeviceObject(
+ IN PDEVICE_OBJECT FunctionalDeviceObject)
+{
+
+ return NULL;
+}
+
+/*
+ @unimplemented
+*/
+KSDDKAPI
+NTSTATUS
+NTAPI
+KsInitializeDevice(
+ IN PDEVICE_OBJECT FunctionalDeviceObject,
+ IN PDEVICE_OBJECT PhysicalDeviceObject,
+ IN PDEVICE_OBJECT NextDeviceObject,
+ IN const KSDEVICE_DESCRIPTOR* Descriptor OPTIONAL)
+{
+ return STATUS_UNSUCCESSFUL;
+}
+
+/*
+ @implemented
+*/
+KSDDKAPI
+NTSTATUS
+NTAPI
+KsCreateDevice(
+ IN PDRIVER_OBJECT DriverObject,
+ IN PDEVICE_OBJECT PhysicalDeviceObject,
+ IN const KSDEVICE_DESCRIPTOR* Descriptor OPTIONAL,
+ IN ULONG ExtensionSize OPTIONAL,
+ OUT PKSDEVICE* Device OPTIONAL)
+{
+ NTSTATUS Status = STATUS_DEVICE_REMOVED;
+ PDEVICE_OBJECT FunctionalDeviceObject= NULL;
+ PDEVICE_OBJECT OldHighestDeviceObject;
+
+ if (!ExtensionSize)
+ ExtensionSize = sizeof(PVOID);
+
+ Status = IoCreateDevice(DriverObject, ExtensionSize, NULL, FILE_DEVICE_KS,
FILE_DEVICE_SECURE_OPEN, FALSE, &FunctionalDeviceObject);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ OldHighestDeviceObject = IoAttachDeviceToDeviceStack(FunctionalDeviceObject,
PhysicalDeviceObject);
+ if (OldHighestDeviceObject)
+ {
+ Status = KsInitializeDevice(FunctionalDeviceObject, PhysicalDeviceObject,
OldHighestDeviceObject, Descriptor);
+ }
+
+ if (!NT_SUCCESS(Status))
+ {
+ if (OldHighestDeviceObject)
+ IoDetachDevice(OldHighestDeviceObject);
+
+ IoDeleteDevice(FunctionalDeviceObject);
+ return Status;
+ }
+
+ if (Device)
+ {
+ *Device = KsGetDeviceForDeviceObject(FunctionalDeviceObject);
+ }
+
+ return Status;
+}
+
+/*
+ @implemented
+*/
+KSDDKAPI
+NTSTATUS
+NTAPI
+KsAddDevice(
+ IN PDRIVER_OBJECT DriverObject,
+ IN PDEVICE_OBJECT PhysicalDeviceObject)
+{
+ PKSDEVICE_DESCRIPTOR *DriverObjectExtension;
+ PKSDEVICE_DESCRIPTOR Descriptor = NULL;
+
+ DriverObjectExtension = IoGetDriverObjectExtension(DriverObject,
(PVOID)KsAddDevice);
+ if (DriverObjectExtension)
+ {
+ Descriptor = *DriverObjectExtension;
+ }
+
+ return KsCreateDevice(DriverObject, PhysicalDeviceObject, Descriptor, 0, NULL);
+}
+
+/*
+ @implemented
+*/
+KSDDKAPI
+NTSTATUS
+NTAPI
+KsInitializeDriver(
+ IN PDRIVER_OBJECT DriverObject,
+ IN PUNICODE_STRING RegistryPath,
+ IN const KSDEVICE_DESCRIPTOR *Descriptor OPTIONAL
+)
+{
+ PKSDEVICE_DESCRIPTOR *DriverObjectExtension;
+ NTSTATUS Status;
+
+ if (Descriptor)
+ {
+ Status = IoAllocateDriverObjectExtension(DriverObject, (PVOID)KsAddDevice,
sizeof(PKSDEVICE_DESCRIPTOR), (PVOID*)&DriverObjectExtension);
+ if (NT_SUCCESS(Status))
+ {
+ *DriverObjectExtension = (KSDEVICE_DESCRIPTOR*)Descriptor;
+ }
+ }
+ /* Setting our IRP handlers */
+ //DriverObject->MajorFunction[IRP_MJ_CREATE] = KspDispatch;
+ //DriverObject->MajorFunction[IRP_MJ_PNP] = KspDispatch;
+ //DriverObject->MajorFunction[IRP_MJ_POWER] = KspDispatch;
+
+ /* The driver-supplied AddDevice */
+ DriverObject->DriverExtension->AddDevice = KsAddDevice;
+
+ /* KS handles these */
+ DPRINT1("Setting KS function handlers\n");
+ KsSetMajorFunctionHandler(DriverObject, IRP_MJ_CLOSE);
+ KsSetMajorFunctionHandler(DriverObject, IRP_MJ_DEVICE_CONTROL);
+
+
+ return STATUS_SUCCESS;
+}
Propchange: trunk/reactos/drivers/ksfilter/ks/driver.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/drivers/ksfilter/ks/irp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/irp.c?…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/irp.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/irp.c [iso-8859-1] Mon Jan 26 04:05:46 2009
@@ -678,3 +678,16 @@
UNIMPLEMENTED;
return STATUS_UNSUCCESSFUL;
}
+
+/*
+ @unimplemented
+*/
+KSDDKAPI NTSTATUS NTAPI
+KsDefaultForwardIrp(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ UNIMPLEMENTED;
+ return STATUS_UNSUCCESSFUL;
+}
+
Modified: trunk/reactos/drivers/ksfilter/ks/ks.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/ks.rbu…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/ks.rbuild [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/ks.rbuild [iso-8859-1] Mon Jan 26 04:05:46 2009
@@ -12,6 +12,9 @@
<define name="_COMDDK_" />
<file>ks.rc</file>
<file>allocators.c</file>
+ <file>bag.c</file>
+ <file>device.c</file>
+ <file>driver.c</file>
<file>clocks.c</file>
<file>connectivity.c</file>
<file>events.c</file>
Modified: trunk/reactos/drivers/ksfilter/ks/ks.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/ks.spe…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/ks.spec [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/ks.spec [iso-8859-1] Mon Jan 26 04:05:46 2009
@@ -44,6 +44,7 @@
@ stdcall KsHandleSizedListQuery(ptr long long ptr)
@ stdcall KsAcquireResetValue(ptr ptr)
+@ stdcall KsDefaultForwardIrp(ptr ptr)
@ stdcall KsAddIrpToCancelableQueue(ptr ptr ptr long ptr)
@ stdcall KsAddObjectCreateItemToDeviceHeader(ptr ptr ptr wstr ptr)
@ stdcall KsAddObjectCreateItemToObjectHeader(ptr ptr ptr wstr ptr)
Added: trunk/reactos/drivers/ksfilter/ks/ksfunc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/ksfunc…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/ksfunc.h (added)
+++ trunk/reactos/drivers/ksfilter/ks/ksfunc.h [iso-8859-1] Mon Jan 26 04:05:46 2009
@@ -1,0 +1,17 @@
+#ifndef KSFUNC_H__
+#define KSFUNC_H__
+
+#include "ksiface.h"
+
+NTSTATUS
+NTAPI
+NewIKsDevice(IKsDevice** OutDevice);
+
+
+
+
+
+
+
+
+#endif
Propchange: trunk/reactos/drivers/ksfilter/ks/ksfunc.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/drivers/ksfilter/ks/ksiface.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/ksifac…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/ksiface.h (added)
+++ trunk/reactos/drivers/ksfilter/ks/ksiface.h [iso-8859-1] Mon Jan 26 04:05:46 2009
@@ -1,0 +1,101 @@
+#ifndef KSIFACE_H__
+#define KSIFACE_H__
+
+#include <ntddk.h>
+#include <ks.h>
+
+
+
+/*****************************************************************************
+ * IKsFilterFactory
+ *****************************************************************************
+ */
+
+#undef INTERFACE
+#define INTERFACE IKsFilterFactory
+
+struct KSFILTERFACTORY;
+
+DECLARE_INTERFACE_(IKsFilterFactory, IUnknown)
+{
+ //DEFINE_ABSTRACT_UNKNOWN()
+
+ STDMETHOD_(struct KSFILTERFACTORY*,GetStruct)(THIS) PURE;
+
+ STDMETHOD_(NTSTATUS,SetDeviceClassesState)(THIS_
+ IN ULONG Unknown1,
+ IN BOOLEAN Enable)PURE;
+};
+
+
+/*****************************************************************************
+ * IKsPowerNotify
+ *****************************************************************************
+ */
+
+#undef INTERFACE
+#define INTERFACE IKsPowerNotify
+
+DECLARE_INTERFACE_(IKsPowerNotify, IUnknown)
+{
+ //DEFINE_ABSTRACT_UNKNOWN()
+
+ STDMETHOD_(ULONG,Sleep)(THIS_
+ IN DEVICE_POWER_STATE State) PURE;
+
+ STDMETHOD_(ULONG,Wake)(THIS) PURE;
+};
+
+
+/*****************************************************************************
+ * IKsDevice
+ *****************************************************************************
+ */
+
+#undef INTERFACE
+#define INTERFACE IKsDevice
+
+struct KSIOBJECTBAG;
+struct KSPOWER_ENTRY;
+
+DECLARE_INTERFACE_(IKsDevice, IUnknown)
+{
+ //DEFINE_ABSTRACT_UNKNOWN()
+
+ STDMETHOD_(struct KSDEVICE*,GetStruct)(THIS) PURE;
+
+ STDMETHOD_(NTSTATUS, InitializeObjectBag)(THIS_
+ IN struct KSIOBJECTBAG *Bag,
+ IN KMUTANT * Mutant) PURE;
+
+ STDMETHOD_(ULONG,AcquireDevice)(THIS) PURE;
+ STDMETHOD_(ULONG,ReleaseDevice)(THIS) PURE;
+
+ STDMETHOD_(VOID, GetAdapterObject)(THIS_
+ IN PADAPTER_OBJECT Object,
+ IN PULONG Unknown1,
+ IN PULONG Unknown2) PURE;
+
+ STDMETHOD_(VOID, AddPowerEntry)(THIS_
+ IN struct KSPOWER_ENTRY * Entry,
+ IN struct IKsPowerNotify* Notify)PURE;
+
+ STDMETHOD_(VOID, RemovePowerEntry)(THIS_
+ IN struct KSPOWER_ENTRY * Entry)PURE;
+
+ STDMETHOD_(NTSTATUS, PinStateChange)(THIS_
+ IN KSPIN Pin,
+ IN PIRP Irp,
+ IN KSSTATE OldState,
+ IN KSSTATE NewState)PURE;
+
+ STDMETHOD_(NTSTATUS, ArbitrateAdapterChannel)(THIS_
+ IN ULONG ControlCode,
+ IN IO_ALLOCATION_ACTION Action,
+ IN PVOID Context)PURE;
+
+ STDMETHOD_(NTSTATUS, CheckIoCapability)(THIS_
+ IN ULONG Unknown)PURE;
+};
+
+#endif
Propchange: trunk/reactos/drivers/ksfilter/ks/ksiface.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/drivers/ksfilter/ks/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/misc.c…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/misc.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/misc.c [iso-8859-1] Mon Jan 26 04:05:46 2009
@@ -218,17 +218,5 @@
return STATUS_UNSUCCESSFUL;
}
-/*
- @unimplemented
-*/
-KSDDKAPI NTSTATUS NTAPI
-KsInitializeDriver(
- IN PDRIVER_OBJECT DriverObject,
- IN PUNICODE_STRING RegistryPath,
- IN const KSDEVICE_DESCRIPTOR *Descriptor OPTIONAL
-)
-{
- UNIMPLEMENTED;
- return STATUS_UNSUCCESSFUL;
-}
-
+
+