- Check for valid DeviceExtensionSize

- Pass correct flags when creating the fdo
- set DO_DIRECT_IO flag
- clear DO_DEVICE_INITIALIZING flag
- Move all calls to ExAllocatePoolWithTag to a function AllocateItem which is also responsible for zeroing memory
- Fix ISubDevice GUID
- don't disconnect the interrupt on cleanup, IInterruptSync_fnDisconnect exist for that purpose
- If there is no interrupt yet connected, call the synchronized routine holding the internal spinlock
- Copy the current stack location  when forwarding a Irp PcForwardIrpSynchronous
- Implement ISubdevice interface for IPortTopology
- Initialize the dpc for calling Miniport object, as it might create an interrupt object which immediately fires an interrupt
- If the caller doesnt provide an IAdapterPowerManagement interface, clear the existing reference
- Fix 2 bugs in IRegistryKey_NewSubKey which made the system crashing 
- Pass the pdo to IoOpenDeviceRegistryKey
- Move all guids and IIDs to own file and initialize them
- portcls initializes now to the first interrupt fired (vbox+ICH AC97 driver | qemu+es1370 driver)


svn path=/trunk/; revision=38810
This commit is contained in:
Johannes Anderwald 2009-01-17 11:19:27 +00:00
parent 4ca6732fcd
commit f59378c1d0
24 changed files with 602 additions and 197 deletions

View file

