1 /*++ 2 3 Copyright (c) Microsoft Corporation 4 5 Module Name: 6 7 FxDeviceInterface.cpp 8 9 Abstract: 10 11 This module implements the device interface object. 12 13 Author: 14 15 16 17 Environment: 18 19 Both kernel and user mode 20 21 Revision History: 22 23 --*/ 24 25 #include "fxsupportpch.hpp" 26 27 extern "C" { 28 // #include "FxDeviceInterface.tmh" 29 } 30 31 FxDeviceInterface::FxDeviceInterface( 32 ) 33 /*++ 34 35 Routine Description: 36 Constructor for the object. Initializes all fields 37 38 Arguments: 39 None 40 41 Return Value: 42 None 43 44 --*/ 45 { 46 RtlZeroMemory(&m_InterfaceClassGUID, sizeof(m_InterfaceClassGUID)); 47 48 RtlZeroMemory(&m_SymbolicLinkName, sizeof(m_SymbolicLinkName)); 49 RtlZeroMemory(&m_ReferenceString, sizeof(m_ReferenceString)); 50 51 m_Entry.Next = NULL; 52 53 m_State = FALSE; 54 55 #if (FX_CORE_MODE == FX_CORE_USER_MODE) 56 m_Device = NULL; 57 #endif 58 59 } 60 61 FxDeviceInterface::~FxDeviceInterface() 62 /*++ 63 64 Routine Description: 65 Destructor for FxDeviceInterface. Cleans up any allocations previously 66 allocated. 67 68 Arguments: 69 None 70 71 Return Value: 72 None 73 74 --*/ 75 { 76 // the device interface should be off now 77 ASSERT(m_State == FALSE); 78 79 // should no longer be in any list 80 ASSERT(m_Entry.Next == NULL); 81 82 if (m_ReferenceString.Buffer != NULL) { 83 FxPoolFree(m_ReferenceString.Buffer); 84 RtlZeroMemory(&m_ReferenceString, sizeof(m_ReferenceString)); 85 } 86 87 if (m_SymbolicLinkName.Buffer != NULL) { 88 RtlFreeUnicodeString(&m_SymbolicLinkName); 89 } 90 } 91 92 _Must_inspect_result_ 93 NTSTATUS 94 FxDeviceInterface::Initialize( 95 __in PFX_DRIVER_GLOBALS FxDriverGlobals, 96 __in CONST GUID* InterfaceGUID, 97 __in_opt PCUNICODE_STRING ReferenceString 98 ) 99 /*++ 100 101 Routine Description: 102 Initializes the object with the interface GUID and optional reference string 103 104 Arguments: 105 InterfaceGUID - GUID describing the interface 106 107 ReferenceString - string used to differentiate between 2 interfaces on the 108 same PDO 109 110 Return Value: 111 STATUS_SUCCESS or STATUS_INSUFFICIENT_RESOURCES 112 113 --*/ 114 { 115 RtlCopyMemory(&m_InterfaceClassGUID, InterfaceGUID, sizeof(GUID)); 116 117 if (ReferenceString != NULL) { 118 return FxDuplicateUnicodeString(FxDriverGlobals, 119 ReferenceString, 120 &m_ReferenceString); 121 } 122 else { 123 return STATUS_SUCCESS; 124 } 125 } 126 127 128 VOID 129 FxDeviceInterface::SetState( 130 __in BOOLEAN State 131 ) 132 /*++ 133 134 Routine Description: 135 Sets the state of the device interface 136 137 Arguments: 138 State - the state to set 139 140 141 Return Value: 142 None. 143 144 --*/ 145 { 146 m_State = State; 147 148 // 149 // Only set the state if the interface has been registered 150 // 151 if (m_SymbolicLinkName.Buffer != NULL) { 152 Mx::MxSetDeviceInterfaceState(&m_SymbolicLinkName, m_State); 153 } 154 } 155 156