ReactOS  0.4.15-dev-2144-g2282205
fxrelateddevicelist.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation. All rights reserved.
4 
5 Module Name:
6 
7  FxDependentList.cpp
8 
9 Abstract:
10  This object derives from the transactioned list and provides a unique
11  object check during the addition of an item.
12 
13 Author:
14 
15 
16 
17 Environment:
18 
19  Kernel mode only
20 
21 Revision History:
22 
23 --*/
24 
25 #include "fxsupportpch.hpp"
26 
30  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
32  )
33 {
34  return FxSpinLockTransactionedList::Add(FxDriverGlobals,
35  &Entry->m_TransactionedEntry);
36 }
37 
38 VOID
40  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
42  )
43 {
44  SearchForAndRemove(FxDriverGlobals, (PVOID) Device);
45 }
46 
51  )
52 {
53  FxTransactionedEntry *pReturn, *pEntry;
54 
55  if (Entry == NULL) {
56  pEntry = NULL;
57  }
58  else {
59  pEntry = &Entry->m_TransactionedEntry;
60  }
61 
63 
64  if (pReturn != NULL) {
65  return CONTAINING_RECORD(pReturn, FxRelatedDevice, m_TransactionedEntry);
66  }
67  else {
68  return NULL;
69  }
70 }
71 
75  __in FxTransactionedEntry *NewEntry
76  )
77 {
78  FxRelatedDevice* pNew, *pInList;
81 
82  pNew = CONTAINING_RECORD(NewEntry, FxRelatedDevice, m_TransactionedEntry);
83 
84  pEntry = NULL;
85 
86  //
87  // Go over the transactions first because the device could be in the real
88  // list with a transaction to remove it, so we catch first here instead
89  // of adding complexity to the iteration of the already inserted list.
90  //
93  ple = ple->Flink) {
95  pInList = CONTAINING_RECORD(pEntry, FxRelatedDevice, m_TransactionedEntry);
96 
97  if (pInList->m_DeviceObject == pNew->m_DeviceObject) {
98  if (pEntry->GetTransactionAction() == FxTransactionActionAdd) {
99  //
100  // An additional add, failure
101  //
103  }
104 
105 
106  // Removal is OK b/c our add will be right behind it
107  //
108  ASSERT(pEntry->GetTransactionAction() == FxTransactionActionRemove);
109  return STATUS_SUCCESS;
110  }
111  }
112 
113  pEntry = NULL;
114  while ((pEntry = FxSpinLockTransactionedList::GetNextEntryLocked(pEntry)) != NULL) { // __super call
115  pInList = CONTAINING_RECORD(pEntry, FxRelatedDevice, m_TransactionedEntry);
116 
117  if (pInList->m_DeviceObject == pNew->m_DeviceObject) {
119  }
120  }
121 
122  return STATUS_SUCCESS;
123 }
124 
125 BOOLEAN
128  __in PVOID Data
129  )
130 {
131  FxRelatedDevice *pRelated;
132 
133  pRelated = CONTAINING_RECORD(Entry, FxRelatedDevice, m_TransactionedEntry);
134 
135  return pRelated->GetDevice() == (PDEVICE_OBJECT) Data ? TRUE : FALSE;
136 }
137 
138 VOID
141  )
142 {
143  FxRelatedDevice *pRelated;
144 
145  pRelated = CONTAINING_RECORD(Entry, FxRelatedDevice, m_TransactionedEntry);
146 
147  if (pRelated->m_State == RelatedDeviceStateReportedPresent) {
149  }
150 }
#define _Must_inspect_result_
Definition: no_sal2.h:62
#define __in_opt
Definition: dbghelp.h:38
#define TRUE
Definition: types.h:120
struct _DEVICE_OBJECT * PDEVICE_OBJECT
LONG NTSTATUS
Definition: precomp.h:26
VOID SearchForAndRemove(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PVOID EntryData)
VOID Remove(__in PFX_DRIVER_GLOBALS Globals, __in MdDeviceObject Device)
NTSTATUS Add(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxTransactionedEntry *Entry)
_Must_inspect_result_ FxTransactionedEntry * GetNextEntryLocked(__in_opt FxTransactionedEntry *Entry)
PSINGLE_LIST_ENTRY ple
virtual BOOLEAN Compare(__in FxTransactionedEntry *Entry, __in PVOID Data)
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
MdDeviceObject m_DeviceObject
_Must_inspect_result_ NTSTATUS Add(__in PFX_DRIVER_GLOBALS Globals, __inout FxRelatedDevice *Entry)
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define ASSERT(a)
Definition: mode.c:45
MdDeviceObject GetDevice(VOID)
_Must_inspect_result_ FxRelatedDevice * GetNextEntry(__in_opt FxRelatedDevice *Entry)
_Must_inspect_result_ FxTransactionedEntry * GetNextEntry(__in_opt FxTransactionedEntry *Entry)
FxRelatedDeviceState m_State
#define __inout
Definition: dbghelp.h:50
Definition: typedefs.h:119
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define NULL
Definition: types.h:112
virtual _Must_inspect_result_ NTSTATUS ProcessAdd(__in FxTransactionedEntry *Entry)
static FxTransactionedEntry * _FromEntry(__in PLIST_ENTRY Entry)
virtual VOID EntryRemoved(__in FxTransactionedEntry *Entry)
#define STATUS_SUCCESS
Definition: shellext.h:65
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define __in
Definition: dbghelp.h:35
base of all file and directory entries
Definition: entries.h:82
#define STATUS_DUPLICATE_OBJECTID
Definition: ntstatus.h:686