Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygendevicecontrol.cpp
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS BDA Proxy 00004 * FILE: dll/directx/bdaplgin/classfactory.cpp 00005 * PURPOSE: ClassFactory interface 00006 * 00007 * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) 00008 */ 00009 00010 #include "precomp.h" 00011 00012 const GUID IID_IKsObject = {0x423c13a2, 0x2070, 0x11d0, {0x9e, 0xf7, 0x00, 0xaa, 0x00, 0xa2, 0x16, 0xa1}}; 00013 00014 #ifndef _MSC_VER 00015 const GUID CLSID_DVBTNetworkProvider = {0x216c62df, 0x6d7f, 0x4e9a, {0x85, 0x71, 0x5, 0xf1, 0x4e, 0xdb, 0x76, 0x6a}}; 00016 00017 const GUID KSPROPSETID_BdaTopology = {0xa14ee835, 0x0a23, 0x11d3, {0x9c, 0xc7, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}}; 00018 const GUID KSMETHODSETID_BdaDeviceConfiguration = {0x71985f45, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}}; 00019 const GUID KSMETHODSETID_BdaChangeSync = {0xfd0a5af3, 0xb41d, 0x11d2, {0x9c, 0x95, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}}; 00020 const GUID IID_IBaseFilter = {0x56a86895, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}}; 00021 const GUID IID_IAsyncReader = {0x56A868AA, 0x0AD4, 0x11CE, {0xB0, 0x3A, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70}}; 00022 const GUID IID_IAMOpenProgress = {0x8E1C39A1, 0xDE53, 0x11cf, {0xAA, 0x63, 0x00, 0x80, 0xC7, 0x44, 0x52, 0x8D}}; 00023 const GUID IID_IBDA_Topology = {0x79B56888, 0x7FEA, 0x4690, {0xB4, 0x5D, 0x38, 0xFD, 0x3C, 0x78, 0x49, 0xBE}}; 00024 const GUID IID_IBDA_NetworkProvider = {0xfd501041, 0x8ebe, 0x11ce, {0x81, 0x83, 0x00, 0xaa, 0x00, 0x57, 0x7d, 0xa2}}; 00025 const GUID IID_IBDA_DeviceControl = {0xFD0A5AF3, 0xB41D, 0x11d2, {0x9C, 0x95, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}}; 00026 00027 const GUID IID_IDistributorNotify = {0x56a868af, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; 00028 00029 #endif 00030 00031 class CBDADeviceControl : public IBDA_DeviceControl, 00032 public IBDA_Topology 00033 { 00034 public: 00035 STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); 00036 00037 STDMETHODIMP_(ULONG) AddRef() 00038 { 00039 InterlockedIncrement(&m_Ref); 00040 return m_Ref; 00041 } 00042 STDMETHODIMP_(ULONG) Release() 00043 { 00044 InterlockedDecrement(&m_Ref); 00045 if (!m_Ref) 00046 { 00047 delete this; 00048 return 0; 00049 } 00050 return m_Ref; 00051 } 00052 00053 // IBDA_DeviceControl methods 00054 HRESULT STDMETHODCALLTYPE StartChanges( void); 00055 HRESULT STDMETHODCALLTYPE CheckChanges( void); 00056 HRESULT STDMETHODCALLTYPE CommitChanges( void); 00057 HRESULT STDMETHODCALLTYPE GetChangeState(ULONG *pState); 00058 00059 // IBDA_Topology methods 00060 HRESULT STDMETHODCALLTYPE GetNodeTypes(ULONG *pulcNodeTypes, ULONG ulcNodeTypesMax, ULONG * rgulNodeTypes); 00061 HRESULT STDMETHODCALLTYPE GetNodeDescriptors(ULONG *ulcNodeDescriptors, ULONG ulcNodeDescriptorsMax, BDANODE_DESCRIPTOR * rgNodeDescriptors); 00062 HRESULT STDMETHODCALLTYPE GetNodeInterfaces(ULONG ulNodeType, ULONG *pulcInterfaces, ULONG ulcInterfacesMax, GUID * rgguidInterfaces); 00063 HRESULT STDMETHODCALLTYPE GetPinTypes(ULONG *pulcPinTypes, ULONG ulcPinTypesMax, ULONG *rgulPinTypes); 00064 HRESULT STDMETHODCALLTYPE GetTemplateConnections(ULONG *pulcConnections, ULONG ulcConnectionsMax, BDA_TEMPLATE_CONNECTION * rgConnections); 00065 HRESULT STDMETHODCALLTYPE CreatePin(ULONG ulPinType, ULONG *pulPinId); 00066 HRESULT STDMETHODCALLTYPE DeletePin(ULONG ulPinId); 00067 HRESULT STDMETHODCALLTYPE SetMediaType(ULONG ulPinId, AM_MEDIA_TYPE *pMediaType); 00068 HRESULT STDMETHODCALLTYPE SetMedium(ULONG ulPinId, REGPINMEDIUM *pMedium); 00069 HRESULT STDMETHODCALLTYPE CreateTopology(ULONG ulInputPinId, ULONG ulOutputPinId); 00070 HRESULT STDMETHODCALLTYPE GetControlNode(ULONG ulInputPinId, ULONG ulOutputPinId, ULONG ulNodeType, IUnknown **ppControlNode); 00071 00072 CBDADeviceControl(IUnknown * pUnkOuter, IBaseFilter *pFilter, HANDLE hFile) : m_Ref(0), m_pUnkOuter(pUnkOuter), m_Handle(hFile), m_pFilter(pFilter){}; 00073 virtual ~CBDADeviceControl(){}; 00074 00075 protected: 00076 LONG m_Ref; 00077 IUnknown * m_pUnkOuter; 00078 HANDLE m_Handle; 00079 IBaseFilter * m_pFilter; 00080 }; 00081 00082 HRESULT 00083 STDMETHODCALLTYPE 00084 CBDADeviceControl::QueryInterface( 00085 IN REFIID refiid, 00086 OUT PVOID* Output) 00087 { 00088 *Output = NULL; 00089 00090 if (IsEqualGUID(refiid, IID_IUnknown)) 00091 { 00092 *Output = PVOID(this); 00093 reinterpret_cast<IUnknown*>(*Output)->AddRef(); 00094 return NOERROR; 00095 } 00096 if (IsEqualGUID(refiid, IID_IBDA_DeviceControl)) 00097 { 00098 *Output = (IBDA_DeviceControl*)(this); 00099 reinterpret_cast<IBDA_DeviceControl*>(*Output)->AddRef(); 00100 return NOERROR; 00101 } 00102 00103 if (IsEqualGUID(refiid, IID_IBDA_Topology)) 00104 { 00105 *Output = (IBDA_Topology*)(this); 00106 reinterpret_cast<IBDA_Topology*>(*Output)->AddRef(); 00107 return NOERROR; 00108 } 00109 00110 return E_NOINTERFACE; 00111 } 00112 00113 00114 //------------------------------------------------------------------- 00115 // IBDA_DeviceControl methods 00116 // 00117 HRESULT 00118 STDMETHODCALLTYPE 00119 CBDADeviceControl::StartChanges( void) 00120 { 00121 KSMETHOD Method; 00122 HRESULT hr; 00123 ULONG BytesReturned; 00124 00125 /* setup request */ 00126 Method.Set = KSMETHODSETID_BdaChangeSync; 00127 Method.Id = KSMETHOD_BDA_START_CHANGES; 00128 Method.Flags = KSMETHOD_TYPE_NONE; 00129 00130 /* execute request */ 00131 hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_METHOD, (PVOID)&Method, sizeof(KSMETHOD), NULL, 0, &BytesReturned); 00132 00133 #ifdef BDAPLGIN_TRACE 00134 WCHAR Buffer[100]; 00135 swprintf(Buffer, L"CBDADeviceControl::StartChanges: hr %lx, BytesReturned %lu\n", hr, BytesReturned); 00136 OutputDebugStringW(Buffer); 00137 #endif 00138 00139 return hr; 00140 } 00141 00142 00143 HRESULT 00144 STDMETHODCALLTYPE 00145 CBDADeviceControl::CheckChanges( void) 00146 { 00147 KSMETHOD Method; 00148 HRESULT hr; 00149 ULONG BytesReturned; 00150 00151 /* setup request */ 00152 Method.Set = KSMETHODSETID_BdaChangeSync; 00153 Method.Id = KSMETHOD_BDA_CHECK_CHANGES; 00154 Method.Flags = KSMETHOD_TYPE_NONE; 00155 00156 /* execute request */ 00157 hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_METHOD, (PVOID)&Method, sizeof(KSMETHOD), NULL, 0, &BytesReturned); 00158 00159 #ifdef BDAPLGIN_TRACE 00160 WCHAR Buffer[100]; 00161 swprintf(Buffer, L"CBDADeviceControl::CheckChanges: hr %lx, BytesReturned %lu\n", hr, BytesReturned); 00162 OutputDebugStringW(Buffer); 00163 #endif 00164 00165 return hr; 00166 } 00167 00168 00169 HRESULT 00170 STDMETHODCALLTYPE 00171 CBDADeviceControl::CommitChanges( void) 00172 { 00173 KSMETHOD Method; 00174 HRESULT hr; 00175 ULONG BytesReturned; 00176 00177 /* setup request */ 00178 Method.Set = KSMETHODSETID_BdaChangeSync; 00179 Method.Id = KSMETHOD_BDA_COMMIT_CHANGES; 00180 Method.Flags = KSMETHOD_TYPE_NONE; 00181 00182 /* execute request */ 00183 hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_METHOD, (PVOID)&Method, sizeof(KSMETHOD), NULL, 0, &BytesReturned); 00184 00185 #ifdef BDAPLGIN_TRACE 00186 WCHAR Buffer[100]; 00187 swprintf(Buffer, L"CBDADeviceControl::CommitChanges: hr %lx, BytesReturned %lu\n", hr, BytesReturned); 00188 OutputDebugStringW(Buffer); 00189 #endif 00190 00191 return hr; 00192 } 00193 00194 HRESULT 00195 STDMETHODCALLTYPE 00196 CBDADeviceControl::GetChangeState(ULONG *pState) 00197 { 00198 if (pState) 00199 { 00200 *pState = BDA_CHANGES_COMPLETE; 00201 return S_OK; 00202 } 00203 else 00204 { 00205 return E_POINTER; 00206 } 00207 } 00208 00209 //------------------------------------------------------------------- 00210 // IBDA_Topology methods 00211 // 00212 HRESULT 00213 STDMETHODCALLTYPE 00214 CBDADeviceControl::GetNodeTypes(ULONG *pulcNodeTypes, ULONG ulcNodeTypesMax, ULONG * rgulNodeTypes) 00215 { 00216 KSPROPERTY Property; 00217 HRESULT hr; 00218 ULONG BytesReturned; 00219 00220 // setup request 00221 Property.Set = KSPROPSETID_BdaTopology; 00222 Property.Id = KSPROPERTY_BDA_NODE_TYPES; 00223 Property.Flags = KSPROPERTY_TYPE_GET; 00224 00225 // perform request 00226 hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), rgulNodeTypes, sizeof(ULONG) * ulcNodeTypesMax, &BytesReturned); 00227 00228 *pulcNodeTypes = (BytesReturned / sizeof(ULONG)); 00229 00230 #ifdef BDAPLGIN_TRACE 00231 WCHAR Buffer[100]; 00232 swprintf(Buffer, L"CBDADeviceControl::GetNodeTypes: hr %lx, BytesReturned %lu\n", hr, BytesReturned); 00233 OutputDebugStringW(Buffer); 00234 00235 if (SUCCEEDED(hr)) 00236 { 00237 for(ULONG Index = 0; Index < *pulcNodeTypes; Index++) 00238 { 00239 swprintf(Buffer, L"CBDADeviceControl::GetPinTypes: Index %lu Value %lx\n", Index, rgulNodeTypes[Index]); 00240 OutputDebugStringW(Buffer); 00241 } 00242 } 00243 #endif 00244 00245 return hr; 00246 } 00247 00248 HRESULT 00249 STDMETHODCALLTYPE 00250 CBDADeviceControl::GetNodeDescriptors(ULONG *ulcNodeDescriptors, ULONG ulcNodeDescriptorsMax, BDANODE_DESCRIPTOR * rgNodeDescriptors) 00251 { 00252 KSPROPERTY Property; 00253 HRESULT hr; 00254 ULONG BytesReturned; 00255 00256 00257 // setup request 00258 Property.Set = KSPROPSETID_BdaTopology; 00259 Property.Id = KSPROPERTY_BDA_NODE_DESCRIPTORS; 00260 Property.Flags = KSPROPERTY_TYPE_GET; 00261 00262 // perform request 00263 hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), rgNodeDescriptors, sizeof(BDANODE_DESCRIPTOR) * ulcNodeDescriptorsMax, &BytesReturned); 00264 00265 *ulcNodeDescriptors = (BytesReturned / sizeof(BDANODE_DESCRIPTOR)); 00266 00267 #ifdef BDAPLGIN_TRACE 00268 WCHAR Buffer[1000]; 00269 swprintf(Buffer, L"CBDADeviceControl::GetNodeDescriptors: hr %lx, BytesReturned %lu\n", hr, BytesReturned); 00270 OutputDebugStringW(Buffer); 00271 00272 00273 if (SUCCEEDED(hr)) 00274 { 00275 for(ULONG Index = 0; Index < min(*ulcNodeDescriptors, ulcNodeDescriptorsMax); Index++) 00276 { 00277 LPOLESTR pGUIDFunction, pGUIDName; 00278 00279 StringFromCLSID(rgNodeDescriptors[Index].guidFunction, &pGUIDFunction); 00280 StringFromCLSID(rgNodeDescriptors[Index].guidName, &pGUIDName); 00281 00282 swprintf(Buffer, L"CBDADeviceControl::GetPinTypes: Index %lu Value %lx\nFunction %s\n Name %s\n-----\n", Index, rgNodeDescriptors[Index].ulBdaNodeType, pGUIDFunction, pGUIDName); 00283 OutputDebugStringW(Buffer); 00284 } 00285 } 00286 #endif 00287 00288 00289 return hr; 00290 } 00291 00292 HRESULT 00293 STDMETHODCALLTYPE 00294 CBDADeviceControl::GetNodeInterfaces(ULONG ulNodeType, ULONG *pulcInterfaces, ULONG ulcInterfacesMax, GUID * rgguidInterfaces) 00295 { 00296 KSP_NODE Property; 00297 HRESULT hr; 00298 ULONG BytesReturned; 00299 00300 00301 // setup request 00302 Property.Property.Set = KSPROPSETID_BdaTopology; 00303 Property.Property.Id = KSPROPERTY_BDA_NODE_PROPERTIES; 00304 Property.Property.Flags = KSPROPERTY_TYPE_GET; 00305 Property.NodeId = ulNodeType; 00306 Property.Reserved = 0; 00307 00308 // perform request 00309 hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_NODE), rgguidInterfaces, sizeof(GUID) * ulcInterfacesMax, &BytesReturned); 00310 00311 *pulcInterfaces = (BytesReturned / sizeof(GUID)); 00312 00313 #ifdef BDAPLGIN_TRACE 00314 WCHAR Buffer[100]; 00315 swprintf(Buffer, L"CBDADeviceControl::GetNodeInterfaces: hr %lx, BytesReturned %lu ulNodeType %lu\n", hr, BytesReturned, ulNodeType); 00316 OutputDebugStringW(Buffer); 00317 00318 if (SUCCEEDED(hr)) 00319 { 00320 for(ULONG Index = 0; Index < min(*pulcInterfaces, ulcInterfacesMax); Index++) 00321 { 00322 LPOLESTR pstr; 00323 00324 StringFromCLSID(rgguidInterfaces[Index], &pstr); 00325 00326 swprintf(Buffer, L"CBDADeviceControl::GetNodeInterfaces: Index %lu Name %s\n", Index, pstr); 00327 OutputDebugStringW(Buffer); 00328 } 00329 } 00330 #endif 00331 00332 return hr; 00333 } 00334 00335 HRESULT 00336 STDMETHODCALLTYPE 00337 CBDADeviceControl::GetPinTypes(ULONG *pulcPinTypes, ULONG ulcPinTypesMax, ULONG *rgulPinTypes) 00338 { 00339 KSPROPERTY Property; 00340 HRESULT hr; 00341 ULONG BytesReturned; 00342 00343 // setup request 00344 Property.Set = KSPROPSETID_BdaTopology; 00345 Property.Id = KSPROPERTY_BDA_PIN_TYPES; 00346 Property.Flags = KSPROPERTY_TYPE_GET; 00347 00348 // perform request 00349 hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), rgulPinTypes, sizeof(ULONG) * ulcPinTypesMax, &BytesReturned); 00350 00351 *pulcPinTypes = (BytesReturned / sizeof(ULONG)); 00352 00353 #ifdef BDAPLGIN_TRACE 00354 WCHAR Buffer[100]; 00355 swprintf(Buffer, L"CBDADeviceControl::GetPinTypes: hr %lx, BytesReturned %lu\n", hr, BytesReturned); 00356 OutputDebugStringW(Buffer); 00357 00358 if (SUCCEEDED(hr)) 00359 { 00360 for(ULONG Index = 0; Index < *pulcPinTypes; Index++) 00361 { 00362 swprintf(Buffer, L"CBDADeviceControl::GetPinTypes: Index %lu Value %lx\n", Index, rgulPinTypes[Index]); 00363 OutputDebugStringW(Buffer); 00364 } 00365 } 00366 #endif 00367 00368 return hr; 00369 } 00370 00371 HRESULT 00372 STDMETHODCALLTYPE 00373 CBDADeviceControl::GetTemplateConnections(ULONG *pulcConnections, ULONG ulcConnectionsMax, BDA_TEMPLATE_CONNECTION * rgConnections) 00374 { 00375 #ifdef BDAPLGIN_TRACE 00376 OutputDebugStringW(L"CBDADeviceControl::GetTemplateConnections: NotImplemented\n"); 00377 #endif 00378 00379 return E_NOTIMPL; 00380 } 00381 00382 HRESULT 00383 STDMETHODCALLTYPE 00384 CBDADeviceControl::CreatePin(ULONG ulPinType, ULONG *pulPinId) 00385 { 00386 #ifdef BDAPLGIN_TRACE 00387 OutputDebugStringW(L"CBDADeviceControl::CreatePin: NotImplemented\n"); 00388 #endif 00389 00390 return E_NOTIMPL; 00391 } 00392 00393 HRESULT 00394 STDMETHODCALLTYPE 00395 CBDADeviceControl::DeletePin(ULONG ulPinId) 00396 { 00397 #ifdef BDAPLGIN_TRACE 00398 OutputDebugStringW(L"CBDADeviceControl::DeletePin: NotImplemented\n"); 00399 #endif 00400 00401 return E_NOTIMPL; 00402 } 00403 00404 HRESULT 00405 STDMETHODCALLTYPE 00406 CBDADeviceControl::SetMediaType(ULONG ulPinId, AM_MEDIA_TYPE *pMediaType) 00407 { 00408 #ifdef BDAPLGIN_TRACE 00409 OutputDebugStringW(L"CBDADeviceControl::SetMediaType: NotImplemented\n"); 00410 #endif 00411 00412 return E_NOTIMPL; 00413 } 00414 00415 HRESULT 00416 STDMETHODCALLTYPE 00417 CBDADeviceControl::SetMedium(ULONG ulPinId, REGPINMEDIUM *pMedium) 00418 { 00419 #ifdef BDAPLGIN_TRACE 00420 OutputDebugStringW(L"CBDADeviceControl::SetMedium: NotImplemented\n"); 00421 #endif 00422 00423 return E_NOTIMPL; 00424 } 00425 00426 HRESULT 00427 STDMETHODCALLTYPE 00428 CBDADeviceControl::CreateTopology(ULONG ulInputPinId, ULONG ulOutputPinId) 00429 { 00430 KSM_BDA_PIN_PAIR Method; 00431 HRESULT hr; 00432 ULONG BytesReturned = 0; 00433 00434 Method.Method.Flags = KSMETHOD_TYPE_NONE; 00435 Method.Method.Id = KSMETHOD_BDA_CREATE_TOPOLOGY; 00436 Method.Method.Set = KSMETHODSETID_BdaDeviceConfiguration; 00437 Method.InputPinId = ulInputPinId; 00438 Method.OutputPinId = ulOutputPinId; 00439 00440 hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_METHOD, (PVOID)&Method, sizeof(KSM_BDA_PIN_PAIR), NULL, 0, &BytesReturned); 00441 00442 #ifdef BDAPLGIN_TRACE 00443 WCHAR Buffer[100]; 00444 swprintf(Buffer, L"CBDADeviceControl::CreateTopology: hr %lx, BytesReturned %lu\n", hr, BytesReturned); 00445 OutputDebugStringW(Buffer); 00446 #endif 00447 00448 return hr; 00449 } 00450 00451 HRESULT 00452 STDMETHODCALLTYPE 00453 CBDADeviceControl::GetControlNode(ULONG ulInputPinId, ULONG ulOutputPinId, ULONG ulNodeType, IUnknown **ppControlNode) 00454 { 00455 HRESULT hr; 00456 ULONG PinId = 0; 00457 ULONG BytesReturned; 00458 KSP_BDA_NODE_PIN Property; 00459 00460 //setup request 00461 Property.Property.Set = KSPROPSETID_BdaTopology; 00462 Property.Property.Id = KSPROPERTY_BDA_CONTROLLING_PIN_ID; 00463 Property.Property.Flags = KSPROPERTY_TYPE_GET; 00464 Property.ulInputPinId = ulInputPinId; 00465 Property.ulOutputPinId = ulOutputPinId; 00466 Property.ulNodeType = ulNodeType; 00467 00468 // perform request 00469 // WinXP SP3 expects minimum sizeof(KSP_BDA_NODE_PIN) + sizeof(ULONG) 00470 // seems a driver to be a driver bug 00471 00472 hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_BDA_NODE_PIN) + sizeof(ULONG), &PinId, sizeof(ULONG), &BytesReturned); 00473 00474 #ifdef BDAPLGIN_TRACE 00475 WCHAR Buffer[200]; 00476 swprintf(Buffer, L"CBDADeviceControl::GetControlNode: hr %lx, BytesReturned %lu PinId %lu ulInputPinId %lu ulOutputPinId %lu ulNodeType %lu\n", hr, BytesReturned, PinId, ulInputPinId, ulOutputPinId, ulNodeType); 00477 OutputDebugStringW(Buffer); 00478 #endif 00479 00480 if (FAILED(hr)) 00481 return hr; 00482 00483 hr = CControlNode_fnConstructor(m_pFilter, ulNodeType, PinId, IID_IUnknown, (LPVOID*)ppControlNode); 00484 00485 #ifdef BDAPLGIN_TRACE 00486 swprintf(Buffer, L"CBDADeviceControl::GetControlNode: hr %lx\n", hr); 00487 OutputDebugStringW(Buffer); 00488 #endif 00489 00490 return hr; 00491 } 00492 00493 HRESULT 00494 WINAPI 00495 CBDADeviceControl_fnConstructor( 00496 IUnknown * pUnkOuter, 00497 REFIID riid, 00498 LPVOID * ppv) 00499 { 00500 HRESULT hr; 00501 IKsObject *pObject = NULL; 00502 IBaseFilter *pFilter = NULL; 00503 HANDLE hFile; 00504 00505 #ifdef BDAPLGIN_TRACE 00506 OutputDebugStringW(L"CBDADeviceControl_fnConstructor\n"); 00507 #endif 00508 00509 //DebugBreak(); 00510 00511 // sanity check 00512 assert(pUnkOuter); 00513 00514 // query for IKsObject 00515 hr = pUnkOuter->QueryInterface(IID_IKsObject, (void**)&pObject); 00516 00517 if (FAILED(hr)) 00518 return E_NOINTERFACE; 00519 00520 // sanity check 00521 assert(hr == NOERROR); 00522 00523 // query for IBaseFilter interface support 00524 hr = pUnkOuter->QueryInterface(IID_IBaseFilter, (void**)&pFilter); 00525 00526 if (FAILED(hr)) 00527 { 00528 // release 00529 pObject->Release(); 00530 return E_NOINTERFACE; 00531 } 00532 00533 // another sanity check 00534 assert(pObject != NULL); 00535 00536 // get file handle 00537 hFile = pObject->KsGetObjectHandle(); 00538 00539 // one more sanity check 00540 assert(hFile != NULL && hFile != INVALID_HANDLE_VALUE); 00541 00542 // release IKsObject interface 00543 pObject->Release(); 00544 00545 // release filter 00546 pFilter->Release(); 00547 00548 // construct device control 00549 CBDADeviceControl * handler = new CBDADeviceControl(pUnkOuter, pFilter, hFile); 00550 00551 if (!handler) 00552 return E_OUTOFMEMORY; 00553 00554 if (FAILED(handler->QueryInterface(riid, ppv))) 00555 { 00556 /* not supported */ 00557 delete handler; 00558 return E_NOINTERFACE; 00559 } 00560 00561 return NOERROR; 00562 } Generated on Sat May 26 2012 04:19:49 for ReactOS by
1.7.6.1
|