@ -13,8 +13,6 @@
#include <devguid.h> #include <devguid.h>
#include <initguid.h> #include <initguid.h>
const GUID IID_ISubdevice;
/* /*
This is called from DriverEntry so that PortCls can take care of some This is called from DriverEntry so that PortCls can take care of some
IRPs and map some others to the main KS driver. In most cases this will IRPs and map some others to the main KS driver. In most cases this will
@ -49,7 +47,7 @@ PcInitializeAdapterDriver(
//NTSTATUS status; //NTSTATUS status;
//ULONG i; //ULONG i;
DPRINT("PcInitializeAdapterDriver\n"); DPRINT1("PcInitializeAdapterDriver\n");
#if 0 #if 0
/* Set default stub - is this a good idea? */ /* Set default stub - is this a good idea? */
@ -101,59 +99,41 @@ PcAddAdapterDevice(
IN ULONG MaxObjects, IN ULONG MaxObjects,
IN ULONG DeviceExtensionSize) IN ULONG DeviceExtensionSize)
{ {
/*
Note - after this has been called, we can
handle IRP_MN_START_DEVICE by calling StartDevice
TODO:
Validate DeviceExtensionSize!! (et al...)
*/
NTSTATUS status = STATUS_UNSUCCESSFUL; NTSTATUS status = STATUS_UNSUCCESSFUL;
PDEVICE_OBJECT fdo = NULL; PDEVICE_OBJECT fdo = NULL;
PDEVICE_OBJECT PrevDeviceObject;
PCExtension* portcls_ext; PCExtension* portcls_ext;
DPRINT1("PcAddAdapterDevice called\n"); DPRINT1("PcAddAdapterDevice called\n");
if ( ! DriverObject) if (!DriverObject || !PhysicalDeviceObject || !StartDevice)
{ {
DPRINT("DriverObject is NULL!\n");
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
if ( ! PhysicalDeviceObject ) /* check if the DeviceExtensionSize is provided */
{
DPRINT("PhysicalDeviceObject is NULL!\n");
return STATUS_INVALID_PARAMETER;
}
if ( ! StartDevice )
{
DPRINT("No StartDevice parameter!\n");
return STATUS_INVALID_PARAMETER;
}
/* TODO: Make sure this is right */
if ( DeviceExtensionSize < PORT_CLASS_DEVICE_EXTENSION_SIZE ) if ( DeviceExtensionSize < PORT_CLASS_DEVICE_EXTENSION_SIZE )
{ {
/* driver does not need a device extension */
if ( DeviceExtensionSize != 0 ) if ( DeviceExtensionSize != 0 )
{ {
/* TODO: Error */ /* DeviceExtensionSize must be zero*/
DPRINT("DeviceExtensionSize is invalid\n");
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
/* set size to our extension size */
DeviceExtensionSize = PORT_CLASS_DEVICE_EXTENSION_SIZE;
} }
DPRINT("portcls is creating a device\n"); /* create the device */
status = IoCreateDevice(DriverObject, status = IoCreateDevice(DriverObject,
DeviceExtensionSize, DeviceExtensionSize,
NULL, NULL,
FILE_DEVICE_KS, FILE_DEVICE_KS,
PhysicalDeviceObject->Characteristics, /* TODO: Check */ FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN,
FALSE, FALSE,
&fdo); &fdo);
if ( ! NT_SUCCESS(status) ) if (!NT_SUCCESS(status))
{ {
DPRINT("IoCreateDevice() failed with status 0x%08lx\n", status); DPRINT("IoCreateDevice() failed with status 0x%08lx\n", status);
return status; return status;
@ -161,24 +141,60 @@ PcAddAdapterDevice(
/* Obtain the new device extension */ /* Obtain the new device extension */
portcls_ext = (PCExtension*) fdo->DeviceExtension; portcls_ext = (PCExtension*) fdo->DeviceExtension;
/* initialize the device extension */
RtlZeroMemory(portcls_ext, DeviceExtensionSize);
/* allocate create item */
portcls_ext->CreateItems = AllocateItem(NonPagedPool, MaxObjects * sizeof(KSOBJECT_CREATE_ITEM), TAG_PORTCLASS);
ASSERT(portcls_ext); /* store the physical device object */
/* Initialize */
RtlZeroMemory(portcls_ext, sizeof(PCExtension));
portcls_ext->PhysicalDeviceObject = PhysicalDeviceObject; portcls_ext->PhysicalDeviceObject = PhysicalDeviceObject;
/* set up the start device function */
portcls_ext->StartDevice = StartDevice; portcls_ext->StartDevice = StartDevice;
/* prepare the subdevice list */
InitializeListHead(&portcls_ext->SubDeviceList); InitializeListHead(&portcls_ext->SubDeviceList);
/* prepare the physical connection list */
InitializeListHead(&portcls_ext->PhysicalConnectionList); InitializeListHead(&portcls_ext->PhysicalConnectionList);
status = KsAllocateDeviceHeader(&portcls_ext->KsDeviceHeader, 0, NULL); /* set io flags */
fdo->Flags |= DO_DIRECT_IO | DO_POWER_PAGABLE;
/* clear initializing flag */
fdo->Flags &= ~ DO_DEVICE_INITIALIZING;
/* allocate the device header */
status = KsAllocateDeviceHeader(&portcls_ext->KsDeviceHeader, MaxObjects, portcls_ext->CreateItems);
/* did we succeed */
if (!NT_SUCCESS(status)) if (!NT_SUCCESS(status))
{ {
/* free previously allocated create items */
FreeItem(portcls_ext->CreateItems, TAG_PORTCLASS);
/* delete created fdo */
IoDeleteDevice(fdo); IoDeleteDevice(fdo);
/* return error code */
return status; return status;
} }
DPRINT("PcAddAdapterDriver succeeded\n"); /* attach device to device stack */
PrevDeviceObject = IoAttachDeviceToDeviceStack(fdo, PhysicalDeviceObject);
/* did we succeed */
if (PrevDeviceObject)
{
/* store the device object in the device header */
//KsSetDevicePnpBaseObject(portcls_ext->KsDeviceHeader, PrevDeviceObject, fdo);
portcls_ext->PrevDeviceObject = PrevDeviceObject;
}
else
{
/* free the device header */
KsFreeDeviceHeader(portcls_ext->KsDeviceHeader);
/* free previously allocated create items */
FreeItem(portcls_ext->CreateItems, TAG_PORTCLASS);
/* delete created fdo */
IoDeleteDevice(fdo);
/* return error code */
return STATUS_UNSUCCESSFUL;
}
return status; return status;
} }
@ -206,7 +222,7 @@ PciDriverDispatch(
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
Entry = ExAllocatePoolWithTag(NonPagedPool, sizeof(SUBDEVICE_ENTRY), TAG_PORTCLASS); Entry = AllocateItem(NonPagedPool, sizeof(SUBDEVICE_ENTRY), TAG_PORTCLASS);
if (!Entry) if (!Entry)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
@ -221,7 +237,7 @@ PciDriverDispatch(
Status = KsAllocateObjectHeader(&Entry->ObjectHeader, 1, NULL, Irp, &DispatchTable); Status = KsAllocateObjectHeader(&Entry->ObjectHeader, 1, NULL, Irp, &DispatchTable);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
ExFreePoolWithTag(Entry, TAG_PORTCLASS); FreeItem(Entry, TAG_PORTCLASS);
return Status; return Status;
} }
@ -247,9 +263,13 @@ PcRegisterSubdevice(
UNICODE_STRING ReferenceString; UNICODE_STRING ReferenceString;
UNICODE_STRING SymbolicLinkName; UNICODE_STRING SymbolicLinkName;
DPRINT1("PcRegisterSubdevice DeviceObject %p Name %S Unknown %p\n", DeviceObject, Name, Unknown);
if (!DeviceObject || !Name || !Unknown) if (!DeviceObject || !Name || !Unknown)
{
DPRINT("PcRegisterSubdevice invalid parameter\n");
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
}
DeviceExt = (PCExtension*)DeviceObject->DeviceExtension; DeviceExt = (PCExtension*)DeviceObject->DeviceExtension;
if (!DeviceExt) if (!DeviceExt)
@ -258,17 +278,20 @@ PcRegisterSubdevice(
Status = Unknown->lpVtbl->QueryInterface(Unknown, &IID_ISubdevice, (LPVOID)&SubDevice); Status = Unknown->lpVtbl->QueryInterface(Unknown, &IID_ISubdevice, (LPVOID)&SubDevice);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("No ISubdevice interface\n");
/* the provided port driver doesnt support ISubdevice */ /* the provided port driver doesnt support ISubdevice */
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
#if KS_IMPLEMENTED
Status = KsAddObjectCreateItemToDeviceHeader(DeviceExt->KsDeviceHeader, PciDriverDispatch, (PVOID)SubDevice, Name, NULL); Status = KsAddObjectCreateItemToDeviceHeader(DeviceExt->KsDeviceHeader, PciDriverDispatch, (PVOID)SubDevice, Name, NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
/* failed to attach */ /* failed to attach */
SubDevice->lpVtbl->Release(SubDevice); SubDevice->lpVtbl->Release(SubDevice);
DPRINT1("KsAddObjectCreateItemToDeviceHeader failed with %x\n", Status);
return Status; return Status;
} }
#endif
/* FIXME retrieve guid from subdescriptor */ /* FIXME retrieve guid from subdescriptor */
@ -284,6 +307,11 @@ PcRegisterSubdevice(
RtlFreeUnicodeString(&SymbolicLinkName); RtlFreeUnicodeString(&SymbolicLinkName);
} }
DPRINT1("PcRegisterSubdevice Status %x\n", Status);
return Status; /// HACK
/// IoRegisterDeviceInterface fails with
/// STATUS_OBJECT_PATH_NOT_FOUND
/// return Status;
return STATUS_SUCCESS;
} }

View file

@ -59,7 +59,7 @@ RegisterConnection(
goto cleanup; goto cleanup;
} }
NewConnection = ExAllocatePoolWithTag(NonPagedPool, sizeof(PHYSICAL_CONNECTION), TAG_PORTCLASS); NewConnection = AllocateItem(NonPagedPool, sizeof(PHYSICAL_CONNECTION), TAG_PORTCLASS);
if (!NewConnection) if (!NewConnection)
{ {
Status = STATUS_INSUFFICIENT_RESOURCES; Status = STATUS_INSUFFICIENT_RESOURCES;
@ -107,6 +107,9 @@ PcRegisterPhysicalConnection(
IN PUNKNOWN ToUnknown, IN PUNKNOWN ToUnknown,
IN ULONG ToPin) IN ULONG ToPin)
{ {
DPRINT1("PcRegisterPhysicalConnection\n");
if (!DeviceObject || !FromUnknown || !ToUnknown) if (!DeviceObject || !FromUnknown || !ToUnknown)
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;

View file

@ -85,7 +85,7 @@ IDmaChannelSlave_fnRelease(
if (This->ref == 0) if (This->ref == 0)
{ {
This->pAdapter->DmaOperations->PutDmaAdapter(This->pAdapter); This->pAdapter->DmaOperations->PutDmaAdapter(This->pAdapter);
ExFreePoolWithTag(This, TAG_PORTCLASS); FreeItem(This, TAG_PORTCLASS);
return 0; return 0;
} }
/* Return new reference count */ /* Return new reference count */
@ -487,7 +487,7 @@ PcNewDmaChannel(
IDmaChannelSlaveImpl * This; IDmaChannelSlaveImpl * This;
This = ExAllocatePoolWithTag(PoolType, sizeof(IDmaChannelSlaveImpl), TAG_PORTCLASS); This = AllocateItem(PoolType, sizeof(IDmaChannelSlaveImpl), TAG_PORTCLASS);
if (!This) if (!This)
{ {
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
@ -503,12 +503,11 @@ PcNewDmaChannel(
Adapter = IoGetDmaAdapter(DeviceObject, DeviceDescription, &MapRegisters); Adapter = IoGetDmaAdapter(DeviceObject, DeviceDescription, &MapRegisters);
if (!Adapter) if (!Adapter)
{ {
ExFreePoolWithTag(This, TAG_PORTCLASS); FreeItem(This, TAG_PORTCLASS);
return STATUS_DEVICE_CONFIGURATION_ERROR; return STATUS_DEVICE_CONFIGURATION_ERROR;
} }
RtlZeroMemory(This, sizeof(IDmaChannelSlaveImpl)); /* initialize object */
This->ref = 1; This->ref = 1;
This->lpVtbl = &vt_IDmaChannelSlaveVtbl; This->lpVtbl = &vt_IDmaChannelSlaveVtbl;
This->pAdapter = Adapter; This->pAdapter = Adapter;

View file

@ -1,8 +1,7 @@
#include "private.h" #include "private.h"
const GUID IID_IDrmPort;
const GUID IID_IDrmPort2;
typedef struct typedef struct
{ {
@ -33,7 +32,7 @@ IDrmPort2_fnRelease(
if (This->ref == 0) if (This->ref == 0)
{ {
ExFreePoolWithTag(This, TAG_PORTCLASS); FreeItem(This, TAG_PORTCLASS);
return 0; return 0;
} }
/* Return new reference count */ /* Return new reference count */
@ -154,7 +153,7 @@ NTSTATUS
NewIDrmPort( NewIDrmPort(
OUT PDRMPORT2 *OutPort) OUT PDRMPORT2 *OutPort)
{ {
IDrmPort2Impl * This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IDrmPort2Impl), TAG_PORTCLASS); IDrmPort2Impl * This = AllocateItem(NonPagedPool, sizeof(IDrmPort2Impl), TAG_PORTCLASS);
if (!This) if (!This)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;

View file

@ -59,7 +59,7 @@ IPortFilterWaveCyclic_fnRelease(
if (This->ref == 0) if (This->ref == 0)
{ {
ExFreePoolWithTag(This, TAG_PORTCLASS); FreeItem(This, TAG_PORTCLASS);
return 0; return 0;
} }
return This->ref; return This->ref;
@ -260,7 +260,7 @@ NTSTATUS NewPortFilterWaveCyclic(
{ {
IPortFilterWaveCyclicImpl * This; IPortFilterWaveCyclicImpl * This;
This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IPortFilterWaveCyclicImpl), TAG_PORTCLASS); This = AllocateItem(NonPagedPool, sizeof(IPortFilterWaveCyclicImpl), TAG_PORTCLASS);
if (!This) if (!This)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;

View file

@ -0,0 +1,49 @@
#include "private.h"
const GUID CLSID_PortTopology = {0xb4c90a32L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
const GUID CLSID_PortMidi = {0xb4c90a43L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
const GUID CLSID_PortWaveCyclic = {0xb4c90a2aL, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
const GUID CLSID_PortWavePci = {0xb4c90a54L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
const GUID CLSID_PortDMus;
const GUID IID_IMiniportDMus;
const GUID IID_IMiniportTopology = {0xb4c90a31L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
const GUID IID_IPortTopology = {0xb4c90a30L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
const GUID CLSID_MiniportDriverDMusUART;
const GUID CLSID_MiniportDriverUart;
const GUID CLSID_MiniportDriverDMusUARTCapture;
const GUID CLSID_MiniportDriverFmSynth;
const GUID CLSID_MiniportDriverFmSynthWithVol;
const GUID IID_IDrmPort = {0x286D3DF8L, 0xCA22, 0x4E2E, {0xB9, 0xBC, 0x20, 0xB4, 0xF0, 0xE2, 0x01, 0xCE}};
const GUID IID_IDrmPort2 = {0x1ACCE59CL, 0x7311, 0x4B6B, {0x9F, 0xBA, 0xCC, 0x3B, 0xA5, 0x9A, 0xCD, 0xCE}};
const GUID IID_IInterruptSync = {0x22C6AC63L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}};
const GUID IID_IPortWavePci = {0xb4c90a50L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
const GUID IID_IMiniportWavePci = {0xb4c90a52L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
const GUID IID_IAdapterPowerManagement = {0x793417D0L, 0x35FE, 0x11D1, {0xAD, 0x08, 0x00, 0xA0, 0xC9, 0x0A, 0xB1, 0xB0}};
const GUID IID_IMiniportWaveCyclic = {0xb4c90a27L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
const GUID IID_IPortWaveCyclic = {0xb4c90a26L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
const GUID IID_IResourceList = {0x22C6AC60L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}};
const GUID IID_IServiceGroup = {0x22C6AC65L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}};
const GUID IID_IPinCount = {0x5dadb7dcL, 0xa2cb, 0x4540, {0xa4, 0xa8, 0x42, 0x5e, 0xe4, 0xae, 0x90, 0x51}};
const GUID IID_IPowerNotify = {0x3DD648B8L, 0x969F, 0x11D1, {0x95, 0xA9, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3}};
const GUID IID_IDmaChannelSlave = {0x22C6AC62L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}};
const GUID IID_IDmaChannel = {0x22C6AC61L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}};
const GUID IID_IRegistryKey = {0xE8DA4302l, 0xF304, 0x11D0, {0x95, 0x8B, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3}};
const GUID IID_IServiceSink = {0x22C6AC64L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}};
const GUID IID_IPortClsVersion = {0x7D89A7BBL, 0x869B, 0x4567, {0x8D, 0xBE, 0x1E, 0x16, 0x8C, 0xC8, 0x53, 0xDE}};
const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x46}};
///
/// undocumented guids
const GUID IID_ISubdevice = {0xB4C90A61, 0x5791, 0x11D0, {0x86, 0xF9, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44}};
const GUID IID_IIrpTarget = {0xB4C90A60, 0x5791, 0x11D0, {0xF9, 0x86, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44}};
const GUID IID_IIrpTargetFactory = {0xB4C90A62, 0x5791, 0x11D0, {0xF9, 0x86, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44}};

View file

@ -1,9 +1,9 @@
#ifndef INTERFACES_H__ #ifndef INTERFACES_H__
#define INTERFACES_H__ #define INTERFACES_H__
DEFINE_GUID(IID_IIrpTarget, 0xB4C90A60, 0x5791, 0x11D0, 0x86, 0xF9, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44); DEFINE_GUID(IID_IIrpTarget, 0xB4C90A60, 0x5791, 0x11D0, 0xF9, 0x86, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44);
DEFINE_GUID(IID_ISubdevice, 0xB4C90A61, 0x5791, 0x11D0, 0x86, 0xF9, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44); DEFINE_GUID(IID_ISubdevice, 0xB4C90A61, 0x5791, 0x11D0, 0xF9, 0x86, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44);
DEFINE_GUID(IID_IIrpTargetFactory, 0xB4C90A62, 0x5791, 0x11D0, 0x86, 0xF9, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44); DEFINE_GUID(IID_IIrpTargetFactory, 0xB4C90A62, 0x5791, 0x11D0, 0xF9, 0x86, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44);
/***************************************************************************** /*****************************************************************************

View file

@ -28,7 +28,7 @@ typedef struct
// IUnknown methods // IUnknown methods
// //
const GUID IID_IInterruptSync;
NTSTATUS NTSTATUS
NTAPI NTAPI
@ -39,13 +39,15 @@ IInterruptSync_fnQueryInterface(
{ {
IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface; IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface;
DPRINT1("IInterruptSync_fnQueryInterface: This %p\n", This);
if (IsEqualGUIDAligned(refiid, &IID_IInterruptSync)) if (IsEqualGUIDAligned(refiid, &IID_IInterruptSync))
{ {
*Output = &This->lpVtbl; *Output = &This->lpVtbl;
_InterlockedIncrement(&This->ref); _InterlockedIncrement(&This->ref);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
DPRINT1("IInterruptSync_fnQueryInterface: This %p UNKNOWN interface requested\n", This);
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -56,7 +58,7 @@ IInterruptSync_fnAddRef(
{ {
IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface; IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface;
DPRINT("IInterruptSync_AddRef: This %p\n", This); DPRINT1("IInterruptSync_AddRef: This %p\n", This);
return _InterlockedIncrement(&This->ref); return _InterlockedIncrement(&This->ref);
} }
@ -72,24 +74,20 @@ IInterruptSync_fnRelease(
_InterlockedDecrement(&This->ref); _InterlockedDecrement(&This->ref);
DPRINT("IInterruptSync_Release: This %p new ref %u\n", This, This->ref); DPRINT1("IInterruptSync_Release: This %p new ref %u\n", This, This->ref);
if (This->ref == 0) if (This->ref == 0)
{ {
if (This->Interrupt)
{
DPRINT1("Interrupt not disconnected! %p\n", This->Interrupt);
IoDisconnectInterrupt(This->Interrupt);
}
while(!IsListEmpty(&This->ServiceRoutines)) while(!IsListEmpty(&This->ServiceRoutines))
{ {
CurEntry = RemoveHeadList(&This->ServiceRoutines); CurEntry = RemoveHeadList(&This->ServiceRoutines);
Entry = CONTAINING_RECORD(CurEntry, SYNC_ENTRY, ListEntry); Entry = CONTAINING_RECORD(CurEntry, SYNC_ENTRY, ListEntry);
ExFreePoolWithTag(Entry, TAG_PORTCLASS); FreeItem(Entry, TAG_PORTCLASS);
} }
This->ResourceList->lpVtbl->Release(This->ResourceList); //This->ResourceList->lpVtbl->Release(This->ResourceList);
ExFreePoolWithTag(This, TAG_PORTCLASS); //FreeItem(This, TAG_PORTCLASS);
DPRINT1("IInterruptSync_Release: complete\n");
return 0; return 0;
} }
/* Return new reference count */ /* Return new reference count */
@ -107,8 +105,8 @@ IInterruptSynchronizedRoutine(
IN PVOID ServiceContext) IN PVOID ServiceContext)
{ {
IInterruptSyncImpl * This = (IInterruptSyncImpl*)ServiceContext; IInterruptSyncImpl * This = (IInterruptSyncImpl*)ServiceContext;
DPRINT1("IInterruptSynchronizedRoutine This %p SyncRoutine%p\n", This, This->SyncRoutine);
return This->SyncRoutine((IInterruptSync*)This, This->DynamicContext); return This->SyncRoutine((IInterruptSync*)&This->lpVtbl, This->DynamicContext);
} }
NTSTATUS NTSTATUS
@ -118,12 +116,24 @@ IInterruptSync_fnCallSynchronizedRoutine(
IN PINTERRUPTSYNCROUTINE Routine, IN PINTERRUPTSYNCROUTINE Routine,
IN PVOID DynamicContext) IN PVOID DynamicContext)
{ {
KIRQL OldIrql;
IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface; IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface;
DPRINT1("IInterruptSync_fnCallSynchronizedRoutine This %p Routine %p DynamicContext %p\n", This, Routine, DynamicContext);
if (!This->Interrupt) if (!This->Interrupt)
{ {
DPRINT("IInterruptSync_CallSynchronizedRoutine %p no interrupt connected\n", This); DPRINT("IInterruptSync_CallSynchronizedRoutine %p no interrupt connected\n", This);
return STATUS_UNSUCCESSFUL; if (KeGetCurrentIrql() > DISPATCH_LEVEL)
return STATUS_UNSUCCESSFUL;
KeAcquireSpinLock(&This->Lock, &OldIrql);
This->SyncRoutine = Routine;
This->DynamicContext = DynamicContext;
IInterruptSynchronizedRoutine((PVOID)This);
KeReleaseSpinLock(&This->Lock, OldIrql);
return STATUS_SUCCESS;
} }
This->SyncRoutine = Routine; This->SyncRoutine = Routine;
@ -138,6 +148,7 @@ IInterruptSync_fnGetKInterrupt(
IN IInterruptSync * iface) IN IInterruptSync * iface)
{ {
IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface; IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface;
DPRINT1("IInterruptSynchronizedRoutine\n");
return This->Interrupt; return This->Interrupt;
} }
@ -154,6 +165,8 @@ IInterruptServiceRoutine(
BOOL Success; BOOL Success;
IInterruptSyncImpl * This = (IInterruptSyncImpl*)ServiceContext; IInterruptSyncImpl * This = (IInterruptSyncImpl*)ServiceContext;
DPRINT1("IInterruptServiceRoutine\n");
if (This->Mode == InterruptSyncModeNormal) if (This->Mode == InterruptSyncModeNormal)
{ {
CurEntry = This->ServiceRoutines.Flink; CurEntry = This->ServiceRoutines.Flink;
@ -216,6 +229,8 @@ IInterruptSync_fnConnect(
NTSTATUS Status; NTSTATUS Status;
PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor; PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor;
DPRINT1("IInterruptSync_fnConnect\n");
Descriptor = This->ResourceList->lpVtbl->FindTranslatedEntry(This->ResourceList, CmResourceTypeInterrupt, This->ResourceIndex); Descriptor = This->ResourceList->lpVtbl->FindTranslatedEntry(This->ResourceList, CmResourceTypeInterrupt, This->ResourceIndex);
if (!Descriptor) if (!Descriptor)
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
@ -244,6 +259,7 @@ IInterruptSync_fnDisconnect(
IN IInterruptSync * iface) IN IInterruptSync * iface)
{ {
IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface; IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface;
DPRINT1("IInterruptSync_fnDisconnect\n");
if (!This->Interrupt) if (!This->Interrupt)
{ {
@ -266,7 +282,9 @@ IInterruptSync_fnRegisterServiceRoutine(
PSYNC_ENTRY NewEntry; PSYNC_ENTRY NewEntry;
IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface; IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface;
NewEntry = ExAllocatePoolWithTag(NonPagedPool, sizeof(SYNC_ENTRY), TAG_PORTCLASS); DPRINT1("IInterruptSync_fnRegisterServiceRoutine\n");
NewEntry = AllocateItem(NonPagedPool, sizeof(SYNC_ENTRY), TAG_PORTCLASS);
if (!NewEntry) if (!NewEntry)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
@ -308,6 +326,7 @@ PcNewInterruptSync(
{ {
IInterruptSyncImpl * This; IInterruptSyncImpl * This;
DPRINT1("PcNewInterruptSync entered\n");
if (!OutInterruptSync || !ResourceList || Mode > InterruptSyncModeRepeat || Mode < 0) if (!OutInterruptSync || !ResourceList || Mode > InterruptSyncModeRepeat || Mode < 0)
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
@ -315,22 +334,24 @@ PcNewInterruptSync(
if (ResourceIndex > ResourceList->lpVtbl->NumberOfEntriesOfType(ResourceList, CmResourceTypeInterrupt)) if (ResourceIndex > ResourceList->lpVtbl->NumberOfEntriesOfType(ResourceList, CmResourceTypeInterrupt))
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
ResourceList->lpVtbl->AddRef(ResourceList); ResourceList->lpVtbl->AddRef(ResourceList);
This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IInterruptSyncImpl), TAG_PORTCLASS); This = AllocateItem(NonPagedPool, sizeof(IInterruptSyncImpl), TAG_PORTCLASS);
if (!This) if (!This)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
/* initialize object */
This->lpVtbl = &vt_IInterruptSyncVtbl; This->lpVtbl = &vt_IInterruptSyncVtbl;
This->ref = 1; This->ref = 1;
This->Mode = Mode; This->Mode = Mode;
This->Interrupt = NULL;
This->ResourceIndex = ResourceIndex; This->ResourceIndex = ResourceIndex;
This->ResourceList = ResourceList; This->ResourceList = ResourceList;
InitializeListHead(&This->ServiceRoutines); InitializeListHead(&This->ServiceRoutines);
KeInitializeSpinLock(&This->Lock); KeInitializeSpinLock(&This->Lock);
*OutInterruptSync = (PINTERRUPTSYNC)&This->lpVtbl; *OutInterruptSync = (PINTERRUPTSYNC)&This->lpVtbl;
return STATUS_UNSUCCESSFUL; DPRINT1("PcNewInterruptSync success %p\n", *OutInterruptSync);
return STATUS_SUCCESS;
} }

View file

@ -205,7 +205,7 @@ PcDispatchIrp(
{ {
PIO_STACK_LOCATION irp_stack; PIO_STACK_LOCATION irp_stack;
DPRINT("PcDispatchIrp called - handling IRP in PortCls\n"); DPRINT1("PcDispatchIrp called - handling IRP in PortCls\n");
irp_stack = IoGetCurrentIrpStackLocation(Irp); irp_stack = IoGetCurrentIrpStackLocation(Irp);
@ -289,10 +289,13 @@ PcForwardIrpSynchronous(
DPRINT1("PcForwardIrpSynchronous\n"); DPRINT1("PcForwardIrpSynchronous\n");
DeviceExt = (PCExtension*)DeviceObject->DeviceExtension; DeviceExt = (PCExtension*)DeviceObject->DeviceExtension;
return STATUS_SUCCESS;
/* initialize the notification event */ /* initialize the notification event */
KeInitializeEvent(&Event, NotificationEvent, FALSE); KeInitializeEvent(&Event, NotificationEvent, FALSE);
/* copy the current stack location */
IoCopyCurrentIrpStackLocationToNext(Irp);
/* setup a completion routine */ /* setup a completion routine */
IoSetCompletionRoutine(Irp, IrpCompletionRoutine, (PVOID)&Event, TRUE, FALSE, FALSE); IoSetCompletionRoutine(Irp, IrpCompletionRoutine, (PVOID)&Event, TRUE, FALSE, FALSE);

View file

@ -12,11 +12,7 @@
#include "private.h" #include "private.h"
const GUID CLSID_MiniportDriverDMusUART;
const GUID CLSID_MiniportDriverUart;
const GUID CLSID_MiniportDriverDMusUARTCapture;
const GUID CLSID_MiniportDriverFmSynth;
const GUID CLSID_MiniportDriverFmSynthWithVol;
/* /*
* @implemented * @implemented
@ -28,6 +24,8 @@ PcNewMiniport(
{ {
NTSTATUS Status = STATUS_INVALID_PARAMETER; NTSTATUS Status = STATUS_INVALID_PARAMETER;
DPRINT1("PcNewMiniport entered\n");
if (!OutMiniport) if (!OutMiniport)
{ {
DPRINT("PcNewMiniport was supplied a NULL OutPort parameter\n"); DPRINT("PcNewMiniport was supplied a NULL OutPort parameter\n");

View file

@ -8,7 +8,7 @@ typedef struct
}IMiniportDMusImpl; }IMiniportDMusImpl;
const GUID IID_IMiniportDMus;
/* IUnknown methods */ /* IUnknown methods */
@ -51,7 +51,7 @@ IMiniportDMust_fnRelease(
if (This->ref == 0) if (This->ref == 0)
{ {
ExFreePoolWithTag(This, TAG_PORTCLASS); FreeItem(This, TAG_PORTCLASS);
return 0; return 0;
} }
/* Return new reference count */ /* Return new reference count */
@ -148,7 +148,7 @@ NewMiniportDMusUART(
{ {
IMiniportDMusImpl * This; IMiniportDMusImpl * This;
This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IMiniportDMusImpl), TAG_PORTCLASS); This = AllocateItem(NonPagedPool, sizeof(IMiniportDMusImpl), TAG_PORTCLASS);
if (!This) if (!This)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;

View file

@ -0,0 +1,26 @@
#include "private.h"
PVOID
AllocateItem(
IN POOL_TYPE PoolType,
IN SIZE_T NumberOfBytes,
IN ULONG Tag)
{
PVOID Item = ExAllocatePoolWithTag(PoolType, NumberOfBytes, Tag);
if (!Item)
return Item;
RtlZeroMemory(Item, NumberOfBytes);
return Item;
}
VOID
FreeItem(
IN PVOID Item,
IN ULONG Tag)
{
//ExFreePoolWithTag(Item, Tag);
}

View file

@ -1,13 +1,31 @@
#include "private.h" #include "private.h"
NTSTATUS StringFromCLSID(
const CLSID *id, /* [in] GUID to be converted */
LPWSTR idstr /* [out] pointer to buffer to contain converted guid */
) {
static const char hex[] = "0123456789ABCDEF";
WCHAR *s;
int i;
swprintf(idstr, L"{%08X-%04X-%04X-%02X%02X-",
id->Data1, id->Data2, id->Data3,
id->Data4[0], id->Data4[1]);
s = &idstr[25];
/* 6 hex bytes */
for (i = 2; i < 8; i++) {
*s++ = hex[id->Data4[i]>>4];
*s++ = hex[id->Data4[i] & 0xf];
}
*s++ = '}';
*s++ = '\0';
return STATUS_SUCCESS;
}
const GUID CLSID_PortTopology;
const GUID CLSID_PortMidi;
const GUID CLSID_PortWaveCyclic;
const GUID CLSID_PortWavePci;
const GUID CLSID_PortDMus;
PORTCLASSAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
PcNewPort( PcNewPort(
@ -15,6 +33,9 @@ PcNewPort(
IN REFCLSID ClassId) IN REFCLSID ClassId)
{ {
NTSTATUS Status; NTSTATUS Status;
WCHAR Buffer[100];
DPRINT1("PcNewPort entered\n");
if (!OutPort) if (!OutPort)
{ {
@ -33,8 +54,14 @@ PcNewPort(
else if (IsEqualGUIDAligned(ClassId, &CLSID_PortWavePci)) else if (IsEqualGUIDAligned(ClassId, &CLSID_PortWavePci))
Status = NewPortWavePci(OutPort); Status = NewPortWavePci(OutPort);
else else
Status = STATUS_NOT_SUPPORTED; {
StringFromCLSID(ClassId, Buffer);
DPRINT1("unknown interface %S\n", Buffer);
Status = STATUS_NOT_SUPPORTED;
return Status;
}
DPRINT("PcNewPort Status %lx\n", Status); DPRINT("PcNewPort Status %lx\n", Status);
return Status; return Status;

View file

@ -66,7 +66,7 @@ IPortDMus_fnRelease(
{ {
This->pMiniport->lpVtbl->Release(This->pMiniport); This->pMiniport->lpVtbl->Release(This->pMiniport);
} }
ExFreePoolWithTag(This, TAG_PORTCLASS); FreeItem(This, TAG_PORTCLASS);
return 0; return 0;
} }
/* Return new reference count */ /* Return new reference count */

View file

@ -3,18 +3,20 @@
typedef struct typedef struct
{ {
IPortTopologyVtbl *lpVtbl; IPortTopologyVtbl *lpVtbl;
ISubdeviceVtbl *lpVtblSubDevice;
LONG ref; LONG ref;
BOOL bInitialized; BOOL bInitialized;
PMINIPORTTOPOLOGY Miniport; PMINIPORTTOPOLOGY pMiniport;
PDEVICE_OBJECT pDeviceObject; PDEVICE_OBJECT pDeviceObject;
PRESOURCELIST pResourceList; PRESOURCELIST pResourceList;
PPINCOUNT pPinCount;
PPOWERNOTIFY pPowerNotify;
}IPortTopologyImpl; }IPortTopologyImpl;
const GUID IID_IMiniportTopology;
const GUID IID_IPortTopology;
#if 0 #if 0
static static
KSPROPERTY_SET PinPropertySet = KSPROPERTY_SET PinPropertySet =
@ -49,19 +51,32 @@ IPortTopology_fnQueryInterface(
IN REFIID refiid, IN REFIID refiid,
OUT PVOID* Output) OUT PVOID* Output)
{ {
WCHAR Buffer[100];
IPortTopologyImpl * This = (IPortTopologyImpl*)iface; IPortTopologyImpl * This = (IPortTopologyImpl*)iface;
DPRINT1("IPortTopology_fnQueryInterface\n");
if (IsEqualGUIDAligned(refiid, &IID_IPortTopology) || if (IsEqualGUIDAligned(refiid, &IID_IPortTopology) ||
IsEqualGUIDAligned(refiid, &IID_IUnknown)) IsEqualGUIDAligned(refiid, &IID_IUnknown))
{ {
*Output = &This->lpVtbl; *Output = &This->lpVtbl;
_InterlockedIncrement(&This->ref); InterlockedIncrement(&This->ref);
return STATUS_SUCCESS;
}
else if (IsEqualGUIDAligned(refiid, &IID_ISubdevice))
{
*Output = &This->lpVtblSubDevice;
InterlockedIncrement(&This->ref);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
else if (IsEqualGUIDAligned(refiid, &IID_IPortClsVersion)) else if (IsEqualGUIDAligned(refiid, &IID_IPortClsVersion))
{ {
return NewPortClsVersion((PPORTCLSVERSION*)Output); return NewPortClsVersion((PPORTCLSVERSION*)Output);
} }
StringFromCLSID(refiid, Buffer);
DPRINT1("IPortTopology_fnQueryInterface no iface %S\n", Buffer);
StringFromCLSID(&IID_IUnknown, Buffer);
DPRINT1("IPortTopology_fnQueryInterface IUnknown %S\n", Buffer);
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -87,7 +102,7 @@ IPortTopology_fnRelease(
if (This->ref == 0) if (This->ref == 0)
{ {
ExFreePoolWithTag(This, TAG_PORTCLASS); FreeItem(This, TAG_PORTCLASS);
return 0; return 0;
} }
/* Return new reference count */ /* Return new reference count */
@ -112,7 +127,7 @@ IPortTopology_fnGetDeviceProperty(
if (!This->bInitialized) if (!This->bInitialized)
{ {
DPRINT("IPortWaveCyclic_fnNewRegistryKey called w/o initiazed\n"); DPRINT("IPortTopology_fnNewRegistryKey called w/o initiazed\n");
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -133,37 +148,43 @@ IPortTopology_fnInit(
NTSTATUS Status; NTSTATUS Status;
IPortTopologyImpl * This = (IPortTopologyImpl*)iface; IPortTopologyImpl * This = (IPortTopologyImpl*)iface;
DPRINT1("IPortTopology_fnInit entered\n");
if (This->bInitialized) if (This->bInitialized)
{ {
DPRINT("IPortWaveCyclic_Init called again\n"); DPRINT1("IPortTopology_Init called again\n");
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
Status = UnknownMiniport->lpVtbl->QueryInterface(UnknownMiniport, &IID_IMiniportTopology, (PVOID*)&Miniport); Status = UnknownMiniport->lpVtbl->QueryInterface(UnknownMiniport, &IID_IMiniportTopology, (PVOID*)&Miniport);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("IPortWaveCyclic_Init called with invalid IMiniport adapter\n"); DPRINT1("IPortTopology_Init called with invalid IMiniport adapter\n");
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
/* increment reference on resource list */
//HACK
//ResourceList->lpVtbl->AddRef(ResourceList);
Status = Miniport->lpVtbl->Init(Miniport, UnknownAdapter, ResourceList, iface); Status = Miniport->lpVtbl->Init(Miniport, UnknownAdapter, ResourceList, iface);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("IMiniportWaveCyclic_Init failed with %x\n", Status); DPRINT1("IPortTopology_Init failed with %x\n", Status);
return Status; return Status;
} }
/* Initialize port object */ /* Initialize port object */
This->Miniport = Miniport; This->pMiniport = Miniport;
This->pDeviceObject = DeviceObject; This->pDeviceObject = DeviceObject;
This->bInitialized = TRUE; This->bInitialized = TRUE;
This->pResourceList = ResourceList; This->pResourceList = ResourceList;
/* increment reference on miniport adapter */ /* increment reference on miniport adapter */
Miniport->lpVtbl->AddRef(Miniport); Miniport->lpVtbl->AddRef(Miniport);
/* increment reference on resource list */
ResourceList->lpVtbl->AddRef(ResourceList);
DPRINT1("IPortTopology_fnInit success\n");
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -184,7 +205,7 @@ IPortTopology_fnNewRegistryKey(
if (!This->bInitialized) if (!This->bInitialized)
{ {
DPRINT("IPortWaveCyclic_fnNewRegistryKey called w/o initialized\n"); DPRINT("IPortTopology_fnNewRegistryKey called w/o initialized\n");
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
return PcNewRegistryKey(OutRegistryKey, return PcNewRegistryKey(OutRegistryKey,
@ -210,20 +231,185 @@ static IPortTopologyVtbl vt_IPortTopology =
IPortTopology_fnNewRegistryKey IPortTopology_fnNewRegistryKey
}; };
//---------------------------------------------------------------
// ISubdevice interface
//
static
NTSTATUS
NTAPI
ISubDevice_fnQueryInterface(
IN ISubdevice *iface,
IN REFIID InterfaceId,
IN PVOID* Interface)
{
IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice);
return IPortTopology_fnQueryInterface((IPortTopology*)This, InterfaceId, Interface);
}
static
ULONG
NTAPI
ISubDevice_fnAddRef(
IN ISubdevice *iface)
{
IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice);
return IPortTopology_fnAddRef((IPortTopology*)This);
}
static
ULONG
NTAPI
ISubDevice_fnRelease(
IN ISubdevice *iface)
{
IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice);
return IPortTopology_fnRelease((IPortTopology*)This);
}
static
NTSTATUS
NTAPI
ISubDevice_fnNewIrpTarget(
IN ISubdevice *iface,
OUT struct IIrpTarget **OutTarget,
IN WCHAR * Name,
IN PUNKNOWN Unknown,
IN POOL_TYPE PoolType,
IN PDEVICE_OBJECT * DeviceObject,
IN PIRP Irp,
IN KSOBJECT_CREATE *CreateObject)
{
IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice);
DPRINT1("ISubDevice_NewIrpTarget this %p\n", This);
return STATUS_UNSUCCESSFUL;
}
static
NTSTATUS
NTAPI
ISubDevice_fnReleaseChildren(
IN ISubdevice *iface)
{
IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice);
DPRINT1("ISubDevice_ReleaseChildren this %p\n", This);
return STATUS_UNSUCCESSFUL;
}
static
NTSTATUS
NTAPI
ISubDevice_fnGetDescriptor(
IN ISubdevice *iface,
IN struct SUBDEVICE_DESCRIPTOR ** Descriptor)
{
IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice);
DPRINT1("ISubDevice_GetDescriptor this %p\n", This);
return STATUS_UNSUCCESSFUL;
}
static
NTSTATUS
NTAPI
ISubDevice_fnDataRangeIntersection(
IN ISubdevice *iface,
IN ULONG PinId,
IN PKSDATARANGE DataRange,
IN PKSDATARANGE MatchingDataRange,
IN ULONG OutputBufferLength,
OUT PVOID ResultantFormat OPTIONAL,
OUT PULONG ResultantFormatLength)
{
IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice);
DPRINT("ISubDevice_DataRangeIntersection this %p\n", This);
if (This->pMiniport)
{
return This->pMiniport->lpVtbl->DataRangeIntersection (This->pMiniport, PinId, DataRange, MatchingDataRange, OutputBufferLength, ResultantFormat, ResultantFormatLength);
}
return STATUS_UNSUCCESSFUL;
}
static
NTSTATUS
NTAPI
ISubDevice_fnPowerChangeNotify(
IN ISubdevice *iface,
IN POWER_STATE PowerState)
{
IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice);
if (This->pPowerNotify)
{
This->pPowerNotify->lpVtbl->PowerChangeNotify(This->pPowerNotify, PowerState);
}
return STATUS_SUCCESS;
}
static
NTSTATUS
NTAPI
ISubDevice_fnPinCount(
IN ISubdevice *iface,
IN ULONG PinId,
IN OUT PULONG FilterNecessary,
IN OUT PULONG FilterCurrent,
IN OUT PULONG FilterPossible,
IN OUT PULONG GlobalCurrent,
IN OUT PULONG GlobalPossible)
{
IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice);
if (This->pPinCount)
{
This->pPinCount->lpVtbl->PinCount(This->pPinCount, PinId, FilterNecessary, FilterCurrent, FilterPossible, GlobalCurrent, GlobalPossible);
return STATUS_SUCCESS;
}
/* FIXME
* scan filter descriptor
*/
return STATUS_UNSUCCESSFUL;
}
static ISubdeviceVtbl vt_ISubdeviceVtbl =
{
ISubDevice_fnQueryInterface,
ISubDevice_fnAddRef,
ISubDevice_fnRelease,
ISubDevice_fnNewIrpTarget,
ISubDevice_fnReleaseChildren,
ISubDevice_fnGetDescriptor,
ISubDevice_fnDataRangeIntersection,
ISubDevice_fnPowerChangeNotify,
ISubDevice_fnPinCount
};
NTSTATUS NTSTATUS
NewPortTopology( NewPortTopology(
OUT PPORT* OutPort) OUT PPORT* OutPort)
{ {
IPortTopologyImpl * This; IPortTopologyImpl * This;
This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IPortTopologyImpl), TAG_PORTCLASS); This = AllocateItem(NonPagedPool, sizeof(IPortTopologyImpl), TAG_PORTCLASS);
if (!This) if (!This)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
RtlZeroMemory(This, sizeof(IPortTopologyImpl));
This->lpVtbl = &vt_IPortTopology; This->lpVtbl = &vt_IPortTopology;
This->lpVtblSubDevice = &vt_ISubdeviceVtbl;
This->ref = 1; This->ref = 1;
*OutPort = (PPORT)(&This->lpVtbl); *OutPort = (PPORT)(&This->lpVtbl);
DPRINT1("NewPortTopology result %p\n", *OutPort);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -20,13 +20,6 @@ typedef struct
}IPortWaveCyclicImpl; }IPortWaveCyclicImpl;
const GUID IID_IMiniportWaveCyclic;
const GUID IID_IPortWaveCyclic;
const GUID IID_IUnknown;
const GUID IID_IIrpTarget;
const GUID IID_IPinCount;
const GUID IID_IPowerNotify;
const GUID IID_IDmaChannelSlave;
const GUID GUID_DEVCLASS_SOUND; //FIXME const GUID GUID_DEVCLASS_SOUND; //FIXME
//--------------------------------------------------------------- //---------------------------------------------------------------
@ -98,7 +91,7 @@ IPortWaveCyclic_fnRelease(
if (This->pPowerNotify) if (This->pPowerNotify)
This->pPowerNotify->lpVtbl->Release(This->pPowerNotify); This->pPowerNotify->lpVtbl->Release(This->pPowerNotify);
ExFreePoolWithTag(This, TAG_PORTCLASS); FreeItem(This, TAG_PORTCLASS);
return 0; return 0;
} }
/* Return new reference count */ /* Return new reference count */
@ -509,16 +502,17 @@ NewPortWaveCyclic(
{ {
IPortWaveCyclicImpl * This; IPortWaveCyclicImpl * This;
This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IPortWaveCyclicImpl), TAG_PORTCLASS); This = AllocateItem(NonPagedPool, sizeof(IPortWaveCyclicImpl), TAG_PORTCLASS);
if (!This) if (!This)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
RtlZeroMemory(This, sizeof(IPortWaveCyclicImpl));
This->lpVtbl = (IPortWaveCyclicVtbl*)&vt_IPortWaveCyclicVtbl; This->lpVtbl = (IPortWaveCyclicVtbl*)&vt_IPortWaveCyclicVtbl;
This->lpVtblSubDevice = (ISubdeviceVtbl*)&vt_ISubdeviceVtbl; This->lpVtblSubDevice = (ISubdeviceVtbl*)&vt_ISubdeviceVtbl;
This->ref = 1; This->ref = 1;
*OutPort = (PPORT)(&This->lpVtbl); *OutPort = (PPORT)(&This->lpVtbl);
DPRINT1("NewPortWaveCyclic %p\n", *OutPort);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -19,8 +19,7 @@ typedef struct
}IPortWavePciImpl; }IPortWavePciImpl;
const GUID IID_IPortWavePci;
const GUID IID_IMiniportWavePci;
//--------------------------------------------------------------- //---------------------------------------------------------------
// IServiceSink // IServiceSink
@ -36,7 +35,10 @@ IServiceSink_fnQueryInterface(
{ {
IPortWavePciImpl * This = (IPortWavePciImpl*)CONTAINING_RECORD(iface, IPortWavePciImpl, lpVtblServiceSink); IPortWavePciImpl * This = (IPortWavePciImpl*)CONTAINING_RECORD(iface, IPortWavePciImpl, lpVtblServiceSink);
if (IsEqualGUIDAligned(refiid, &IID_IServiceSink)) DPRINT1("IServiceSink_fnQueryInterface entered\n");
if (IsEqualGUIDAligned(refiid, &IID_IServiceSink) ||
IsEqualGUIDAligned(refiid, &IID_IUnknown))
{ {
*Output = &This->lpVtblServiceSink; *Output = &This->lpVtblServiceSink;
InterlockedIncrement(&This->ref); InterlockedIncrement(&This->ref);
@ -52,7 +54,7 @@ IServiceSink_fnAddRef(
IServiceSink* iface) IServiceSink* iface)
{ {
IPortWavePciImpl * This = (IPortWavePciImpl*)CONTAINING_RECORD(iface, IPortWavePciImpl, lpVtblServiceSink); IPortWavePciImpl * This = (IPortWavePciImpl*)CONTAINING_RECORD(iface, IPortWavePciImpl, lpVtblServiceSink);
DPRINT1("IServiceSink_fnAddRef entered\n");
return InterlockedIncrement(&This->ref); return InterlockedIncrement(&This->ref);
} }
@ -63,12 +65,12 @@ IServiceSink_fnRelease(
IServiceSink* iface) IServiceSink* iface)
{ {
IPortWavePciImpl * This = (IPortWavePciImpl*)CONTAINING_RECORD(iface, IPortWavePciImpl, lpVtblServiceSink); IPortWavePciImpl * This = (IPortWavePciImpl*)CONTAINING_RECORD(iface, IPortWavePciImpl, lpVtblServiceSink);
DPRINT1("IServiceSink_fnRelease entered\n");
InterlockedDecrement(&This->ref); InterlockedDecrement(&This->ref);
if (This->ref == 0) if (This->ref == 0)
{ {
ExFreePoolWithTag(This, TAG_PORTCLASS); FreeItem(This, TAG_PORTCLASS);
return 0; return 0;
} }
/* Return new reference count */ /* Return new reference count */
@ -82,7 +84,7 @@ IServiceSink_fnRequestService(
IServiceSink* iface) IServiceSink* iface)
{ {
IPortWavePciImpl * This = (IPortWavePciImpl*)CONTAINING_RECORD(iface, IPortWavePciImpl, lpVtblServiceSink); IPortWavePciImpl * This = (IPortWavePciImpl*)CONTAINING_RECORD(iface, IPortWavePciImpl, lpVtblServiceSink);
DPRINT1("IServiceSink_fnRequestService entered\n");
if (This->Miniport) if (This->Miniport)
{ {
This->Miniport->lpVtbl->Service(This->Miniport); This->Miniport->lpVtbl->Service(This->Miniport);
@ -111,7 +113,10 @@ IPortWavePci_fnQueryInterface(
{ {
IPortWavePciImpl * This = (IPortWavePciImpl*)iface; IPortWavePciImpl * This = (IPortWavePciImpl*)iface;
if (IsEqualGUIDAligned(refiid, &IID_IPortWavePci)) DPRINT1("IPortWavePci_fnQueryInterface entered\n");
if (IsEqualGUIDAligned(refiid, &IID_IPortWavePci) ||
IsEqualGUIDAligned(refiid, &IID_IUnknown))
{ {
*Output = &This->lpVtbl; *Output = &This->lpVtbl;
InterlockedIncrement(&This->ref); InterlockedIncrement(&This->ref);
@ -127,6 +132,9 @@ IPortWavePci_fnQueryInterface(
{ {
return NewPortClsVersion((PPORTCLSVERSION*)Output); return NewPortClsVersion((PPORTCLSVERSION*)Output);
} }
DPRINT1("IPortWavePci_fnQueryInterface no interface!!!\n");
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -137,6 +145,9 @@ IPortWavePci_fnAddRef(
IPortWavePci* iface) IPortWavePci* iface)
{ {
IPortWavePciImpl * This = (IPortWavePciImpl*)iface; IPortWavePciImpl * This = (IPortWavePciImpl*)iface;
DPRINT1("IPortWavePci_fnAddRef entered\n");
return InterlockedIncrement(&This->ref); return InterlockedIncrement(&This->ref);
} }
@ -148,11 +159,13 @@ IPortWavePci_fnRelease(
{ {
IPortWavePciImpl * This = (IPortWavePciImpl*)iface; IPortWavePciImpl * This = (IPortWavePciImpl*)iface;
DPRINT1("IPortWavePci_fnRelease entered\n");
InterlockedDecrement(&This->ref); InterlockedDecrement(&This->ref);
if (This->ref == 0) if (This->ref == 0)
{ {
ExFreePoolWithTag(This, TAG_PORTCLASS); FreeItem(This, TAG_PORTCLASS);
return 0; return 0;
} }
/* Return new reference count */ /* Return new reference count */
@ -167,8 +180,10 @@ ServiceNotifyRoutine(
IN PVOID SystemArgument1, IN PVOID SystemArgument1,
IN PVOID SystemArgument2) IN PVOID SystemArgument2)
{ {
DPRINT1("ServiceNotifyRoutine entered\n");
IPortWavePciImpl * This = (IPortWavePciImpl*)DeferredContext; IPortWavePciImpl * This = (IPortWavePciImpl*)DeferredContext;
if (This->ServiceGroup) if (This->ServiceGroup && This->bInitialized)
{ {
This->ServiceGroup->lpVtbl->RequestService(This->ServiceGroup); This->ServiceGroup->lpVtbl->RequestService(This->ServiceGroup);
} }
@ -191,6 +206,9 @@ IPortWavePci_fnInit(
NTSTATUS Status; NTSTATUS Status;
IPortWavePciImpl * This = (IPortWavePciImpl*)iface; IPortWavePciImpl * This = (IPortWavePciImpl*)iface;
DPRINT1("IPortWavePci::Init entered with This %p, DeviceObject %p Irp %p UnknownMiniport %p, UnknownAdapter %p ResourceList %p\n",
This, DeviceObject, Irp, UnknownMiniport, UnknownAdapter, ResourceList);
if (This->bInitialized) if (This->bInitialized)
{ {
DPRINT("IPortWaveCyclic_Init called again\n"); DPRINT("IPortWaveCyclic_Init called again\n");
@ -204,13 +222,17 @@ IPortWavePci_fnInit(
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
/* initialize the dpc */
KeInitializeDpc(&This->Dpc, ServiceNotifyRoutine, (PVOID)This);
Status = Miniport->lpVtbl->Init(Miniport, UnknownAdapter, ResourceList, iface, &ServiceGroup); Status = Miniport->lpVtbl->Init(Miniport, UnknownAdapter, ResourceList, iface, &ServiceGroup);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("IMiniportWaveCyclic_Init failed with %x\n", Status); DPRINT("IMiniportWaveCyclic_Init failed with %x\n", Status);
return Status; return Status;
} }
DPRINT1("IPortWaveCyclic_Init Miniport adapter initialized\n");
/* Initialize port object */ /* Initialize port object */
This->Miniport = Miniport; This->Miniport = Miniport;
This->pDeviceObject = DeviceObject; This->pDeviceObject = DeviceObject;
@ -218,8 +240,6 @@ IPortWavePci_fnInit(
This->pResourceList = ResourceList; This->pResourceList = ResourceList;
This->ServiceGroup = ServiceGroup; This->ServiceGroup = ServiceGroup;
/* initialize the dpc */
KeInitializeDpc(&This->Dpc, ServiceNotifyRoutine, (PVOID)This);
/* increment reference on miniport adapter */ /* increment reference on miniport adapter */
Miniport->lpVtbl->AddRef(Miniport); Miniport->lpVtbl->AddRef(Miniport);
@ -232,6 +252,7 @@ IPortWavePci_fnInit(
/* increment reference on service group */ /* increment reference on service group */
ServiceGroup->lpVtbl->AddRef(ServiceGroup); ServiceGroup->lpVtbl->AddRef(ServiceGroup);
DPRINT("IPortWaveCyclic_Init sucessfully initialized\n");
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -249,6 +270,8 @@ IPortWavePci_fnNewRegistryKey(
{ {
IPortWavePciImpl * This = (IPortWavePciImpl*)iface; IPortWavePciImpl * This = (IPortWavePciImpl*)iface;
DPRINT1("IPortWavePci_fnNewRegistryKey entered\n");
if (!This->bInitialized) if (!This->bInitialized)
{ {
DPRINT("IPortWaveCyclic_fnNewRegistryKey called w/o initiazed\n"); DPRINT("IPortWaveCyclic_fnNewRegistryKey called w/o initiazed\n");
@ -277,6 +300,8 @@ IPortWavePci_fnGetDeviceProperty(
{ {
IPortWavePciImpl * This = (IPortWavePciImpl*)iface; IPortWavePciImpl * This = (IPortWavePciImpl*)iface;
DPRINT1("IPortWavePci_fnGetDeviceProperty entered\n");
if (!This->bInitialized) if (!This->bInitialized)
{ {
DPRINT("IPortWaveCyclic_fnNewRegistryKey called w/o initiazed\n"); DPRINT("IPortWaveCyclic_fnNewRegistryKey called w/o initiazed\n");
@ -307,6 +332,8 @@ IPortWavePci_fnNewMasterDmaChannel(
DEVICE_DESCRIPTION DeviceDescription; DEVICE_DESCRIPTION DeviceDescription;
IPortWavePciImpl * This = (IPortWavePciImpl*)iface; IPortWavePciImpl * This = (IPortWavePciImpl*)iface;
DPRINT1("IPortWavePci_fnNewMasterDmaChannel entered\n");
Status = PcDmaMasterDescription(ResourceList, ScatterGather, Dma32BitAddresses, IgnoreCount, Dma64BitAddresses, DmaWidth, DmaSpeed, MaximumLength, DmaPort, &DeviceDescription); Status = PcDmaMasterDescription(ResourceList, ScatterGather, Dma32BitAddresses, IgnoreCount, Dma64BitAddresses, DmaWidth, DmaSpeed, MaximumLength, DmaPort, &DeviceDescription);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
@ -323,6 +350,10 @@ IPortWavePci_fnNotify(
IN PSERVICEGROUP ServiceGroup) IN PSERVICEGROUP ServiceGroup)
{ {
IPortWavePciImpl * This = (IPortWavePciImpl*)iface; IPortWavePciImpl * This = (IPortWavePciImpl*)iface;
DPRINT1("IPortWavePci_fnNotify entered\n");
KeInsertQueueDpc(&This->Dpc, NULL, NULL); KeInsertQueueDpc(&This->Dpc, NULL, NULL);
} }
@ -348,15 +379,15 @@ NewPortWavePci(
{ {
IPortWavePciImpl * This; IPortWavePciImpl * This;
This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IPortWavePciImpl), TAG_PORTCLASS); This = AllocateItem(NonPagedPool, sizeof(IPortWavePciImpl), TAG_PORTCLASS);
if (!This) if (!This)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
RtlZeroMemory(This, sizeof(IPortWavePciImpl));
This->lpVtblServiceSink = &vt_IServiceSink; This->lpVtblServiceSink = &vt_IServiceSink;
This->lpVtbl = &vt_IPortWavePci; This->lpVtbl = &vt_IPortWavePci;
This->ref = 1; This->ref = 1;
*OutPort = (PPORT)&This->lpVtbl; *OutPort = (PPORT)&This->lpVtbl;
DPRINT1("NewPortWavePci %p\n", *OutPort);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -17,6 +17,7 @@
<file>drm_port.c</file> <file>drm_port.c</file>
<file>adapter.c</file> <file>adapter.c</file>
<file>filter_wavecyclic.c</file> <file>filter_wavecyclic.c</file>
<file>guids.c</file>
<file>irp.c</file> <file>irp.c</file>
<file>interrupt.c</file> <file>interrupt.c</file>
<file>drm.c</file> <file>drm.c</file>
@ -25,6 +26,7 @@
<file>resource.c</file> <file>resource.c</file>
<file>registry.c</file> <file>registry.c</file>
<file>service_group.c</file> <file>service_group.c</file>
<file>pool.c</file>
<file>port.c</file> <file>port.c</file>
<file>power.c</file> <file>power.c</file>
<file>port_dmus.c</file> <file>port_dmus.c</file>

View file

@ -1,6 +1,6 @@
#include "private.h" #include "private.h"
const GUID IID_IAdapterPowerManagement;
/* /*
* @implemented * @implemented
@ -17,23 +17,25 @@ PcRegisterAdapterPowerManagement(
PCExtension* DeviceExt; PCExtension* DeviceExt;
IAdapterPowerManagement * pPower; IAdapterPowerManagement * pPower;
DPRINT1("PcRegisterAdapterPowerManagement pUnknown %p pvContext %p\n", pUnknown, pvContext);
if (!pUnknown || !pvContext) if (!pUnknown || !pvContext)
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
Status = pUnknown->lpVtbl->QueryInterface(pUnknown, &IID_IAdapterPowerManagement, (PVOID*)&pPower);
if (!NT_SUCCESS(Status))
return Status;
pDeviceObject = (PDEVICE_OBJECT)pvContext; pDeviceObject = (PDEVICE_OBJECT)pvContext;
DeviceExt = (PCExtension*)pDeviceObject->DeviceExtension; DeviceExt = (PCExtension*)pDeviceObject->DeviceExtension;
if (DeviceExt->AdapterPowerManagement) Status = pUnknown->lpVtbl->QueryInterface(pUnknown, &IID_IAdapterPowerManagement, (PVOID*)&pPower);
if (!NT_SUCCESS(Status))
{ {
pPower->lpVtbl->Release(pPower); DPRINT1("PcRegisterAdapterPowerManagement no IAdapterPowerManagement interface %x\n", Status);
return STATUS_UNSUCCESSFUL; DeviceExt->AdapterPowerManagement = NULL;
return STATUS_SUCCESS;
} }
DeviceExt->AdapterPowerManagement = pPower; DeviceExt->AdapterPowerManagement = pPower;
DPRINT1("PcRegisterAdapterPowerManagement success %x\n", Status);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -17,6 +17,7 @@
#include "interfaces.h" #include "interfaces.h"
#include <ks.h> #include <ks.h>
#include <stdio.h>
#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24)) #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
#define TAG_PORTCLASS TAG('P', 'C', 'L', 'S') #define TAG_PORTCLASS TAG('P', 'C', 'L', 'S')
@ -82,6 +83,18 @@ NTSTATUS NewPortClsVersion(
NTSTATUS NewPortFilterWaveCyclic( NTSTATUS NewPortFilterWaveCyclic(
OUT IPortFilterWaveCyclic ** OutFilter); OUT IPortFilterWaveCyclic ** OutFilter);
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag);
VOID
FreeItem(
IN PVOID Item,
IN ULONG Tag);
NTSTATUS StringFromCLSID(
const CLSID *id,
LPWSTR idstr);
typedef struct typedef struct
{ {
LIST_ENTRY Entry; LIST_ENTRY Entry;

View file

@ -9,13 +9,8 @@ typedef struct
}IRegistryKeyImpl; }IRegistryKeyImpl;
const GUID IID_IRegistryKey;
/* static IRegistryKeyVtbl vt_IRegistryKey;
Basic IUnknown methods
*/
static IRegistryKeyVtbl vt_IRegistryKeyVtbl;
ULONG ULONG
@ -38,14 +33,14 @@ IRegistryKey_fnRelease(
IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface;
_InterlockedDecrement(&This->ref); _InterlockedDecrement(&This->ref);
DPRINT1("IRegistryKey_fnRelease ref %u this %p entered\n", This->ref, This);
if (This->ref == 0) if (This->ref == 0)
{ {
if (This->hKey) if (This->hKey)
{ {
ZwClose(This->hKey); ZwClose(This->hKey);
} }
ExFreePoolWithTag(This, TAG_PORTCLASS); FreeItem(This, TAG_PORTCLASS);
return 0; return 0;
} }
/* Return new reference count */ /* Return new reference count */
@ -60,7 +55,7 @@ IRegistryKey_fnQueryInterface(
OUT PVOID* Output) OUT PVOID* Output)
{ {
IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface;
DPRINT1("IRegistryKey_fnQueryInterface entered\n");
if (IsEqualGUIDAligned(refiid, &IID_IRegistryKey)) if (IsEqualGUIDAligned(refiid, &IID_IRegistryKey))
{ {
*Output = (PVOID)&This->lpVtbl; *Output = (PVOID)&This->lpVtbl;
@ -78,6 +73,7 @@ IRegistryKey_fnDeleteKey(
IN IRegistryKey* iface) IN IRegistryKey* iface)
{ {
IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface;
DPRINT1("IRegistryKey_fnDeleteKey entered\n");
return ZwDeleteKey(This->hKey); return ZwDeleteKey(This->hKey);
} }
@ -92,6 +88,7 @@ IRegistryKey_fnEnumerateKey(
OUT PULONG ResultLength) OUT PULONG ResultLength)
{ {
IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface;
DPRINT1("IRegistryKey_fnEnumerateKey entered\n");
return ZwEnumerateKey(This->hKey, Index, KeyInformationClass, KeyInformation, Length, ResultLength); return ZwEnumerateKey(This->hKey, Index, KeyInformationClass, KeyInformation, Length, ResultLength);
} }
@ -106,6 +103,7 @@ IRegistryKey_fnEnumerateKeyValue(
OUT PULONG ResultLength) OUT PULONG ResultLength)
{ {
IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface;
DPRINT1("IRegistryKey_fnEnumerateKeyValue entered\n");
return ZwEnumerateValueKey(This->hKey, Index, KeyValueInformationClass, KeyValueInformation, Length, ResultLength); return ZwEnumerateValueKey(This->hKey, Index, KeyValueInformationClass, KeyValueInformation, Length, ResultLength);
} }
@ -125,13 +123,15 @@ IRegistryKey_fnNewSubKey(
HANDLE hKey; HANDLE hKey;
IRegistryKeyImpl * NewThis, *This = (IRegistryKeyImpl*)iface; IRegistryKeyImpl * NewThis, *This = (IRegistryKeyImpl*)iface;
DPRINT1("IRegistryKey_fnNewSubKey entered\n");
InitializeObjectAttributes(&Attributes, SubKeyName, 0, This->hKey, NULL); InitializeObjectAttributes(&Attributes, SubKeyName, 0, This->hKey, NULL);
Status = ZwCreateKey(&hKey, KEY_READ | KEY_WRITE, &Attributes, 0, NULL, 0, Disposition); Status = ZwCreateKey(&hKey, KEY_READ | KEY_WRITE, &Attributes, 0, NULL, 0, Disposition);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
return Status; return Status;
NewThis = ExAllocatePoolWithTag(NonPagedPool, sizeof(IRegistryKeyImpl), TAG_PORTCLASS); NewThis = AllocateItem(NonPagedPool, sizeof(IRegistryKeyImpl), TAG_PORTCLASS);
if (!NewThis) if (!NewThis)
{ {
ZwClose(hKey); ZwClose(hKey);
@ -140,8 +140,11 @@ IRegistryKey_fnNewSubKey(
NewThis->hKey = hKey; NewThis->hKey = hKey;
NewThis->ref = 1; NewThis->ref = 1;
NewThis->lpVtbl = &vt_IRegistryKeyVtbl; NewThis->lpVtbl = &vt_IRegistryKey;
*RegistrySubKey = (PREGISTRYKEY)&This->lpVtbl; *RegistrySubKey = (PREGISTRYKEY)&NewThis->lpVtbl;
DPRINT1("IRegistryKey_fnNewSubKey RESULT %p\n", *RegistrySubKey );
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -155,6 +158,7 @@ IRegistryKey_fnQueryKey(
OUT PULONG ResultLength) OUT PULONG ResultLength)
{ {
IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface;
DPRINT1("IRegistryKey_fnQueryKey entered\n");
return ZwQueryKey(This->hKey, KeyInformationClass, KeyInformation, Length, ResultLength); return ZwQueryKey(This->hKey, KeyInformationClass, KeyInformation, Length, ResultLength);
} }
@ -166,7 +170,7 @@ IRegistryKey_fnQueryRegistryValues(
IN PVOID Context OPTIONAL) IN PVOID Context OPTIONAL)
{ {
IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface;
DPRINT("IRegistryKey_QueryRegistryValues: This %p\n", This); DPRINT1("IRegistryKey_QueryRegistryValues: This %p\n", This);
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -181,6 +185,7 @@ IRegistryKey_fnQueryValueKey(
OUT PULONG ResultLength) OUT PULONG ResultLength)
{ {
IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface;
DPRINT1("IRegistryKey_fnQueryValueKey entered %p value %wZ\n", This, ValueName);
return ZwQueryValueKey(This->hKey, ValueName, KeyValueInformationClass, KeyValueInformation, Length, ResultLength); return ZwQueryValueKey(This->hKey, ValueName, KeyValueInformationClass, KeyValueInformation, Length, ResultLength);
} }
@ -195,6 +200,7 @@ IRegistryKey_fnSetValueKey(
) )
{ {
IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface;
DPRINT1("IRegistryKey_fnSetValueKey entered\n");
return ZwSetValueKey(This->hKey, ValueName, 0, Type, Data, DataSize); return ZwSetValueKey(This->hKey, ValueName, 0, Type, Data, DataSize);
} }
@ -233,6 +239,9 @@ PcNewRegistryKey(
HANDLE hHandle; HANDLE hHandle;
NTSTATUS Status = STATUS_UNSUCCESSFUL; NTSTATUS Status = STATUS_UNSUCCESSFUL;
IRegistryKeyImpl * This; IRegistryKeyImpl * This;
PCExtension* portcls_ext;
DPRINT1("PcNewRegistryKey entered\n");
if (!OutRegistryKey) if (!OutRegistryKey)
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
@ -246,28 +255,38 @@ PcNewRegistryKey(
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
/* check for the key type */
if (RegistryKeyType == GeneralRegistryKey) if (RegistryKeyType == GeneralRegistryKey)
{ {
/* do we have the required object attributes */
if (!ObjectAttributes) if (!ObjectAttributes)
{
/* object attributes is mandatory */
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
}
/* try to open the key */
Status = ZwOpenKey(&hHandle, DesiredAccess, ObjectAttributes); Status = ZwOpenKey(&hHandle, DesiredAccess, ObjectAttributes);
} }
else if (RegistryKeyType == DeviceRegistryKey || else if (RegistryKeyType == DeviceRegistryKey ||
RegistryKeyType == DriverRegistryKey || RegistryKeyType == DriverRegistryKey ||
RegistryKeyType == HwProfileRegistryKey) RegistryKeyType == HwProfileRegistryKey)
{ {
/* check for HwProfileRegistryKey case */
if (RegistryKeyType == HwProfileRegistryKey) if (RegistryKeyType == HwProfileRegistryKey)
{ {
/* IoOpenDeviceRegistryKey used different constant */ /* IoOpenDeviceRegistryKey used different constant */
RegistryKeyType = PLUGPLAY_REGKEY_CURRENT_HWPROFILE; RegistryKeyType = PLUGPLAY_REGKEY_CURRENT_HWPROFILE;
} }
Status = IoOpenDeviceRegistryKey(DeviceObject, RegistryKeyType, DesiredAccess, &hHandle); /* obtain the new device extension */
portcls_ext = (PCExtension*) ((PDEVICE_OBJECT)DeviceObject)->DeviceExtension;
Status = IoOpenDeviceRegistryKey(portcls_ext->PhysicalDeviceObject, RegistryKeyType, DesiredAccess, &hHandle);
} }
else if (RegistryKeyType == DeviceInterfaceRegistryKey) else if (RegistryKeyType == DeviceInterfaceRegistryKey)
{ {
/* FIXME */ /* FIXME */
DPRINT1("fixme\n");
} }
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
@ -275,7 +294,7 @@ PcNewRegistryKey(
return Status; return Status;
} }
This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IRegistryKeyImpl), TAG_PORTCLASS); This = AllocateItem(NonPagedPool, sizeof(IRegistryKeyImpl), TAG_PORTCLASS);
if (!This) if (!This)
{ {
ZwClose(hHandle); ZwClose(hHandle);
@ -287,6 +306,7 @@ PcNewRegistryKey(
This->ref = 1; This->ref = 1;
*OutRegistryKey = (PREGISTRYKEY)&This->lpVtbl; *OutRegistryKey = (PREGISTRYKEY)&This->lpVtbl;
DPRINT1("PcNewRegistryKey result %p\n", *OutRegistryKey);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -24,7 +24,7 @@ typedef struct CResourceList
PCM_RESOURCE_LIST UntranslatedResourceList; PCM_RESOURCE_LIST UntranslatedResourceList;
} IResourceListImpl; } IResourceListImpl;
const GUID IID_IResourceList;
/* /*
Basic IUnknown methods Basic IUnknown methods
@ -41,7 +41,7 @@ IResourceList_fnQueryInterface(
if (IsEqualGUIDAligned(refiid, &IID_IResourceList)) if (IsEqualGUIDAligned(refiid, &IID_IResourceList))
{ {
*Output = &This->lpVtbl; *Output = &This->lpVtbl;
_InterlockedIncrement(&This->ref); InterlockedIncrement(&This->ref);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
@ -54,7 +54,7 @@ IResourceList_fnAddRef(
{ {
IResourceListImpl * This = (IResourceListImpl*)iface; IResourceListImpl * This = (IResourceListImpl*)iface;
return _InterlockedIncrement(&This->ref); return InterlockedIncrement(&This->ref);
} }
ULONG ULONG
@ -64,13 +64,15 @@ IResourceList_fnRelease(
{ {
IResourceListImpl * This = (IResourceListImpl*)iface; IResourceListImpl * This = (IResourceListImpl*)iface;
_InterlockedDecrement(&This->ref); InterlockedDecrement(&This->ref);
DPRINT("IResourceList_fnRelease %p ref %x\n", This, This->ref);
if (This->ref == 0) if (This->ref == 0)
{ {
ExFreePool(This->TranslatedResourceList); FreeItem(This->TranslatedResourceList, TAG_PORTCLASS);
ExFreePool(This->UntranslatedResourceList); FreeItem(This->UntranslatedResourceList, TAG_PORTCLASS);
ExFreePoolWithTag(This, TAG_PORTCLASS); FreeItem(This, TAG_PORTCLASS);
return 0; return 0;
} }
/* Return new reference count */ /* Return new reference count */
@ -187,15 +189,15 @@ IResourceList_fnAddEntry(
IResourceListImpl * This = (IResourceListImpl*)iface; IResourceListImpl * This = (IResourceListImpl*)iface;
NewTranslatedSize = sizeof(CM_RESOURCE_LIST) + This->TranslatedResourceList[0].List->PartialResourceList.Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); NewTranslatedSize = sizeof(CM_RESOURCE_LIST) + This->TranslatedResourceList[0].List->PartialResourceList.Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
NewTranslatedResources = ExAllocatePoolWithTag(This->PoolType, NewTranslatedSize, TAG_PORTCLASS); NewTranslatedResources = AllocateItem(This->PoolType, NewTranslatedSize, TAG_PORTCLASS);
if (!NewTranslatedResources) if (!NewTranslatedResources)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
NewUntranslatedSize = sizeof(CM_RESOURCE_LIST) + This->UntranslatedResourceList[0].List->PartialResourceList.Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); NewUntranslatedSize = sizeof(CM_RESOURCE_LIST) + This->UntranslatedResourceList[0].List->PartialResourceList.Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
NewUntranslatedResources = ExAllocatePoolWithTag(This->PoolType, NewUntranslatedSize, TAG_PORTCLASS); NewUntranslatedResources = AllocateItem(This->PoolType, NewUntranslatedSize, TAG_PORTCLASS);
if (!NewUntranslatedResources) if (!NewUntranslatedResources)
{ {
ExFreePoolWithTag(NewTranslatedResources, TAG_PORTCLASS); FreeItem(NewTranslatedResources, TAG_PORTCLASS);
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
@ -205,8 +207,8 @@ IResourceList_fnAddEntry(
RtlCopyMemory(NewUntranslatedResources, This->UntranslatedResourceList, sizeof(CM_RESOURCE_LIST) + (This->UntranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)); RtlCopyMemory(NewUntranslatedResources, This->UntranslatedResourceList, sizeof(CM_RESOURCE_LIST) + (This->UntranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
RtlCopyMemory(&NewUntranslatedResources->List[0].PartialResourceList.PartialDescriptors[This->UntranslatedResourceList[0].List->PartialResourceList.Count], Untranslated, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)); RtlCopyMemory(&NewUntranslatedResources->List[0].PartialResourceList.PartialDescriptors[This->UntranslatedResourceList[0].List->PartialResourceList.Count], Untranslated, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
ExFreePoolWithTag(This->TranslatedResourceList, TAG_PORTCLASS); FreeItem(This->TranslatedResourceList, TAG_PORTCLASS);
ExFreePoolWithTag(This->UntranslatedResourceList, TAG_PORTCLASS); FreeItem(This->UntranslatedResourceList, TAG_PORTCLASS);
This->UntranslatedResourceList = NewUntranslatedResources; This->UntranslatedResourceList = NewUntranslatedResources;
This->TranslatedResourceList = NewTranslatedResources; This->TranslatedResourceList = NewTranslatedResources;
@ -235,14 +237,14 @@ IResourceList_fnAddEntryFromParent(
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
NewTranslatedSize = sizeof(CM_RESOURCE_LIST) + This->TranslatedResourceList[0].List->PartialResourceList.Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); NewTranslatedSize = sizeof(CM_RESOURCE_LIST) + This->TranslatedResourceList[0].List->PartialResourceList.Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
NewTranslatedResources = ExAllocatePoolWithTag(This->PoolType, NewTranslatedSize, TAG_PORTCLASS); NewTranslatedResources = AllocateItem(This->PoolType, NewTranslatedSize, TAG_PORTCLASS);
if (!NewTranslatedResources) if (!NewTranslatedResources)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
RtlCopyMemory(NewTranslatedResources, This->TranslatedResourceList, sizeof(CM_RESOURCE_LIST) + (This->TranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)); RtlCopyMemory(NewTranslatedResources, This->TranslatedResourceList, sizeof(CM_RESOURCE_LIST) + (This->TranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
RtlCopyMemory(&NewTranslatedResources->List[0].PartialResourceList.PartialDescriptors[This->TranslatedResourceList[0].List->PartialResourceList.Count], Translated, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)); RtlCopyMemory(&NewTranslatedResources->List[0].PartialResourceList.PartialDescriptors[This->TranslatedResourceList[0].List->PartialResourceList.Count], Translated, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
ExFreePoolWithTag(This->TranslatedResourceList, TAG_PORTCLASS); FreeItem(This->TranslatedResourceList, TAG_PORTCLASS);
This->TranslatedResourceList = NewTranslatedResources; This->TranslatedResourceList = NewTranslatedResources;
NewTranslatedResources->List[0].PartialResourceList.Count++; NewTranslatedResources->List[0].PartialResourceList.Count++;
@ -308,32 +310,32 @@ PcNewResourceList(
/* TODO: Validate parameters */ /* TODO: Validate parameters */
DPRINT("PcNewResourceList\n"); DPRINT1("PcNewResourceList\n");
NewList = ExAllocatePoolWithTag(PoolType, sizeof(IResourceListImpl), TAG_PORTCLASS); NewList = AllocateItem(PoolType, sizeof(IResourceListImpl), TAG_PORTCLASS);
if (!NewList) if (!NewList)
{ {
DPRINT("ExAllocatePoolWithTag failed\n"); DPRINT("AllocateItem failed\n");
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
/* Initialize */ /* Initialize */
NewTranslatedSize = sizeof(CM_RESOURCE_LIST) + (TranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); NewTranslatedSize = sizeof(CM_RESOURCE_LIST) + (TranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
NewTranslatedResources = ExAllocatePoolWithTag(PoolType, NewTranslatedSize, TAG_PORTCLASS); NewTranslatedResources = AllocateItem(PoolType, NewTranslatedSize, TAG_PORTCLASS);
if (!NewTranslatedResources) if (!NewTranslatedResources)
{ {
ExFreePoolWithTag(NewList, TAG_PORTCLASS); FreeItem(NewList, TAG_PORTCLASS);
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
NewUntranslatedSize = sizeof(CM_RESOURCE_LIST) + (UntranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); NewUntranslatedSize = sizeof(CM_RESOURCE_LIST) + (UntranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
NewUntranslatedResources = ExAllocatePoolWithTag(PoolType, NewUntranslatedSize, TAG_PORTCLASS); NewUntranslatedResources = AllocateItem(PoolType, NewUntranslatedSize, TAG_PORTCLASS);
if (!NewUntranslatedResources) if (!NewUntranslatedResources)
{ {
ExFreePoolWithTag(NewList, TAG_PORTCLASS); FreeItem(NewList, TAG_PORTCLASS);
ExFreePoolWithTag(NewTranslatedResources, TAG_PORTCLASS); FreeItem(NewTranslatedResources, TAG_PORTCLASS);
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
@ -363,11 +365,12 @@ PcNewResourceSublist(
{ {
IResourceListImpl* NewList, *Parent; IResourceListImpl* NewList, *Parent;
if (!OuterUnknown || !ParentList || !MaximumEntries) if (!OutResourceList || !ParentList || !MaximumEntries)
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
Parent = (IResourceListImpl*)ParentList; Parent = (IResourceListImpl*)ParentList;
DPRINT1("PcNewResourceSublist entered\n");
if (!Parent->TranslatedResourceList->List->PartialResourceList.Count || if (!Parent->TranslatedResourceList->List->PartialResourceList.Count ||
!Parent->UntranslatedResourceList->List->PartialResourceList.Count) !Parent->UntranslatedResourceList->List->PartialResourceList.Count)
@ -376,22 +379,22 @@ PcNewResourceSublist(
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
NewList = ExAllocatePoolWithTag(PoolType, sizeof(IResourceListImpl), TAG_PORTCLASS); NewList = AllocateItem(PoolType, sizeof(IResourceListImpl), TAG_PORTCLASS);
if (!NewList) if (!NewList)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
NewList->TranslatedResourceList = ExAllocatePoolWithTag(PoolType, sizeof(CM_RESOURCE_LIST), TAG_PORTCLASS); NewList->TranslatedResourceList = AllocateItem(PoolType, sizeof(CM_RESOURCE_LIST), TAG_PORTCLASS);
if (!NewList->TranslatedResourceList) if (!NewList->TranslatedResourceList)
{ {
ExFreePoolWithTag(NewList, TAG_PORTCLASS); FreeItem(NewList, TAG_PORTCLASS);
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
NewList->UntranslatedResourceList = ExAllocatePoolWithTag(PoolType, sizeof(CM_RESOURCE_LIST), TAG_PORTCLASS); NewList->UntranslatedResourceList = AllocateItem(PoolType, sizeof(CM_RESOURCE_LIST), TAG_PORTCLASS);
if (!NewList->UntranslatedResourceList) if (!NewList->UntranslatedResourceList)
{ {
ExFreePoolWithTag(NewList->TranslatedResourceList, TAG_PORTCLASS); FreeItem(NewList->TranslatedResourceList, TAG_PORTCLASS);
ExFreePoolWithTag(NewList, TAG_PORTCLASS); FreeItem(NewList, TAG_PORTCLASS);
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
@ -409,5 +412,6 @@ PcNewResourceSublist(
*OutResourceList = (IResourceList*)&NewList->lpVtbl; *OutResourceList = (IResourceList*)&NewList->lpVtbl;
DPRINT1("PcNewResourceSublist OutResourceList %p OuterUnknown %p ParentList %p\n", *OutResourceList, OuterUnknown, ParentList);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -21,8 +21,7 @@ typedef struct
}IServiceGroupImpl; }IServiceGroupImpl;
const GUID IID_IServiceGroup;
const GUID IID_IServiceSink;
//--------------------------------------------------------------- //---------------------------------------------------------------
// IUnknown methods // IUnknown methods
@ -75,11 +74,11 @@ IServiceGroup_fnRelease(
CurEntry = RemoveHeadList(&This->ServiceSinkHead); CurEntry = RemoveHeadList(&This->ServiceSinkHead);
Entry = CONTAINING_RECORD(CurEntry, GROUP_ENTRY, Entry); Entry = CONTAINING_RECORD(CurEntry, GROUP_ENTRY, Entry);
Entry->pServiceSink->lpVtbl->Release(Entry->pServiceSink); Entry->pServiceSink->lpVtbl->Release(Entry->pServiceSink);
ExFreePoolWithTag(Entry, TAG_PORTCLASS); FreeItem(Entry, TAG_PORTCLASS);
} }
KeWaitForSingleObject(&This->DpcEvent, Executive, KernelMode, FALSE, NULL); KeWaitForSingleObject(&This->DpcEvent, Executive, KernelMode, FALSE, NULL);
KeCancelTimer(&This->Timer); KeCancelTimer(&This->Timer);
ExFreePoolWithTag(This, TAG_PORTCLASS); FreeItem(This, TAG_PORTCLASS);
return 0; return 0;
} }
/* Return new reference count */ /* Return new reference count */
@ -123,7 +122,7 @@ IServiceGroup_fnAddMember(
PGROUP_ENTRY Entry; PGROUP_ENTRY Entry;
IServiceGroupImpl * This = (IServiceGroupImpl*)iface; IServiceGroupImpl * This = (IServiceGroupImpl*)iface;
Entry = ExAllocatePoolWithTag(NonPagedPool, sizeof(GROUP_ENTRY), TAG_PORTCLASS); Entry = AllocateItem(NonPagedPool, sizeof(GROUP_ENTRY), TAG_PORTCLASS);
if (!Entry) if (!Entry)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
@ -159,7 +158,7 @@ IServiceGroup_fnRemoveMember(
{ {
RemoveEntryList(&Entry->Entry); RemoveEntryList(&Entry->Entry);
pServiceSink->lpVtbl->Release(pServiceSink); pServiceSink->lpVtbl->Release(pServiceSink);
ExFreePoolWithTag(Entry, TAG_PORTCLASS); FreeItem(Entry, TAG_PORTCLASS);
return; return;
} }
CurEntry = CurEntry->Flink; CurEntry = CurEntry->Flink;
@ -253,14 +252,15 @@ PcNewServiceGroup(
{ {
IServiceGroupImpl * This; IServiceGroupImpl * This;
This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IServiceGroupImpl), TAG_PORTCLASS); DPRINT1("PcNewServiceGroup entered\n");
This = AllocateItem(NonPagedPool, sizeof(IServiceGroupImpl), TAG_PORTCLASS);
if (!This) if (!This)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
This->lpVtbl = &vt_IServiceGroup; This->lpVtbl = &vt_IServiceGroup;
This->ref = 1; This->ref = 1;
InitializeListHead(&This->ServiceSinkHead); InitializeListHead(&This->ServiceSinkHead);
This->Initialized = FALSE;
*OutServiceGroup = (PSERVICEGROUP)&This->lpVtbl; *OutServiceGroup = (PSERVICEGROUP)&This->lpVtbl;
return STATUS_SUCCESS; return STATUS_SUCCESS;

View file

@ -7,7 +7,7 @@ typedef struct
LONG ref; LONG ref;
}IPortClsVersionImpl; }IPortClsVersionImpl;
const GUID IID_IPortClsVersion;
//--------------------------------------------------------------- //---------------------------------------------------------------
// IPortClsVersion interface functions // IPortClsVersion interface functions
@ -53,7 +53,7 @@ IPortClsVersion_fnRelease(
if (This->ref == 0) if (This->ref == 0)
{ {
ExFreePoolWithTag(This, TAG_PORTCLASS); FreeItem(This, TAG_PORTCLASS);
return 0; return 0;
} }
/* Return new reference count */ /* Return new reference count */
@ -80,7 +80,7 @@ static IPortClsVersionVtbl vt_PortClsVersion =
NTSTATUS NewPortClsVersion( NTSTATUS NewPortClsVersion(
OUT PPORTCLSVERSION * OutVersion) OUT PPORTCLSVERSION * OutVersion)
{ {
IPortClsVersionImpl * This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IPortClsVersionImpl), TAG_PORTCLASS); IPortClsVersionImpl * This = AllocateItem(NonPagedPool, sizeof(IPortClsVersionImpl), TAG_PORTCLASS);
if (!This) if (!This)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;