// ----------------------------------------------------------------------------- // QuickLookGeneratorQueryInterface // ----------------------------------------------------------------------------- // Implementation of the IUnknown QueryInterface function. // HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv) { CFUUIDRef interfaceID; interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault,iid); if (CFEqual(interfaceID,kQLGeneratorCallbacksInterfaceID)){ /* If the Right interface was requested, bump the ref count, * set the ppv parameter equal to the instance, and * return good status. */ ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->GenerateThumbnailForURL = GenerateThumbnailForURL; ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->CancelThumbnailGeneration = CancelThumbnailGeneration; ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->GeneratePreviewForURL = GeneratePreviewForURL; ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->CancelPreviewGeneration = CancelPreviewGeneration; ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType*)thisInstance)->conduitInterface)->AddRef(thisInstance); *ppv = thisInstance; CFRelease(interfaceID); return S_OK; }else{ /* Requested interface unknown, bail with error. */ *ppv = NULL; CFRelease(interfaceID); return E_NOINTERFACE; } }
HRESULT IOFireWireSBP2LibLUN::queryInterface( REFIID iid, void **ppv ) { CFUUIDRef uuid = CFUUIDCreateFromUUIDBytes(NULL, iid); HRESULT result = S_OK; if( CFEqual(uuid, IUnknownUUID) || CFEqual(uuid, kIOCFPlugInInterfaceID) ) { *ppv = &fIOCFPlugInInterface; addRef(); } else if( CFEqual(uuid, kIOFireWireSBP2LibLUNInterfaceID) ) { *ppv = &fIOFireWireSBP2LibLUNInterface; addRef(); } else *ppv = 0; if( !*ppv ) result = E_NOINTERFACE; CFRelease( uuid ); return result; }
std::ostream& operator<<(std::ostream& out, CFUUIDBytes b) { SFB::CFUUID u = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault, b); if(u) out << u; return out; }
// Implementation of the IUnknown QueryInterface function. static HRESULT myQueryInterface(void * obj, REFIID iid, LPVOID *ppv) { // Create a CoreFoundation UUIDRef for the requested interface. CFUUIDRef interfaceID = CFUUIDCreateFromUUIDBytes(NULL, iid); #if PRINTDEBUG printf("JAS: mQueryInterface %ld\n", iid); #endif // Test the requested ID against the valid interfaces. #ifdef kAudioHardwarePlugInInterface2ID if (CFEqual(interfaceID, kAudioHardwarePlugInInterfaceID) || CFEqual(interfaceID, kAudioHardwarePlugInInterface2ID)) { #if PRINTDEBUG printf("JAS: mQueryInterface : kAudioHardwarePlugInInterface2ID\n"); #endif #else if (CFEqual(interfaceID, kAudioHardwarePlugInInterfaceID)) { #if PRINTDEBUG printf("JAS: mQueryInterface : kAudioHardwarePlugInInterfaceID\n"); #endif #endif // If the TestInterface was requested, bump the ref count, // set the ppv parameter equal to the instance, and // return good status. ((MyType *)obj)->_testInterface->AddRef(obj); *ppv = obj; CFRelease(interfaceID); return S_OK; } else if (CFEqual(interfaceID, IUnknownUUID)) { // If the IUnknown interface was requested, same as above. ((MyType *)obj)->_testInterface->AddRef(obj); *ppv = obj; CFRelease(interfaceID); return S_OK; } else { // Requested interface unknown, bail with error. *ppv = NULL; CFRelease(interfaceID); return E_NOINTERFACE; } } // Implementation of reference counting for this type. // Whenever an interface is requested, bump the refCount for // the instance. NOTE: returning the refcount is a convention // but is not required so don’t rely on it. static ULONG myAddRef(void * obj) { #if PRINTDEBUG printf("JAS: myAddRef\n"); #endif ((MyType *)obj)->_refCount += 1; return ((MyType *)obj)->_refCount; }
HRESULT SATSMARTClient::QueryInterface ( REFIID iid, void ** ppv ) { CFUUIDRef uuid = CFUUIDCreateFromUUIDBytes ( NULL, iid ); HRESULT result = S_OK; PRINT ( ( "SATSMARTClient : QueryInterface called\n" ) ); if ( CFEqual ( uuid, IUnknownUUID ) ) { PRINT ( ( "IUnknownUUID requested\n" ) ); *ppv = &fCFPlugInInterfaceMap; AddRef ( ); } else if (CFEqual ( uuid, kIOCFPlugInInterfaceID ) ) { PRINT ( ( "kIOCFPlugInInterfaceID requested\n" ) ); *ppv = &fCFPlugInInterfaceMap; AddRef ( ); } else if ( CFEqual ( uuid, kIOATASMARTInterfaceID ) ) { PRINT ( ( "kIOATASMARTInterfaceID requested\n" ) ); *ppv = &fATASMARTInterfaceMap; AddRef ( ); } else { PRINT ( ( "unknown interface requested\n" ) ); *ppv = 0; result = E_NOINTERFACE; } CFRelease ( uuid ); return result; }
static HRESULT HP_HardwarePlugIn_QueryInterface(AudioHardwarePlugInRef inSelf, REFIID inUUID, LPVOID* outInterface) { OSStatus theError = kAudioHardwareNoError; try { // check the function arguments ThrowIfNULL(inSelf, CAException(kAudioHardwareIllegalOperationError), "HP_HardwarePlugIn_QueryInterface: no plug-in"); ThrowIfNULL(outInterface, CAException(kAudioHardwareIllegalOperationError), "HP_HardwarePlugIn_QueryInterface: no place to store the return value"); // set the returned interface to NULL *outInterface = NULL; // get the object out of the interface reference HP_HardwarePlugIn* thePlugIn = HP_HardwarePlugIn::GetObject(inSelf); // create a CoreFoundation UUIDRef for the requested interface. CACFUUID theInterfaceUUID(CFUUIDCreateFromUUIDBytes(NULL, inUUID)); // test the requested ID against the valid interfaces. #if defined(kAudioHardwarePlugInInterface5ID) if(theInterfaceUUID.IsEqual(kAudioHardwarePlugInInterface5ID) || theInterfaceUUID.IsEqual(kAudioHardwarePlugInInterface4ID) || theInterfaceUUID.IsEqual(kAudioHardwarePlugInInterface3ID) || theInterfaceUUID.IsEqual(kAudioHardwarePlugInInterface2ID) || theInterfaceUUID.IsEqual(kAudioHardwarePlugInInterfaceID) || theInterfaceUUID.IsEqual(IUnknownUUID)) #else if(theInterfaceUUID.IsEqual(kAudioHardwarePlugInInterface4ID) || theInterfaceUUID.IsEqual(kAudioHardwarePlugInInterface3ID) || theInterfaceUUID.IsEqual(kAudioHardwarePlugInInterface2ID) || theInterfaceUUID.IsEqual(kAudioHardwarePlugInInterfaceID) || theInterfaceUUID.IsEqual(IUnknownUUID)) #endif { // it's one of the interfaces we understand // retain the object on behalf of the caller thePlugIn->Retain(); // return the interface; *outInterface = thePlugIn->GetInterface(); } else { // not anything we understand theError = E_NOINTERFACE; } } catch(const CAException& inException) { theError = inException.GetError(); } catch(...) { theError = kAudioHardwareUnspecifiedError; } return theError; }
static HRESULT IUnknownQueryInterface( void* obj, REFIID iID, LPVOID* intfPtr ) { IUnknownInstance* instance = (IUnknownInstance*) obj; CFUUIDRef myIntfID = NULL, reqIntfID = NULL; HRESULT err = E_UNEXPECTED; PlugInIntf* interface; // Get IDs for requested and PDE interfaces: reqIntfID = CFUUIDCreateFromUUIDBytes( kCFAllocatorDefault, iID ); myIntfID = CFUUIDCreateFromString( kCFAllocatorDefault, kDialogExtensionIntfIDStr ); if(reqIntfID && myIntfID){ // If we are asked to return the interface for // the IUnknown vtable, which the system already has access to, // just increment the refcount value if(CFEqual( reqIntfID, IUnknownUUID ) ) { instance->vtable->AddRef( (void*) instance ); *intfPtr = (LPVOID) instance; err = S_OK; } else if (CFEqual(reqIntfID, myIntfID)) // if we are asked for the PDEs interface, { // lets make one and return it. err = MyCreatePlugInInterface( &interface ); if ( noErr == err ) { *intfPtr = (LPVOID) interface; err = S_OK; }else{ *intfPtr = NULL; err = E_NOINTERFACE; } } else // we will return the err = E_NOINTERFACE and a *intfPtr of NULL; { *intfPtr = NULL; err = E_NOINTERFACE; } }else{ // we will return the err = E_NOINTERFACE and a *intfPtr of NULL; *intfPtr = NULL; err = E_NOINTERFACE; } // Clean up and return status: if(reqIntfID)CFRelease( reqIntfID ); if(myIntfID)CFRelease( myIntfID ); return( err ); }
HRESULT IOHIDTransactionClass::queryInterface(REFIID iid, void ** ppv) { CFUUIDRef uuid = CFUUIDCreateFromUUIDBytes(NULL, iid); HRESULT res = S_OK; if (CFEqual(uuid, kIOHIDDeviceTransactionInterfaceID)) { *ppv = getInterfaceMap(); addRef(); } else { res = fOwningDevice->queryInterface(iid, ppv); } if (!*ppv) res = E_NOINTERFACE; CFRelease(uuid); return res; }
static CFStringRef extsuper_uuid(const char *device) { CFStringRef str; CFUUIDRef uuid; CFUUIDBytes *ubytes; char *buf; struct ext2_super_block *sbp; if (extsuper_read(device, &buf, &sbp)) return (NULL); ubytes = (CFUUIDBytes*)&sbp->s_uuid[0]; uuid = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault, *ubytes); free(buf); if (uuid) { str = CFUUIDCreateString(kCFAllocatorDefault, uuid); CFRelease(uuid); return (str); } return (NULL); }
HRESULT IOCFPlugIn::QueryInterface( REFIID iid, LPVOID* ppv ) { HRESULT result = S_OK ; *ppv = nil ; CFUUIDRef interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault, iid) ; if ( CFEqual(interfaceID, IUnknownUUID) || CFEqual(interfaceID, kIOCFPlugInInterfaceID) ) { *ppv = & GetInterface() ; AddRef() ; ::CFRelease(interfaceID) ; } else // we don't have one of these... let's ask the device interface... result = (**mDevice).QueryInterface( mDevice, iid, ppv) ; return result ; }
static HRESULT Feedback360QueryInterface(void *that,REFIID iid,LPVOID *ppv) { Xbox360ForceFeedback *this=FFThis(that); CFUUIDRef interface; interface=CFUUIDCreateFromUUIDBytes(NULL,iid); // IOForceFeedbackDevice if(CFEqual(interface,kIOForceFeedbackDeviceInterfaceID)) *ppv=&this->iIOForceFeedbackDeviceInterface; // IUnknown || IOCFPlugInInterface else if(CFEqual(interface,IUnknownUUID)||CFEqual(interface,kIOCFPlugInInterfaceID)) *ppv=&this->iIOCFPlugInInterface; else *ppv=NULL; // Done CFRelease(interface); if((*ppv)==NULL) return E_NOINTERFACE; else { this->iIOCFPlugInInterface.pseudoVTable->AddRef(*ppv); return S_OK; } }
// ----------------------------------------------------------------------------- // MetadataImporterQueryInterface // ----------------------------------------------------------------------------- // Implementation of the IUnknown QueryInterface function. // HRESULT MetadataImporterQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv) { CFUUIDRef interfaceID; interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault,iid); if (CFEqual(interfaceID,kMDImporterInterfaceID)) { /* If the Right interface was requested, bump the ref count, * set the ppv parameter equal to the instance, and * return good status. */ ((MDImporterInterfaceStruct *)((MetadataImporterPluginType *)thisInstance)->conduitInterface)->ImporterImportData = LegacyGetMetadataForFile; ((MDImporterInterfaceStruct *)((MetadataImporterPluginType*)thisInstance)->conduitInterface)->AddRef(thisInstance); *ppv = thisInstance; CFRelease(interfaceID); return S_OK; } else if (CFEqual(interfaceID,kMDImporterURLInterfaceID)) { ((MDImporterURLInterfaceStruct *)((MetadataImporterPluginType *)thisInstance)->conduitInterface)->ImporterImportURLData = GetMetadataForURL; ((MDImporterURLInterfaceStruct *)((MetadataImporterPluginType*)thisInstance)->conduitInterface)->AddRef(thisInstance); *ppv = thisInstance; CFRelease(interfaceID); return S_OK; } else if (CFEqual(interfaceID,IUnknownUUID)) { /* If the IUnknown interface was requested, same as above. */ ((MDImporterInterfaceStruct *)((MetadataImporterPluginType*)thisInstance)->conduitInterface)->AddRef(thisInstance); *ppv = thisInstance; CFRelease(interfaceID); return S_OK; } else { /* Requested interface unknown, bail with error. */ *ppv = NULL; CFRelease(interfaceID); return E_NOINTERFACE; } }
HRESULT STDMETHODCALLTYPE IBMDSwitcherDiscovery::QueryInterface(REFIID riid, LPVOID *ppv) { if (!ppv) return E_POINTER; if (riid == IID_IBMDSwitcherDiscovery) { *ppv = static_cast<IBMDSwitcherDiscovery*>(this); AddRef(); return S_OK; } if (CFEqual(CFUUIDCreateFromUUIDBytes(NULL,riid), IUnknownUUID)) { *ppv = static_cast<IUnknown*>(this); AddRef(); return S_OK; } *ppv = NULL; return E_NOINTERFACE; }
HRESULT STDMETHODCALLTYPE PseudoAddressSpace::QueryInterface(REFIID iid, LPVOID* ppv) { HRESULT result = S_OK ; *ppv = nil ; CFUUIDRef interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault, iid) ; if ( CFEqual(interfaceID, IUnknownUUID) || CFEqual(interfaceID, kIOFireWirePseudoAddressSpaceInterfaceID) ) { *ppv = & GetInterface() ; AddRef() ; } else { *ppv = nil ; result = E_NOINTERFACE ; } CFRelease(interfaceID) ; return result ; }
HRESULT PHYPacketListener::QueryInterface( REFIID iid, LPVOID* ppv ) { HRESULT result = S_OK; *ppv = nil; CFUUIDRef interfaceID = CFUUIDCreateFromUUIDBytes( kCFAllocatorDefault, iid ); if( CFEqual(interfaceID, IUnknownUUID) || CFEqual(interfaceID, kIOFireWirePHYPacketListenerInterfaceID) ) { *ppv = &GetInterface(); AddRef(); } else { *ppv = nil; result = E_NOINTERFACE; } CFRelease( interfaceID ); return result; }
// Implementation of the IUnknown QueryInterface function. HRESULT IOHIDEventSystemStatistics::QueryInterface( REFIID iid, LPVOID *ppv ) { // Create a CoreFoundation UUIDRef for the requested interface. CFUUIDRef interfaceID = CFUUIDCreateFromUUIDBytes( NULL, iid ); // Test the requested ID against the valid interfaces. if (CFEqual(interfaceID, kIOHIDSimpleSessionFilterPlugInInterfaceID) || CFEqual(interfaceID, kIOHIDSessionFilterPlugInInterfaceID)) { AddRef(); *ppv = this; CFRelease(interfaceID); return S_OK; } if (CFEqual(interfaceID, IUnknownUUID)) { // If the IUnknown interface was requested, same as above. AddRef(); *ppv = this; CFRelease(interfaceID); return S_OK; } // Requested interface unknown, bail with error. *ppv = NULL; CFRelease( interfaceID ); return E_NOINTERFACE; }
// ----------------------------------------------------------------------------- // SampleCMPluginQueryInterface // ----------------------------------------------------------------------------- // Implementation of the IUnknown QueryInterface function. // static HRESULT SampleCMPluginQueryInterface( void* thisInstance, REFIID iid, LPVOID* ppv ) { // Create a CoreFoundation UUIDRef for the requested interface. CFUUIDRef interfaceID = CFUUIDCreateFromUUIDBytes( NULL, iid ); // Test the requested ID against the valid interfaces. if ( CFEqual( interfaceID, kContextualMenuInterfaceID ) ) { // If the TestInterface was requested, bump the ref count, // set the ppv parameter equal to the instance, and // return good status. ( ( SampleCMPluginType* ) thisInstance )->cmInterface->AddRef( thisInstance ); *ppv = thisInstance; CFRelease( interfaceID ); return S_OK; } else if ( CFEqual( interfaceID, IUnknownUUID ) ) { // If the IUnknown interface was requested, same as above. ( ( SampleCMPluginType* ) thisInstance )->cmInterface->AddRef( thisInstance ); *ppv = thisInstance; CFRelease( interfaceID ); return S_OK; } else { // Requested interface unknown, bail with error. *ppv = NULL; CFRelease( interfaceID ); return E_NOINTERFACE; } }
static inline bool operator== (const REFIID& iid1, const REFIID& iid2) { return CFEqual(CFUUIDCreateFromUUIDBytes(NULL,iid1), CFUUIDCreateFromUUIDBytes(NULL,iid2)); }