ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

unregister.cpp
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:       See COPYING in the top level directory
00003  * PROJECT:         ReactOS Kernel Streaming
00004  * FILE:            drivers/wdm/audio/backpln/portcls/unregister.cpp
00005  * PURPOSE:         Unregisters a subdevice
00006  * PROGRAMMER:      Johannes Anderwald
00007  */
00008 
00009 #include "private.hpp"
00010 
00011 class CUnregisterSubdevice : public IUnregisterSubdevice
00012 {
00013 public:
00014     STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
00015 
00016     STDMETHODIMP_(ULONG) AddRef()
00017     {
00018         InterlockedIncrement(&m_Ref);
00019         return m_Ref;
00020     }
00021     STDMETHODIMP_(ULONG) Release()
00022     {
00023         InterlockedDecrement(&m_Ref);
00024 
00025         if (!m_Ref)
00026         {
00027             delete this;
00028             return 0;
00029         }
00030         return m_Ref;
00031     }
00032 
00033 
00034     IMP_IUnregisterSubdevice;
00035 
00036     CUnregisterSubdevice(IUnknown * OuterUnknown) : m_Ref(0) {}
00037     virtual ~CUnregisterSubdevice(){}
00038 
00039 protected:
00040     LONG m_Ref;
00041 
00042 };
00043 
00044 NTSTATUS
00045 NTAPI
00046 CUnregisterSubdevice::QueryInterface(
00047     IN  REFIID refiid,
00048     OUT PVOID* Output)
00049 {
00050     UNICODE_STRING GuidString;
00051 
00052     if (IsEqualGUIDAligned(refiid, IID_IUnregisterSubdevice) || 
00053         IsEqualGUIDAligned(refiid, IID_IUnknown))
00054     {
00055         *Output = PVOID(PUNREGISTERSUBDEVICE(this));
00056         PUNKNOWN(*Output)->AddRef();
00057         return STATUS_SUCCESS;
00058     }
00059 
00060     if (RtlStringFromGUID(refiid, &GuidString) == STATUS_SUCCESS)
00061     {
00062         DPRINT1("IPortWaveCyclic_fnQueryInterface no interface!!! iface %S\n", GuidString.Buffer);
00063         RtlFreeUnicodeString(&GuidString);
00064     }
00065 
00066     return STATUS_UNSUCCESSFUL;
00067 }
00068 
00069 NTSTATUS
00070 NTAPI
00071 CUnregisterSubdevice::UnregisterSubdevice(
00072     IN PDEVICE_OBJECT  DeviceObject,
00073     IN PUNKNOWN  Unknown)
00074 {
00075     PPCLASS_DEVICE_EXTENSION DeviceExtension;
00076     PLIST_ENTRY Entry;
00077     PSYMBOLICLINK_ENTRY SymLinkEntry;
00078     PSUBDEVICE_DESCRIPTOR SubDeviceDescriptor;
00079     ISubdevice *SubDevice;
00080     ULONG Index;
00081     NTSTATUS Status;
00082 
00083     PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
00084 
00085     DeviceExtension = (PPCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
00086     PC_ASSERT(DeviceExtension);
00087 
00088     // look up our undocumented interface
00089     Status = Unknown->QueryInterface(IID_ISubdevice, (LPVOID*)&SubDevice);
00090     if (!NT_SUCCESS(Status))
00091     {
00092         DPRINT("No ISubdevice interface\n");
00093         // the provided port driver doesnt support ISubdevice
00094         return STATUS_INVALID_PARAMETER;
00095     }
00096 
00097     Status = SubDevice->GetDescriptor(&SubDeviceDescriptor);
00098     if (!NT_SUCCESS(Status))
00099     {
00100         DPRINT("Failed to retrieve subdevice descriptor %x\n", Status);
00101         // the provided port driver doesnt support ISubdevice
00102         return STATUS_INVALID_PARAMETER;
00103     }
00104 
00105     // loop our create items and disable the create handler
00106     for(Index = 0; Index < DeviceExtension->MaxSubDevices; Index++)
00107     {
00108         if (!RtlCompareUnicodeString(&SubDeviceDescriptor->RefString, &DeviceExtension->CreateItems[Index].ObjectClass, TRUE))
00109         {
00110             DeviceExtension->CreateItems[Index].Create = NULL;
00111             RtlInitUnicodeString(&DeviceExtension->CreateItems[Index].ObjectClass, NULL);
00112             break;
00113         }
00114     }
00115 
00116     // now unregister device interfaces
00117     while(!IsListEmpty(&SubDeviceDescriptor->SymbolicLinkList))
00118     {
00119         // remove entry
00120         Entry = RemoveHeadList(&SubDeviceDescriptor->SymbolicLinkList);
00121         // get symlink entry
00122         SymLinkEntry = (PSYMBOLICLINK_ENTRY)CONTAINING_RECORD(Entry, SYMBOLICLINK_ENTRY, Entry);
00123 
00124         // unregister device interface
00125         IoSetDeviceInterfaceState(&SymLinkEntry->SymbolicLink, FALSE);
00126         // free symbolic link
00127         RtlFreeUnicodeString(&SymLinkEntry->SymbolicLink);
00128         // free sym entry
00129         FreeItem(SymLinkEntry, TAG_PORTCLASS);
00130     }
00131 
00132     return STATUS_SUCCESS;
00133 }
00134 
00135 NTSTATUS
00136 NTAPI
00137 NewIUnregisterSubdevice(
00138     OUT PUNREGISTERSUBDEVICE *OutDevice)
00139 {
00140     NTSTATUS Status;
00141     CUnregisterSubdevice * This = new(NonPagedPool, TAG_PORTCLASS) CUnregisterSubdevice(NULL);
00142     if (!This)
00143         return STATUS_INSUFFICIENT_RESOURCES;
00144 
00145     Status = This->QueryInterface(IID_IUnregisterSubdevice, (PVOID*)OutDevice);
00146     if (!NT_SUCCESS(Status))
00147     {
00148         delete This;
00149         return Status;
00150     }
00151 
00152     *OutDevice = (PUNREGISTERSUBDEVICE)This;
00153     return Status;
00154 }

Generated on Sun May 27 2012 04:28:37 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.