HRESULT CVCamStream::QueryInterface(REFIID riid, void **ppv) { // Standard OLE stuff if (riid == _uuidof(IAMStreamConfig)) *ppv = (IAMStreamConfig*)this; else if (riid == _uuidof(IKsPropertySet)) *ppv = (IKsPropertySet*)this; else return CSourceStream::QueryInterface(riid, ppv); AddRef(); return S_OK; }
STDMETHODIMP CCamStudioFilter::QueryInterface(REFIID riid, void **ppv) { if(riid == _uuidof(IAMStreamConfig)) return m_pPin->QueryInterface(riid, ppv); else if(riid == _uuidof(IKsPropertySet)) return m_pPin->QueryInterface(riid, ppv); else if(riid == IID_ICaptureParam) return m_pPin->QueryInterface(riid, ppv); else if(riid == IID_ICaptureReport) return m_pPin->QueryInterface(riid, ppv); else return CSource::QueryInterface(riid, ppv); }
HRESULT CVCamStream::QueryInterface(REFIID riid, void **ppv) { // Standard OLE stuff...allow it to query for our interfaces that we implement... if(riid == _uuidof(IAMStreamConfig)) *ppv = (IAMStreamConfig*)this; else if(riid == _uuidof(IKsPropertySet)) *ppv = (IKsPropertySet*)this; else if(riid == _uuidof(IAMBufferNegotiation)) *ppv = (IAMBufferNegotiation*)this; else return CSourceStream::QueryInterface(riid, ppv); AddRef(); return S_OK; }
HRESULT CDevice::QueryInterface( _In_ REFIID riid, _Out_ LPVOID* ppvObject ) /*++ Routine Description: The framework calls this function to determine which callback interfaces we support. Arguments: riid - GUID for a given callback interface. ppvObject - We set this pointer to our object if we support the interface indicated by riid. Return Value: HRESULT S_OK - Interface is supported. --*/ { if (ppvObject == NULL) { return E_INVALIDARG; } *ppvObject = NULL; if ( riid == _uuidof(IUnknown) ) { *ppvObject = static_cast<IPnpCallbackHardware*>(this); } else if ( riid == _uuidof(IPnpCallbackHardware) ) { *ppvObject = static_cast<IPnpCallbackHardware *>(this); } else { return E_NOINTERFACE; } this->AddRef(); return S_OK; }
bool spoutDirectX::LockD3D11Texture(ID3D11Texture2D* pD3D11Texture) { DWORD dwWaitResult; IDXGIKeyedMutex* pDXGIKeyedMutex; if(pD3D11Texture == NULL) return false; pD3D11Texture->QueryInterface(_uuidof(IDXGIKeyedMutex), (void**)&pDXGIKeyedMutex); if (pDXGIKeyedMutex) { dwWaitResult = (DWORD)pDXGIKeyedMutex->AcquireSync(0, 67); // TODO - link with SPOUT_WAIT_TIMEOUT if (dwWaitResult == WAIT_OBJECT_0 ) { // The state of the object is signaled. return true; } else { switch(dwWaitResult) { case WAIT_ABANDONED : // Could return here printf("LockD3D11Texture : WAIT_ABANDONED\n"); break; case WAIT_TIMEOUT : // The time-out interval elapsed, and the object's state is nonsignaled. printf("LockD3D11Texture : SPOUT_WAIT_TIMEOUT\n"); break; default : break; } } } return false; }
void ValueSetterDialog::resetCombos(long meterIndex) { xml = L""; BSTR xPath = L""; if (meterIndex >= 0) { IMeter *pMeter; meters->Item(CComVariant(meterIndex), &pMeter); IMetaData *pMetaData = 0; pMeter->QueryInterface(_uuidof(IMetaData), (void**)&pMetaData); if (pMetaData) { BSTR xmlString; if (SUCCEEDED(pMetaData->GetMetaData(&xmlString))) { xPath = L"//valueset[@id=//method[@name=\"PutValue\"]/arg[@name=\"selector\"]/valuesetref/@idref]"; xml = xmlString; } pMetaData->Release(); } } BSTR s; pController->get_Selector(&s); _bstr_t _s(s); selectorList.init(m_hWnd, IDC_COMBO_SELECTOR, xml, xPath, _s); resetValueCombo(_s); }
STDMETHODIMP CNetworkProvider::GetSignalStats (ULONG* tunerLocked, ULONG* signalPresent, LONG* signalQuality, LONG* signalLevel){ HRESULT hr = S_OK; try{ IBDA_SignalStatistics* signalStatistcsFilter; if (m_signalStatistics.size() > 0) { for (UINT i = 0; i< m_signalStatistics.size() ; ++i){ if(m_signalStatistics[i]->QueryInterface(_uuidof(IBDA_SignalStatistics),(void**) &signalStatistcsFilter) == S_OK){ BOOLEAN tmp; hr = signalStatistcsFilter->get_SignalPresent(&tmp); if(tmp==TRUE){ *signalPresent=1; }else{ *signalPresent=0; } hr = signalStatistcsFilter->get_SignalLocked(&tmp); if(tmp==TRUE){ *tunerLocked=1; }else{ *tunerLocked=0; } hr = signalStatistcsFilter->get_SignalQuality(signalQuality); hr = signalStatistcsFilter->get_SignalStrength(signalLevel); } } } }catch(...){ hr = S_FALSE; LOG4CPLUS_ERROR(logger,"GetSignalStats failed"); } return hr; }
void GameSystem::StartGame(float gametime, float fps,HINSTANCE hinstance) { //window mainHwnd.CreateHwnd(hinstance,WndProc); //time gameTime.Reset(); gameTime.Update(); //Camera cam.SetProj(0.35*XM_PI, ScreenWidth / (ScreenHeight*1.0f), 0.5f, 20000.0f); cam.Update(); // dx if (SUCCEEDED(CreateSwapChain())) { ID3D11Texture2D* pSwapChainBuffer = 0; swapChain->GetBuffer(0, _uuidof(ID3D11Texture2D), (void**)&pSwapChainBuffer); device->CreateRenderTargetView(pSwapChainBuffer, NULL, &Backbuffer); directX.init(device, deviceContext); pSwapChainBuffer->Release(); } //create shaderss //TEST //createShaders(); //Defered DeferedRendering.StartUp(device, deviceContext,swapChain); //Create Objects etc.... //TEST //setShaders(); //store matrixes XMStoreFloat4x4(&matrix.World, XMMatrixTranspose(XMMatrixScaling(1.0, 1.0, 1.0))); XMStoreFloat4x4(&matrix.View, XMMatrixTranspose(cam.GetViewMa())); XMStoreFloat4x4(&matrix.Proj, XMMatrixTranspose(cam.GetProjMa())); //CreateBuffer CreateBuffers(); hMap.CreateMap(256,256,256,256,device,deviceContext); hMap.setupFrust(256, 256, device); obj.LoadObjFile(L"skull.obj"); obj.createTexture(device, deviceContext, L"teapot.png"); obj.createbuff(device); Ssao.startUp(device, deviceContext); //View projektion from sunlight shadow.StartUp(device,deviceContext,sunMatrix); }
// Set up the connection to a manipulation or inertia processor BOOL CManipulationEventSink::SetupConnPt(IUnknown *manipulationProc) { BOOL success = FALSE; IConnectionPointContainer* pConPointContainer = NULL; // Only connect if there isn't already an active connection if (m_pConnPoint == NULL) { // Check if supports connectable objects success = SUCCEEDED(manipulationProc->QueryInterface(IID_IConnectionPointContainer, (LPVOID*)&(pConPointContainer))); // Get connection point interface if(success) { success = SUCCEEDED(pConPointContainer->FindConnectionPoint( _uuidof(_IManipulationEvents), &(m_pConnPoint))); } // Clean up connection point container if (pConPointContainer != NULL) { pConPointContainer->Release(); pConPointContainer = NULL; } // Hook event object to the connection point IUnknown* pUnk = NULL; if(success) { // Get pointer to manipulation event sink's IUnknown pointer success = SUCCEEDED(QueryInterface(IID_IUnknown, (LPVOID*)&pUnk)); } // Establish connection point to callback interface if(success) { success = SUCCEEDED(m_pConnPoint->Advise(pUnk, &(m_uID))); } // Clean up IUnknown pointer if(pUnk != NULL) { pUnk->Release(); } if (!success && m_pConnPoint != NULL) { m_pConnPoint->Release(); m_pConnPoint = NULL; } } return success; }
STDMETHODIMP CMarshalErrorInfo::GenerateCOMError(int type) { HRESULT hr = S_OK; switch(type) { case 1: hr = E_POINTER; break; case 2: hr = E_NOTIMPL; break; case 3: hr = E_ACCESSDENIED; break; case 4: hr = E_OUTOFMEMORY; break; case 5: hr = CO_E_CLRNOTAVAILABLE; // 相比case 6返回给托管代码的异常,我们可以: // 1. 自定义错误信(messege) // 2. 给定明确的错误产生的位置。(source) GenerateErrorInfo(_uuidof(IMarshalErrorInfo), "CMarshalErrorInfo::GenerateCOMError()", "参数为5时产生的错误: CO_E_CLRNOTAVAILABLE"); break; case 6: hr = CO_E_THREADPOOL_CONFIG; break; case 7: hr = 0x80040310L; GenerateErrorInfo(_uuidof(IMarshalErrorInfo), "CMarshalErrorInfo::GenerateCOMError()", "参数为7时产生的错误"); break; default: break; } return hr; }
BOOL CT3DSystemApp::InitInstance() { AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif // Change the registry key under which our settings are stored. // TODO: You should modify this string to be something appropriate // such as the name of your company or organization. SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CT3DSystemDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CT3DSystemView)); AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; AfxOleInit(); //初始化COM環境 m_Connection.CreateInstance("ADODB.Connection"); m_Recordset.CreateInstance(_uuidof(Recordset)); m_pConnection.CreateInstance("ADODB.Connection"); // The one and only window has been initialized, so show and update it. m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED); m_pMainWnd->UpdateWindow(); m_pMainWnd->SetWindowText("三維可視化系統"); return TRUE; }
bool CNetworkProvider::CheckCapabilities(IBaseFilter* filter){ IBDA_Topology* topology; LOG4CPLUS_DEBUG(logger,"CheckCapabilities - START"); if(filter->QueryInterface(_uuidof(IBDA_Topology), (void**) &topology) == S_OK){ // Check For interfaces CheckInterfaces(topology); // Check for tuning Types CheckTuningType(topology); } LOG4CPLUS_DEBUG(logger,"CheckCapabilities - FINISHED"); return S_OK; }
HRESULT STDMETHODCALLTYPE nsScriptablePeerTearOff::QueryInterface(REFIID riid, void **ppvObject) { if (::IsEqualIID(riid, _uuidof(IDispatch))) { *ppvObject = dynamic_cast<IDispatch *>(this); mOwner->AddRef(); return NS_OK; } nsID iid; memcpy(&iid, &riid, sizeof(nsID)); return mOwner->QueryInterface(iid, ppvObject); }
HRESULT CNetworkProvider::RegisterDeviceFilter(IUnknown* pUnkFilterControl,ULONG* ppvRegisitrationContext) { RegisterDevice* device; FILTER_INFO filterinfo; HRESULT hr; IBaseFilter* filter; LOG4CPLUS_INFO(logger,"RegisterDeviceFilter start"); IMpeg2Demultiplexer* demux; if (m_pNetworkProviderPin->GetConnected() != NULL){ hr = m_pNetworkProviderPin->CreateOutputPin(m_pNetworkProviderPin->GetConnected()); } CAutoLock lock(&m_Lock); if (pUnkFilterControl == NULL){ return E_POINTER; } if (&ppvRegisitrationContext == NULL ){ return E_POINTER; } hr = pUnkFilterControl->QueryInterface(IID_IBaseFilter, (void**) &filter); if (hr != S_OK ){ return S_FALSE; } hr = filter->QueryFilterInfo(&filterinfo); filterinfo.pGraph = NULL; if (hr != S_OK ){ return S_FALSE; } LOG4CPLUS_DEBUG(logger,"RegisterDeviceFilter checks finished"); m_fid = m_fid + 1; device = new RegisterDevice(); device->id = m_fid; device->control = filter; wcstombs( device->name, filterinfo.achName, sizeof(device->name)); ppvRegisitrationContext = &m_fid; hr = pUnkFilterControl->QueryInterface(IID_IMpeg2Demultiplexer, (void**) &demux); if (hr == S_OK ){ LOG4CPLUS_DEBUG(logger,"RegisterDeviceFilter device prepared for registration - Name: "<<device->name<<" - "<<m_fid<<" - "<<&m_fid); device->control = NULL; delete device; LOG4CPLUS_INFO(logger,"RegisterDeviceFilter demux skipped"); return S_FALSE; }else{ LOG4CPLUS_INFO(logger,"RegisterDeviceFilter device prepared for registration - Name: "<<device->name<<" - "<<m_fid<<" - "<<&m_fid); IBDA_DeviceControl* ctrl; if( filter->QueryInterface(_uuidof(IBDA_DeviceControl), (void**) &ctrl)==S_OK){ device->deviceControl=ctrl; } m_vecDevices.push_back(device); CheckCapabilities(filter); } LOG4CPLUS_DEBUG(logger,"RegisterDeviceFilter finished"); return S_OK; }
void spoutDirectX::UnlockD3D11Texture(ID3D11Texture2D* pD3D11Texture) { if(pD3D11Texture == NULL) return; IDXGIKeyedMutex* pDXGIKeyedMutex; pD3D11Texture->QueryInterface(_uuidof(IDXGIKeyedMutex), (void**)&pDXGIKeyedMutex); if (pDXGIKeyedMutex) { HRESULT hr = pDXGIKeyedMutex->ReleaseSync(0); if (FAILED(hr)) { // printf("Failed to unlock the shared texture"); } } }
/// <summary> /// according to select sql ,to get the record set. /// </summary> /// <param name="sql"></param> /// <returns></returns> _RecordsetPtr& CBADO::OpenRecordset(CString sql) { ASSERT(!sql.IsEmpty()); try { m_pRecordset.CreateInstance(_uuidof(Recordset)); m_pRecordset->Open(_bstr_t(sql), m_pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText); } catch (_com_error e) { AfxMessageBox(e.Description()); } return m_pRecordset; }
// // Keyed Mutex locks for shared DirectX 11 textures (not applicable for DirectX 9) // bool spoutDirectX::IsKeyedMutexTexture(ID3D11Texture2D* pD3D11Texture) { IDXGIKeyedMutex* pDXGIKeyedMutex; if(pD3D11Texture == NULL) { return false; } pD3D11Texture->QueryInterface(_uuidof(IDXGIKeyedMutex), (void**)&pDXGIKeyedMutex); if (pDXGIKeyedMutex) { return true; } else { return false; } }
STDMETHODIMP CNetworkProvider::NonDelegatingQueryInterface(REFIID riid, void ** ppv) { CheckPointer(ppv,E_POINTER); CAutoLock lock(&m_Lock); if(riid == IID_IGTvLibLogging){ return GetInterface((IGTvLibLogging*)this,ppv); }else if(riid == IID_IGTvLibTuning){ return GetInterface((IGTvLibTuning*)this,ppv); }else if(riid == _uuidof(IBDA_NetworkProvider)){ return GetInterface((IBDA_NetworkProvider*)this,ppv); } else if (riid == IID_IBaseFilter || riid == IID_IMediaFilter || riid == IID_IPersist) { return m_pFilter->NonDelegatingQueryInterface(riid, ppv); } return CUnknown::NonDelegatingQueryInterface(riid, ppv); }
static void getHardwareAdapter(IDXGIFactory1 *factory, IDXGIAdapter1 **outAdapter) { ComPtr<IDXGIAdapter1> adapter; for (int adapterIndex = 0; factory->EnumAdapters1(adapterIndex, &adapter) != DXGI_ERROR_NOT_FOUND; ++adapterIndex) { DXGI_ADAPTER_DESC1 desc; adapter->GetDesc1(&desc); if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) continue; if (SUCCEEDED(D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, _uuidof(ID3D12Device), Q_NULLPTR))) { const QString name = QString::fromUtf16((char16_t *) desc.Description); qDebug("Using adapter '%s'", qPrintable(name)); break; } } *outAdapter = adapter.Detach(); }
int CDLindex::initxml(){ MSXML2::IXMLDOMDocumentPtr pDoc; MSXML2::IXMLDOMElementPtr xmlRoot; //创建DOMDocument对象 HRESULT hr = pDoc.CreateInstance(_uuidof(MSXML2::DOMDocument40)); if (FAILED(hr)) { MessageBoxA(NULL,"无法创建DOM文件对象,检查是否安装MS XML Parser运行库","error",0); return 0; } return 0; }
HRESULT CPlayer::FinalConstruct() { CLSID clsid; ::CLSIDFromProgID(L"SysStatsCOM.WeakTarget", &clsid); HRESULT res = ::CoCreateInstance(clsid, GetControllingUnknown(), CLSCTX_INPROC_SERVER, IID_IUnknown, (void**)&pWeakTarget); ::CLSIDFromProgID(L"SysStatsCOM.MetaData", &clsid); res = ::CoCreateInstance(clsid, GetControllingUnknown(), CLSCTX_INPROC_SERVER, IID_IUnknown, (void**)&pMetaData); char buf[MAX_PATH]; _snprintf(buf, sizeof(buf), "#%d", IDR_XML_PLAYER); IMetaData *pMD = 0; pMetaData->QueryInterface(_uuidof(IMetaData), (void**)&pMD); if (pMD) { pMD->PutResourceInfo((long)_Module.GetModuleInstance(), _bstr_t(buf)); pMD->Release(); } return res; }
HRESULT As(_Out_ ScopedObject<U>* p ) { return _pointer->QueryInterface( _uuidof(U), reinterpret_cast<void**>( p->ReleaseAndGetAddressOf() ) ); }
HRESULT As(_Inout_ U* p) { return _pointer->QueryInterface( _uuidof(U), reinterpret_cast<void**>( p ) ); }
void Building::GetThisBuildingRecord(int BId) { id=BId; //_ConnectionPtr sqlSp; //DBConnect* dbconnection; //_RecordsetPtr m_pRecordset; //dbconnection = DBConnGuard::GetAConnect(); //sqlSp = dbconnection->_connection_ptr; ////dbCon.getMyConnection(connection); //m_pRecordset.CreateInstance(__uuidof(Recordset)); ////////////////////////////////////////////////////////////////// CoInitialize(NULL); _ConnectionPtr sqlSp; HRESULT hr=sqlSp.CreateInstance(_uuidof(Connection)); if(FAILED(hr)) { cout<<"cuole"<<endl; } try { _bstr_t strConnect="Driver={sql server};server=ZHANGZHE-PC;uid=sa;pwd=123456;database=test30;"; sqlSp->Open(strConnect,"","",adModeUnknown); } catch(_com_error &e) { cout<<"cuole"<<endl; } _RecordsetPtr m_pRecordset;; //记录集对象指针,用来执行SQL语句并记录查询结果 if(FAILED(m_pRecordset.CreateInstance( _uuidof( Recordset )))) { cout<<"cuole"<<endl; } /////////////////////////////////////////////////////////////////////// string Ext; BuildingPoint BP; stringstream ss; Ext.append("SELECT * FROM BuildingPoint WHERE PBuildingId="); ss<<BId; Ext.append(ss.str()); ss.str(""); ss.clear(); try { m_pRecordset->Open(Ext.c_str(),(IDispatch*)sqlSp,adOpenDynamic,adLockOptimistic, adCmdText); m_pRecordset->MoveFirst(); while(!m_pRecordset->adoEOF) { BP.longitude=double(m_pRecordset->GetCollect("PLongitude")); BP.latitude=double(m_pRecordset->GetCollect("PLatitude")); BP.id=int(m_pRecordset->GetCollect("PId")); BP.px=double(m_pRecordset->GetCollect("PX")); BP.py=double(m_pRecordset->GetCollect("PY")); BP.buildingId=int(m_pRecordset->GetCollect("PBuildingId")); BPoint.push_back(BP); m_pRecordset->MoveNext(); } Ext.clear(); } catch (_com_error &e) { cout << e.Description()<<endl; } m_pRecordset->Close(); //查找建筑物的高度 Ext.append("SELECT * FROM Building WHERE BId="); ss<<BId; Ext.append(ss.str()); ss.str(""); ss.clear(); try { m_pRecordset->Open(Ext.c_str(),(IDispatch*)sqlSp,adOpenDynamic,adLockOptimistic, adCmdText); buildingHeight=float(m_pRecordset->GetCollect("BHeight")); Ext.clear(); } catch (_com_error &e) { cout << e.Description()<<endl; } /*sqlSp->Close(); m_pRecordset->Close();*/ }
bool LoadDIASymbols(const wxString &strPDBFile, wxInt32 modulenum, std::list<CFunctionDescription> & llFuncs, stdext::hash_map<BasedAddress,int> & addressmap ) { // Create DIA80 Data Source Object IDiaDataSource *pDataSource; HRESULT hr = NoRegCoCreate( L"msdia80.dll", _uuidof( DiaSource ), _uuidof( IDiaDataSource ), (void **) &(pDataSource)); if(!SUCCEEDED(hr)) { return false; } /* HMODULE mod=LoadLibrary(L"msdia80.dll"); if(!mod) { return false; } TYPEOF_DllGetClassObject *pGetClassObject=(TYPEOF_DllGetClassObject *)GetProcAddress(mod,"DllGetClassObject"); if(!pGetClassObject) { FreeLibrary(mod); return false; } IClassFactory *pcf; HRESULT hr=(*pGetClassObject)(CLSID_DiaSource,IID_IClassFactory,(void **)&pcf); if(!SUCCEEDED(hr)) { FreeLibrary(mod); return false; } IDiaDataSource *pDataSource; hr=pcf->CreateInstance(NULL,_uuidof(IDiaDataSource),(void **)&pDataSource); if(!SUCCEEDED(hr)) { pcf->Release(); FreeLibrary(mod); return false; } pcf->Release(); */ // Load the executable's debug symbols hr=pDataSource->loadDataFromPdb(strPDBFile); if(!SUCCEEDED(hr)) { pDataSource->Release(); return false; } // Open a symbol session IDiaSession *pDIASession; hr=pDataSource->openSession(&pDIASession); if(!SUCCEEDED(hr)) { pDataSource->Release(); return false; } // Set the UNBASED address on the session, for resolving BasedAddress addrs hr=pDIASession->put_loadAddress(0); if(!SUCCEEDED(hr)) { pDIASession->Release(); pDataSource->Release(); return false; } // Get addresses for this module std::list<BasedAddress> addresses; for(stdext::hash_map<BasedAddress,int>::iterator iter=addressmap.begin();iter!=addressmap.end();iter++) { if(iter->first.nModule==modulenum) { addresses.push_back(iter->first); } } stdext::hash_map<DWORD,wxInt32> functions; int curidx=(int)llFuncs.size(); for(std::list<BasedAddress>::iterator itera=addresses.begin();itera!=addresses.end();itera++) { // Get the symbol for this thing IDiaSymbol* pFunc; if(FAILED(pDIASession->findSymbolByVA(itera->nAddr, SymTagFunction, &pFunc)) || pFunc==NULL) { continue; } // Get the unique symbol index id DWORD indexId; if(FAILED(pFunc->get_symIndexId(&indexId))) { pFunc->Release(); continue; } // See if we have this function already stdext::hash_map<DWORD,int>::iterator iterf=functions.find(indexId); if(iterf!=functions.end()) { addressmap[*itera]=iterf->second; } else { CFunctionDescription func; ////// ULONGLONG addr; if(FAILED(pFunc->get_virtualAddress(&addr))) { pFunc->Release(); continue; } ////// ULONGLONG length; if(FAILED(pFunc->get_length(&length))) { pFunc->Release(); continue; } ///////// BSTR pName; if(FAILED(pFunc->get_name(&pName))) { pFunc->Release(); continue; } func.strMangledName=(const LPWSTR)pName; LocalFree(pName); char mangled[512]; WideCharToMultiByte(CP_UTF8,0,func.strMangledName,-1,mangled,512,NULL,NULL); ///////// char outbase[512]; __unDName(outbase,mangled,512,&malloc,&free,0x1000); wchar_t outbasew[512]; MultiByteToWideChar(CP_UTF8,0,outbase,-1,outbasew,512); func.strBaseName=(const wchar_t *)(outbasew); ///////// char outfull[512]; __unDName(outfull,mangled,512,&malloc,&free,0); wchar_t outfullw[512]; MultiByteToWideChar(CP_UTF8,0,outfull,-1,outfullw,512); func.strFullName=(const wchar_t *)(outfullw); ////////// func.nAddress=BasedAddress(addr,modulenum); func.nByteLength=length; ///////// IDiaEnumLineNumbers *pdeln; func.strSourceFile=wxT("<unknown>"); func.nFirstSourceLine=0; func.nLastSourceLine=0; bool bGotFile=false; if(SUCCEEDED(pDIASession->findLinesByVA(addr,length,&pdeln))) { IDiaLineNumber *pdln; int nLineItem=0; while(SUCCEEDED(pdeln->Item(nLineItem,&pdln))) { DWORD dwLineNumber; IDiaSourceFile *pdsf; if(SUCCEEDED(pdln->get_lineNumber(&dwLineNumber)) && SUCCEEDED(pdln->get_sourceFile(&pdsf))) { BSTR filename; if(SUCCEEDED(pdsf->get_fileName(&filename))) { if(bGotFile) { if(filename==func.strSourceFile) { if(dwLineNumber<func.nFirstSourceLine) { func.nFirstSourceLine=dwLineNumber; } if(dwLineNumber>func.nLastSourceLine) { func.nLastSourceLine=dwLineNumber; } } } else { bGotFile=true; func.strSourceFile=filename; func.nFirstSourceLine=dwLineNumber; func.nLastSourceLine=dwLineNumber; } LocalFree(filename); } pdsf->Release(); } pdln->Release(); nLineItem++; } pdeln->Release(); } llFuncs.push_back(func); functions[indexId]=curidx; addressmap[*itera]=curidx; curidx++; } } pDIASession->Release(); pDataSource->Release(); // FreeLibrary(mod); return true; }
HRESULT Engine::CGraphicDevice::Initialize(_ulong x, _ulong y, _bool fullsize, HWND hWnd) { _ulong createDeviceFlags = 0; m_iWinSize[0] = x; m_iWinSize[1] = y; m_bFullSize = fullsize; m_hWnd = hWnd; #if defined(DEBUG) || defined(_DEBUG) createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; #endif D3D_FEATURE_LEVEL featureLevel; HRESULT hr = D3D11CreateDevice( 0, //무슨 어뎁터를 사용할 것인가? 0번은 Default D3D_DRIVER_TYPE_HARDWARE, //3D가속을 사용한다. 나머지는 잘 사용 안할듯 0, //소프트웨어 구동기 지정? 무쓸모 createDeviceFlags, //Debug일시, 위 플래그 해주면 디버그 메세지 수신가능. 0, 0, //피쳐레벨 디폴트? D3D11_SDK_VERSION, &m_pDevice, &featureLevel, //지원되는 기능을 넣어주는듯. &m_pContext ); if (FAILED(hr)) { MSGBOX(L"GraphicDevice Create Failed."); return E_FAIL; } if (featureLevel != D3D_FEATURE_LEVEL_11_0) { MSGBOX(L"Feature Level 11 Unsupported."); return E_FAIL; } //Device 생성 _uint iMsaaQuality; hr = m_pDevice->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, 4, &iMsaaQuality); if (FAILED(hr)) { MSGBOX(L"MultiSampling Check Failed."); return E_FAIL; } assert(iMsaaQuality > 0); //멀티 샘플링 지원여부 확인 //A four-component, 32-bit unsigned-normalized-integer //format that supports 8 bits per channel including alpha. DXGI_SWAP_CHAIN_DESC chainDesc; chainDesc.BufferDesc.Width = m_iWinSize[0]; chainDesc.BufferDesc.Height = m_iWinSize[1]; chainDesc.BufferDesc.RefreshRate.Numerator = 60; chainDesc.BufferDesc.RefreshRate.Denominator = 1; chainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; chainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; chainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; if (m_bEnableMsaa == true) { chainDesc.SampleDesc.Count = 4; chainDesc.SampleDesc.Quality = iMsaaQuality - 1; } else { chainDesc.SampleDesc.Count = 1; chainDesc.SampleDesc.Quality = 0; } chainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; chainDesc.BufferCount = 1; chainDesc.OutputWindow = m_hWnd; chainDesc.Windowed = m_bFullSize; chainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; chainDesc.Flags = 0; //스왑체인 구조체 정의 IDXGIDevice* pDxgiDevice = NULL; HR(m_pDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&pDxgiDevice)); IDXGIAdapter* pDxgiAdapter = NULL; HR(pDxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)pDxgiAdapter)); IDXGIFactory* pDxgiFactory = NULL; HR(pDxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&pDxgiFactory)); HR(pDxgiFactory->CreateSwapChain(m_pDevice, &chainDesc, &m_pSwapChain)); ReleaseCOM(pDxgiDevice); ReleaseCOM(pDxgiAdapter); ReleaseCOM(pDxgiFactory); //스왑체인 생성 끝 ID3D11Texture2D* backBuffer; //스왑체인으로부터 받아온 백버퍼 포인터. m_pSwapChain->GetBuffer(0, _uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBuffer)); m_pDevice->CreateRenderTargetView(backBuffer, 0, &m_pRenderTargetView); ReleaseCOM(backBuffer);//GetBuffer시에 Ref가 1 추가되므로 Release. D3D11_TEXTURE2D_DESC depthStencilDesc; depthStencilDesc.Width = m_iWinSize[0]; depthStencilDesc.Height = m_iWinSize[1]; depthStencilDesc.MipLevels = 1; depthStencilDesc.ArraySize = 1; depthStencilDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; if (m_bEnableMsaa == true) { depthStencilDesc.SampleDesc.Count = 4; depthStencilDesc.SampleDesc.Quality = iMsaaQuality - 1; } else { depthStencilDesc.SampleDesc.Count = 1; depthStencilDesc.SampleDesc.Quality = 0; } depthStencilDesc.Usage = D3D11_USAGE_DEFAULT; depthStencilDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL; depthStencilDesc.CPUAccessFlags = 0; depthStencilDesc.MiscFlags = 0; HR(m_pDevice->CreateTexture2D(&depthStencilDesc, 0, &m_pDepthStencilBuffer)); HR(m_pDevice->CreateDepthStencilView(m_pDepthStencilBuffer, 0, &m_pDepthStencilView)); m_pContext->OMSetRenderTargets(1, &m_pRenderTargetView, m_pDepthStencilView); m_tScreenViewport.TopLeftX = 0.f; m_tScreenViewport.TopLeftY = 0.f; m_tScreenViewport.Width = static_cast<float>(m_iWinSize[0]); m_tScreenViewport.Height = static_cast<float>(m_iWinSize[1]); m_tScreenViewport.MinDepth = 0.f; m_tScreenViewport.MaxDepth = 0.f; m_pContext->RSSetViewports(1, &m_tScreenViewport); return S_OK; }
emu_settings::Render_Creator::Render_Creator() { // check for dx12 adapters #ifdef _MSC_VER HMODULE D3D12Module = LoadLibrary(L"d3d12.dll"); if (D3D12Module != NULL) { Microsoft::WRL::ComPtr<IDXGIAdapter1> pAdapter; Microsoft::WRL::ComPtr<IDXGIFactory1> dxgi_factory; if (SUCCEEDED(CreateDXGIFactory1(IID_PPV_ARGS(&dxgi_factory)))) { PFN_D3D12_CREATE_DEVICE wrapD3D12CreateDevice = (PFN_D3D12_CREATE_DEVICE)GetProcAddress(D3D12Module, "D3D12CreateDevice"); if (wrapD3D12CreateDevice != nullptr) { for (UINT adapterIndex = 0; DXGI_ERROR_NOT_FOUND != dxgi_factory->EnumAdapters1(adapterIndex, pAdapter.ReleaseAndGetAddressOf()); ++adapterIndex) { if (SUCCEEDED(wrapD3D12CreateDevice(pAdapter.Get(), D3D_FEATURE_LEVEL_11_0, _uuidof(ID3D12Device), nullptr))) { //A device with D3D12 support found. Init data supportsD3D12 = true; DXGI_ADAPTER_DESC desc; if (SUCCEEDED(pAdapter->GetDesc(&desc))) D3D12Adapters.append(QString::fromWCharArray(desc.Description)); } } } } } #endif #if defined(WIN32) || defined(HAVE_VULKAN) // check for vulkan adapters vk::context device_enum_context; u32 instance_handle = device_enum_context.createInstance("RPCS3", true); if (instance_handle > 0) { device_enum_context.makeCurrentInstance(instance_handle); std::vector<vk::physical_device>& gpus = device_enum_context.enumerateDevices(); if (gpus.size() > 0) { //A device with vulkan support found. Init data supportsVulkan = true; for (auto& gpu : gpus) { vulkanAdapters.append(qstr(gpu.get_name())); } } } #endif // Graphics Adapter D3D12 = Render_Info(name_D3D12, D3D12Adapters, supportsD3D12, emu_settings::D3D12Adapter); Vulkan = Render_Info(name_Vulkan, vulkanAdapters, supportsVulkan, emu_settings::VulkanAdapter); OpenGL = Render_Info(name_OpenGL); NullRender = Render_Info(name_Null); renderers = { &D3D12, &Vulkan, &OpenGL, &NullRender }; }
STDMETHODIMP CContentBasedClassifier::UseRulesAndDefinitions( IFsrmCollection * Rules, IFsrmCollection * propertyDefinitions ) { HRESULT hr = S_OK; _variant_t vRule; CComPtr<IFsrmRule> pFsrmRule; CComPtr<IFsrmClassificationRule> pFsrmClassificationRule; CComBSTR strRuleName; wstring strRuleNameLower; CComBSTR strPropertyName; CComBSTR strPropertyValue; LONG cRuleCount; SAFEARRAY *psaParams = NULL; SAFEARRAY *psaParsedParams = NULL; SAFEARRAYBOUND rgsaBound[1]; LONG paramIndex; LONG lBoundParams; LONG uBoundParams; GUID idRule; m_mapFsrmClassificationRules.clear(); hr = Rules->get_Count( &cRuleCount ); if (hr != S_OK) { goto exit; } //iterate over the rules collection and build a map to store //this map will be used while processing records for matching rules for (LONG iRule = 1; iRule <= cRuleCount; iRule++) { vRule.Clear( ); // Get the next rule hr = Rules->get_Item( iRule, &vRule ); if (hr != S_OK) { goto exit; } // Query for the IFsrmRule interface pFsrmRule.Release( ); hr = vRule.pdispVal->QueryInterface( _uuidof( IFsrmRule ), (void **)&pFsrmRule ); if (hr != S_OK) { goto exit; } // Query for the IFsrmClassificationRule interface pFsrmClassificationRule.Release( ); hr = pFsrmRule->QueryInterface( _uuidof( IFsrmClassificationRule ), (void **)&pFsrmClassificationRule ); if (hr != S_OK) { goto exit; } // Get the rule's name strRuleName.Empty( ); hr = pFsrmRule->get_Name( &strRuleName ); if (hr != S_OK) { goto exit; } // Get the property name for this rule strPropertyName.Empty( ); hr = pFsrmClassificationRule->get_PropertyAffected( &strPropertyName ); if (hr != S_OK) { goto exit; } // Get the property value that will be applied by this rule strPropertyValue.Empty( ); hr = pFsrmClassificationRule->get_Value( &strPropertyValue ); if (hr != S_OK) { goto exit; } // Get the additional classification parameters for this rule psaParams = NULL; hr = pFsrmRule->get_Parameters(&psaParams); if (FAILED(hr)) { goto exit; } // Get the rule id guid ::memset(&idRule, 0, sizeof(GUID)); hr = pFsrmRule->get_Id(&idRule); if (FAILED(hr)) { goto exit; } psaParsedParams = NULL; if (psaParams) { // The additional parameters array contains parameters in the following format // key=value // This classifier treats the key as a value as well since it needs to search for words // in the contents of files. lBoundParams = 0; uBoundParams = 0; hr = SafeArrayGetLBound(psaParams, 1, &lBoundParams); if (FAILED(hr)) { goto exit; } hr = SafeArrayGetUBound(psaParams, 1, &uBoundParams); if (FAILED(hr)) { goto exit; } rgsaBound[0].cElements = ((uBoundParams - lBoundParams + 1) * 2); rgsaBound[0].lLbound = 0; paramIndex = 0; psaParsedParams = SafeArrayCreate(VT_VARIANT, 1, rgsaBound); if (psaParsedParams == NULL) { hr = E_OUTOFMEMORY; goto exit; } for (LONG iParam = lBoundParams; iParam <= uBoundParams; iParam++) { _variant_t vParam; hr = SafeArrayGetElement(psaParams, &iParam, &vParam); if (FAILED(hr)) { goto exit; } CComBSTR strParam = vParam.bstrVal; LPWSTR pwszParamKey = (LPWSTR)strParam; LPWSTR pwszParamVal = ::wcschr(pwszParamKey, L'='); *pwszParamVal = 0; pwszParamVal++; BSTR bstrKey = SysAllocString(pwszParamKey); BSTR bstrVal = SysAllocString(pwszParamVal); _variant_t vKey = bstrKey; _variant_t vVal = bstrVal; hr = SafeArrayPutElement(psaParsedParams, ¶mIndex, &vKey); if (FAILED(hr)) { goto exit; } paramIndex++; hr = SafeArrayPutElement(psaParsedParams, ¶mIndex, &vVal); if (FAILED(hr)) { goto exit; } } //create a new property/value pair to store CFsrmClassificationRule newRule( strPropertyName, strPropertyValue, &psaParsedParams ); //make sure rule name is lower case for ease in matching strRuleNameLower = strRuleName; std::transform( strRuleNameLower.begin( ), strRuleNameLower.end( ), strRuleNameLower.begin( ), towlower ); //add rule with property/value to map m_mapFsrmClassificationRules[idRule] = newRule; } } exit: return hr; }
bool ADOWrap::opemDB(Table* tableItem) { const char* provider; // 数据引擎提供者 const char* extendedProperties; // 扩展属性 if (eXLS == tableItem->m_enExcelType) { provider = XLS_ENGINE_provider; extendedProperties = XLS_ENGINE_extendedProperties; } else { provider = XLSX_ENGINE_provider; extendedProperties = XLSX_ENGINE_extendedProperties; } // com 接口初始化 // 第一个表的名字 _bstr_t _table_name; // 打开数据库的字符串 _bstr_t _strConnect; // 打开表的字符串 _bstr_t _bstrSQL; ::CoInitialize(NULL); _table_name = tableItem->m_lpszDBTableName.c_str(); HRESULT comRet = S_OK; // 打开数据库 try { m_pConnection.CreateInstance("ADODB.Connection"); _strConnect += provider; _strConnect += "Data Source="; _strConnect += tableItem->m_strExcelDirAndName.c_str(); _strConnect += ";"; _strConnect += extendedProperties; comRet = m_pConnection->Open(_strConnect, "", "", adModeUnknown); if (S_FALSE == comRet) { g_pUtils->informationMessage(QStringLiteral("打开数据库发生异常")); return false; } } catch (_com_error e) //捕捉异常 { ::CoUninitialize(); //g_pUtils->informationMessage(QStringLiteral("打开数据库发生异常")); return false; } // 打开第一个表 try { m_pRecordset.CreateInstance(_uuidof(Recordset)); _bstrSQL += "SELECT * FROM "; _bstrSQL += "["; _bstrSQL += _table_name; _bstrSQL += "$]"; // 保证 GetRecordCount 返回正确的结果 m_pRecordset->CursorLocation = adUseClient; comRet = m_pRecordset->Open(_bstrSQL, m_pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText); if (S_FALSE == comRet) { g_pUtils->informationMessage(QStringLiteral("打开表发生异常")); return false; } // 获取记录集的数量 m_count = m_pRecordset->GetRecordCount(); } catch (_com_error e) { m_pConnection->Close(); ::CoUninitialize(); //g_pUtils->informationMessage(QStringLiteral("打开数据库的第一个表发生异常")); return false; } return true; }
void DirectX12Render::InitializeDX() { //Initialize the debug layer of DX12 #ifdef _DEBUG ComPtr<ID3D12Debug> Debug; ThrowFail(D3D12GetDebugInterface(IID_PPV_ARGS(&Debug)), TEXT("Failed to get debug interface")); Debug->EnableDebugLayer(); #endif //Make a factory so we can get our device along with an adapter to store ComPtr<IDXGIFactory4> Factory; ThrowFail(CreateDXGIFactory1(IID_PPV_ARGS(&Factory)), TEXT("Failed to create factory")); ComPtr<IDXGIAdapter1> Adapter; ComPtr<IDXGIAdapter1> TempAdapter; //Get our device for (UINT i = 0; DXGI_ERROR_NOT_FOUND != Factory->EnumAdapters1(i, &TempAdapter); ++i) { DXGI_ADAPTER_DESC1 Desc; TempAdapter->GetDesc1(&Desc); if (Desc.Flags == DXGI_ERROR_NOT_FOUND) continue; //Fake Create it to make sure it will actually work if (S_OK == D3D12CreateDevice(TempAdapter.Get(), D3D_FEATURE_LEVEL_12_1, _uuidof(ID3D12Device), NULL)) break; } Adapter = TempAdapter.Detach(); //Create the device for reals ThrowFail(D3D12CreateDevice(Adapter.Get(), D3D_FEATURE_LEVEL_12_1, _uuidof(ID3D12Device), &Device), TEXT("Failed to create DirectX 12 Device")); //Create Command Queue D3D12_COMMAND_QUEUE_DESC QueueDesc = {}; QueueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; QueueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; ThrowFail(Device->CreateCommandQueue(&QueueDesc, IID_PPV_ARGS(&CommandQueue)), TEXT("Failed to create Command Queue")); //Create the swap chain DXGI_SWAP_CHAIN_DESC SwapDesc = {}; SwapDesc.BufferCount = FrameCount; SwapDesc.BufferDesc.Width = CWindow::GetWidth(); SwapDesc.BufferDesc.Height = CWindow::GetHeight(); SwapDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; SwapDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; SwapDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; SwapDesc.OutputWindow = CWindow::GethWnd(); SwapDesc.SampleDesc.Count = 1; SwapDesc.Windowed = true; //Create a temporary swap chain because CreateSwapChain doesnt support SwapChain3 ComPtr<IDXGISwapChain> FakeSwap; ThrowFail(Factory->CreateSwapChain( CommandQueue.Get(), &SwapDesc, &FakeSwap), TEXT("Fake Swap Chain Failed to create")); //.As() makes its TARGET itself not the otherway around. Causes evil shit if you do it the other way ThrowFail(FakeSwap.As(&SwapChain), TEXT("Real Swap Chain failed to switch")); FenceIndex = SwapChain->GetCurrentBackBufferIndex(); D3D12_DESCRIPTOR_HEAP_DESC RTVDesc = {}; RTVDesc.NumDescriptors = FrameCount; RTVDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; RTVDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; ThrowFail(Device->CreateDescriptorHeap(&RTVDesc, IID_PPV_ARGS(&RTVHeap)), TEXT("Descriptor Heap failed to create")); HeapSize = Device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); CD3DX12_CPU_DESCRIPTOR_HANDLE RTVHandle( RTVHeap->GetCPUDescriptorHandleForHeapStart()); for (UINT i = 0; i < FrameCount; i++) { ThrowFail(SwapChain->GetBuffer(i, IID_PPV_ARGS(&RenderTargets[i])), TEXT("Failed to Get Buffer")); Device->CreateRenderTargetView(RenderTargets[i].Get(), nullptr, RTVHandle); RTVHandle.Offset(1, HeapSize); } ThrowFail(Device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&CommandAllocator)), TEXT("Command Allocator Failed to Initialize")); }