Reactos
at master 155 lines 2.8 kB view raw
1/*++ 2 3Copyright (c) Microsoft Corporation 4 5Module Name: 6 7 FxDeviceInterface.cpp 8 9Abstract: 10 11 This module implements the device interface object. 12 13Author: 14 15 16 17Environment: 18 19 Both kernel and user mode 20 21Revision History: 22 23--*/ 24 25#include "fxsupportpch.hpp" 26 27extern "C" { 28// #include "FxDeviceInterface.tmh" 29} 30 31FxDeviceInterface::FxDeviceInterface( 32 ) 33/*++ 34 35Routine Description: 36 Constructor for the object. Initializes all fields 37 38Arguments: 39 None 40 41Return 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 61FxDeviceInterface::~FxDeviceInterface() 62/*++ 63 64Routine Description: 65 Destructor for FxDeviceInterface. Cleans up any allocations previously 66 allocated. 67 68Arguments: 69 None 70 71Return 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_ 93NTSTATUS 94FxDeviceInterface::Initialize( 95 __in PFX_DRIVER_GLOBALS FxDriverGlobals, 96 __in CONST GUID* InterfaceGUID, 97 __in_opt PCUNICODE_STRING ReferenceString 98 ) 99/*++ 100 101Routine Description: 102 Initializes the object with the interface GUID and optional reference string 103 104Arguments: 105 InterfaceGUID - GUID describing the interface 106 107 ReferenceString - string used to differentiate between 2 interfaces on the 108 same PDO 109 110Return 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 128VOID 129FxDeviceInterface::SetState( 130 __in BOOLEAN State 131 ) 132/*++ 133 134Routine Description: 135 Sets the state of the device interface 136 137Arguments: 138 State - the state to set 139 140 141Return 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