GetHtmlElementAttributeResult GetHtmlElementAttribute(IHTMLElement& htmlElement,
  const ATL::CComBSTR& attributeName)
{
  GetHtmlElementAttributeResult retValue;
  ATL::CComVariant vAttr;
  ATL::CComPtr<IHTMLElement4> htmlElement4;
  if (FAILED(htmlElement.QueryInterface(&htmlElement4)) || !htmlElement4)
  {
    return retValue;
  }
  ATL::CComPtr<IHTMLDOMAttribute> attributeNode;
  if (FAILED(htmlElement4->getAttributeNode(attributeName, &attributeNode)) || !attributeNode)
  {
    return retValue;
  }
  // we set that attribute found but it's not necessary that we can retrieve its value
  retValue.isAttributeFound = true;
  if (FAILED(attributeNode->get_nodeValue(&vAttr)))
  {
    return retValue;
  }
  if (vAttr.vt == VT_BSTR && vAttr.bstrVal)
  {
    retValue.attributeValue = vAttr.bstrVal;
  }
  else if (vAttr.vt == VT_I4)
  {
    retValue.attributeValue = std::to_wstring(vAttr.iVal);
  }
  return retValue;
}
// This is the heuristic which detects the requests issued by Flash.ocx.
// It turned out that the implementation from ''Flash.ocx'' (tested version is 15.0.0.152)
// returns quite minimal configuration in comparison with the implementation from Microsofts'
// libraries (see grfBINDF and bindInfo.dwOptions). The impl from MS often includes something
// else.
bool WBPassthruSink::IsFlashRequest(const wchar_t* const* additionalHeaders)
{
  if (additionalHeaders && *additionalHeaders)
  {
    auto flashVersionHeader = ExtractHttpHeader<std::wstring>(*additionalHeaders, L"x-flash-version:", L"\n");
    if (!TrimString(flashVersionHeader).empty())
    {
      return true;
    }
  }
  ATL::CComPtr<IBindStatusCallback> bscb;
  if (SUCCEEDED(QueryServiceFromClient(&bscb)) && !!bscb)
  {
    DWORD grfBINDF = 0;
    BINDINFO bindInfo = {};
    bindInfo.cbSize = sizeof(bindInfo);
    if (SUCCEEDED(bscb->GetBindInfo(&grfBINDF, &bindInfo)) &&
      (BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE| BINDF_PULLDATA) == grfBINDF &&
      (BINDINFO_OPTIONS_ENABLE_UTF8 | BINDINFO_OPTIONS_USE_IE_ENCODING) == bindInfo.dwOptions
      )
    {
      return true;
    }
  }
  return false;
}
示例#3
0
	HRESULT InjectedType::ReplaceMethodWith(const ModuleID moduleId, const mdToken functionToken, InstructionList &instructions, const mdSignature localVarSigTok, const unsigned minimumStackSize, ExceptionHandlerList &exceptions) const
	{
		IMAGE_COR_ILMETHOD* pMethodHeader = nullptr;
		ULONG iMethodSize = 0;
		GUARD_FAILURE_HRESULT(m_profilerInfo->GetILFunctionBody(moduleId, functionToken, (LPCBYTE*)&pMethodHeader, &iMethodSize));

		Method method(pMethodHeader);
		method.DeleteAllInstructions();
		method.AppendInstructions(instructions);
		method.SetMinimumStackSize(minimumStackSize);

		if (exceptions.size() > 0)
		{
			method.AddExceptionHandlers(exceptions);
		}

		ATL::CComPtr<IMethodMalloc> methodMalloc;
		GUARD_FAILURE_HRESULT(m_profilerInfo->GetILFunctionBodyAllocator(moduleId, &methodMalloc));

		IMAGE_COR_ILMETHOD* pNewMethod = static_cast<IMAGE_COR_ILMETHOD*>(methodMalloc->Alloc(method.GetMethodSize()));
		method.WriteMethod(pNewMethod);

		if (localVarSigTok != mdSignatureNil)
		{
			pNewMethod->Fat.Flags |= CorILMethod_InitLocals; // always added when local variables present: http://www.liranchen.com/2010/07/behind-locals-init-flag.html
			pNewMethod->Fat.LocalVarSigTok = localVarSigTok;
		}

		GUARD_FAILURE_HRESULT(m_profilerInfo->SetILFunctionBody(moduleId, functionToken, (LPCBYTE)pNewMethod));

		return S_OK;
	}
示例#4
0
	HRESULT InjectedType::DefineAssemblyMaxVersionRef(const ModuleID moduleId, LPCWSTR assemblyName, mdModuleRef* moduleRef) const
	{
		ATL::CComPtr<IMetaDataAssemblyEmit> metaDataAssemblyEmit;
		GUARD_FAILURE_HRESULT(GetMetaDataAssemblyEmit(moduleId, metaDataAssemblyEmit));

		AssemblyReference mscorlibReference;
		if (!m_assemblyRegistry->FindMaxAssemblyVersion(assemblyName, mscorlibReference))
		{
			return E_FAIL;
		}

		ASSEMBLYMETADATA mscorlibMetadata;
		ZeroMemory(&mscorlibMetadata, sizeof(mscorlibMetadata));
		mscorlibMetadata.usMajorVersion = mscorlibReference.version.majorVersion;
		mscorlibMetadata.usMinorVersion = mscorlibReference.version.minorVersion;
		mscorlibMetadata.usBuildNumber = mscorlibReference.version.buildNumber;
		mscorlibMetadata.usRevisionNumber = mscorlibReference.version.revisionNumber;

		const auto name = mscorlibReference.name.c_str();
		return metaDataAssemblyEmit->DefineAssemblyRef(mscorlibReference.publicKeyToken,
			sizeof(mscorlibReference.publicKeyToken),
			name,
			&mscorlibMetadata,
			nullptr,
			0,
			0,
			moduleRef);
	}
示例#5
0
HRESULT CSysProgressDlg::ShowModeless(HWND hWndParent, BOOL immediately)
{
    EnsureValid();
    m_hWndProgDlg = NULL;
    if (!IsValid())
        return E_FAIL;
    m_hWndParent = hWndParent;
    HRESULT hr = m_pIDlg->StartProgressDialog(hWndParent, NULL, m_dwDlgFlags, NULL);
    if(FAILED(hr))
        return hr;

    ATL::CComPtr<IOleWindow> pOleWindow;
    HRESULT hr2 = m_pIDlg.QueryInterface(&pOleWindow);
    if(SUCCEEDED(hr2))
    {
        hr2 = pOleWindow->GetWindow(&m_hWndProgDlg);
        if(SUCCEEDED(hr2))
        {
            // see comment in ShowModal() for why we subclass the window
            if (!m_isVisible)
            {
                m_OrigProc = (WNDPROC) SetWindowLongPtr(m_hWndProgDlg, GWLP_WNDPROC, (LONG_PTR) fnSubclass);
                SetProp(m_hWndProgDlg, L"ParentWindow", m_hWndParent);
                SetProp(m_hWndProgDlg, L"OrigProc", m_OrigProc);
            }
            if (immediately)
                ShowWindow(m_hWndProgDlg, SW_SHOW);
        }
    }
    m_isVisible = true;
    return hr;
}
示例#6
0
HRESULT CSysProgressDlg::ShowModeless(HWND hWndParent, BOOL immediately)
{
	EnsureValid();
	m_hWndProgDlg = nullptr;
	if (!IsValid())
		return E_FAIL;
	m_hWndParent = hWndParent;
	auto winId = GetWindowThreadProcessId(m_hWndParent, 0);
	auto threadId = GetCurrentThreadId();
	if (winId != threadId)
		AttachThreadInput(winId, threadId, TRUE);
	m_hWndFocus = GetFocus();
	if (winId != threadId)
		AttachThreadInput(winId, threadId, FALSE);
	HRESULT hr = m_pIDlg->StartProgressDialog(hWndParent, nullptr, m_dwDlgFlags, nullptr);
	if(FAILED(hr))
		return hr;

	ATL::CComPtr<IOleWindow> pOleWindow;
	HRESULT hr2 = m_pIDlg.QueryInterface(&pOleWindow);
	if(SUCCEEDED(hr2))
	{
		hr2 = pOleWindow->GetWindow(&m_hWndProgDlg);
		if(SUCCEEDED(hr2))
		{
			if (immediately)
				ShowWindow(m_hWndProgDlg, SW_SHOW);
		}
	}
	m_isVisible = true;
	return hr;
}
示例#7
0
void DeleteJumpList(LPCTSTR appID)
{
	ATL::CComPtr<ICustomDestinationList> pcdl;
	HRESULT hr = pcdl.CoCreateInstance(CLSID_DestinationList, nullptr, CLSCTX_INPROC_SERVER);
	if (SUCCEEDED(hr)) {
		pcdl->DeleteList(appID);
	}
}
//-------------------------------------------------------------------------------------------------
ALVR_RESULT WaitForCompletion(bool bLeft)
{
    ALVR_RESULT res = g_pLvrDevice->SubmitFence(bLeft ? 0 : 1, g_pFenceD3D11);
    CHECK_ALVR_ERROR_RETURN(res, L"SubmitFence() failed");
    res = g_pFenceD3D11->Wait(2000);
    CHECK_ALVR_ERROR_RETURN(res, L"g_pFenceD3D11->Wait() failed");

    return ALVR_OK;
}
void ListViewAccServer::ClearProvider( HWND hControl )
{
    ATL::CComPtr<IAccPropServices> pAccPropSvc;
    HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);
    if (hr == S_OK && pAccPropSvc)
    {
        MSAAPROPID propid = PROPID_ACC_HELP;
        pAccPropSvc->ClearHwndProps(hControl, (DWORD)OBJID_CLIENT, CHILDID_SELF, &propid, 1);
    }
}
示例#10
0
	HRESULT InjectedType::GetRVAFromKnownDefaultCtor(ATL::CComPtr<IMetaDataImport>& metaDataImport,
		const LPCWSTR knownTypeDefName,
		mdTypeDef* pKnownTypeDef,
		mdMethodDef* pKnownTypeDefaultCtorDef,
		ULONG* pCodeRVA)
	{
		GUARD_FAILURE_HRESULT(metaDataImport->FindTypeDefByName(knownTypeDefName, mdTokenNil, pKnownTypeDef));
		GUARD_FAILURE_HRESULT(metaDataImport->FindMethod(*pKnownTypeDef, L".ctor", ctorSignature, sizeof(ctorSignature), pKnownTypeDefaultCtorDef));
		GUARD_FAILURE_HRESULT(metaDataImport->GetMethodProps(*pKnownTypeDefaultCtorDef, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr, pCodeRVA, nullptr));

		return S_OK;
	}
示例#11
0
bool CCommonAppUtils::SetAccProperty(HWND hWnd, MSAAPROPID propid, const CString& text)
{
    ATL::CComPtr<IAccPropServices> pAccPropSvc;
    HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);

    if (hr == S_OK && pAccPropSvc)
    {
        pAccPropSvc->SetHwndPropStr(hWnd, (DWORD)OBJID_CLIENT, CHILDID_SELF, propid, text);
        return true;
    }
    return false;
}
示例#12
0
	bool InjectedType::HasTypeDef(const ModuleID moduleId, const LPCWSTR typeDefName) const
	{
		ATL::CComPtr<IMetaDataImport> metaDataImport;
		auto result = GetMetaDataImport(moduleId, metaDataImport);
		if (result != S_OK)
		{
			return false;
		}

		mdTypeDef systemObject = mdTokenNil;
		result = metaDataImport->FindTypeDefByName(typeDefName, mdTokenNil, &systemObject);
		return result == S_OK;
	}
示例#13
0
bool CCommonAppUtils::SetAccProperty(HWND hWnd, MSAAPROPID propid, long value)
{
    ATL::CComPtr<IAccPropServices> pAccPropSvc;
    HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);

    if (hr == S_OK && pAccPropSvc)
    {
        VARIANT var;
        var.vt = VT_I4;
        var.intVal = value;
        pAccPropSvc->SetHwndProp(hWnd, (DWORD)OBJID_CLIENT, CHILDID_SELF, propid, var);
        return true;
    }
    return false;
}
示例#14
0
HRESULT CSysProgressDlg::ShowModal(HWND hWndParent, BOOL immediately /* = true */)
{
    EnsureValid();
    m_hWndProgDlg = NULL;
    if (!IsValid())
        return E_FAIL;
    m_hWndParent = hWndParent;
    HRESULT hr = m_pIDlg->StartProgressDialog(hWndParent, NULL, m_dwDlgFlags | PROGDLG_MODAL, NULL);
    if(FAILED(hr))
        return hr;

    ATL::CComPtr<IOleWindow> pOleWindow;
    HRESULT hr2 = m_pIDlg.QueryInterface(&pOleWindow);
    if(SUCCEEDED(hr2))
    {
        hr2 = pOleWindow->GetWindow(&m_hWndProgDlg);
        if(SUCCEEDED(hr2))
        {
            // StartProgressDialog creates a new thread to host the progress window.
            // When the window receives WM_DESTROY message StopProgressDialog() wrongly
            // attempts to re-enable the parent in the calling thread (our thread),
            // after the progress window is destroyed and the progress thread has died.
            // When the progress window dies, the system tries to assign a new foreground window.
            // It cannot assign to hwndParent because StartProgressDialog (w/PROGDLG_MODAL) disabled the parent window.
            // So the system hands the foreground activation to the next process that wants it in the
            // system foreground queue. Thus we lose our right to recapture the foreground window.
            // The way to fix this bug is to insert a call to EnableWindow(hWndParent) in the WM_DESTROY
            // handler for the progress window in the progress thread.

            // To do that, we Subclass the progress dialog
            // Since the window and thread created by the progress dialog object live on a few
            // milliseconds after calling Stop() and Release(), we must not store anything
            // in member variables of this class but must only store everything in the window
            // itself: thus we use SetProp()/GetProp() to store the data.
            if (!m_isVisible)
            {
                m_OrigProc = (WNDPROC) SetWindowLongPtr(m_hWndProgDlg, GWLP_WNDPROC, (LONG_PTR) fnSubclass);
                SetProp(m_hWndProgDlg, L"ParentWindow", m_hWndParent);
                SetProp(m_hWndProgDlg, L"OrigProc", m_OrigProc);
            }
            if(immediately)
                ShowWindow(m_hWndProgDlg, SW_SHOW);
        }
    }

    m_isVisible = true;
    return hr;
}
示例#15
0
bool IsItemInArray(IShellItem *psi, IObjectArray *poaRemoved)
{
	UINT cItems;
	if (FAILED(poaRemoved->GetCount(&cItems)))
		return false;

	bool fRet = false;
	for (UINT i = 0; !fRet && i < cItems; i++) {
		ATL::CComPtr<IShellItem> psiCompare;
		if (FAILED(poaRemoved->GetAt(i, IID_PPV_ARGS(&psiCompare))))
			continue;
		int iOrder;
		fRet = SUCCEEDED(psiCompare->Compare(psi, SICHINT_CANONICAL, &iOrder)) && (0 == iOrder);
	}
	return fRet;
}
示例#16
0
HRESULT CreateShellLink(PCWSTR pszArguments, PCWSTR pszTitle, int iconIndex, IShellLink **ppsl)
{
    ATL::CComPtr<IShellLink> psl;
    HRESULT hr = psl.CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER);
    if (FAILED(hr))
        return hr;

    WCHAR szAppPath[MAX_PATH];
    if (GetModuleFileName(NULL, szAppPath, _countof(szAppPath)) == 0)
    {
        hr = HRESULT_FROM_WIN32(GetLastError());
        return hr;
    }
    hr = psl->SetPath(szAppPath);
    if (FAILED(hr))
        return hr;

    hr = psl->SetArguments(pszArguments);
    if (FAILED(hr))
        return hr;

    hr = psl->SetIconLocation(szAppPath, iconIndex);
    if (FAILED(hr))
        return hr;

    ATL::CComPtr<IPropertyStore> pps;
    hr = psl.QueryInterface(&pps);
    if (FAILED(hr))
        return hr;

    PROPVARIANT propvar;
    hr = InitPropVariantFromString(pszTitle, &propvar);
    if (SUCCEEDED(hr))
    {
        hr = pps->SetValue(PKEY_Title, propvar);
        if (SUCCEEDED(hr))
        {
            hr = pps->Commit();
            if (SUCCEEDED(hr))
            {
                hr = psl.QueryInterface(ppsl);
            }
        }
        PropVariantClear(&propvar);
    }
    return hr;
}
示例#17
0
//
// IClassFactory implementation
//
HRESULT __stdcall CFactory::CreateInstance(IUnknown* pUnknownOuter, const IID& iid, void** ppv)
{
	if (!ppv)
		return E_POINTER;

	// Cannot aggregate.
	if (pUnknownOuter)
		return CLASS_E_NOAGGREGATION ;

	// Create component.
	ATL::CComPtr<GitWCRev> pA;
	pA.Attach(new (std::nothrow) GitWCRev()); // refcount set to 1 in constructor
	if (!pA)
		return E_OUTOFMEMORY ;

	return pA->QueryInterface(iid, ppv);
}
示例#18
0
	ProgressTaskBar(__RPC__in HWND hwnd, ULONGLONG Total)
		: hwnd(hwnd)
		, Total(Total)
	{
		if (FAILED(CoInitialize(nullptr)))
			ATL::AtlThrowLastWin32();
		if (FAILED(TaskbarList.CoCreateInstance(CLSID_TaskbarList)))
			ATL::AtlThrowLastWin32();
	}
//-------------------------------------------------------------------------------------------------
ALVR_RESULT D3DHelperLateLatch::CreateConstantBuffer()
{
    ALVR_RESULT res = ALVR_OK;

    Locker lock(&m_Sect);

    m_pLateLatchBufferLeft.Release();
    m_pLateLatchBufferRight.Release();

    res = g_pLvrDevice->CreateLateLatchConstantBufferD3D11(sizeof(ConstantBuffer), 1024, 0, &m_pLateLatchBufferLeft);
    CHECK_ALVR_ERROR_RETURN(res, L"CreateLateLatchConstantBufferD3D11() failed");


    res = g_pLvrDevice->CreateLateLatchConstantBufferD3D11(sizeof(ConstantBuffer), 1024, 0, &m_pLateLatchBufferRight);
    CHECK_ALVR_ERROR_RETURN(res, L"CreateLateLatchConstantBufferD3D11() failed");


    return ALVR_OK;
}
ListViewAccServer * ListViewAccServer::CreateProvider(HWND hControl, ListViewAccProvider * provider)
{
    ATL::CComPtr<IAccPropServices> pAccPropSvc;
    HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);
    if (hr == S_OK && pAccPropSvc)
    {
        ListViewAccServer * pLVServer = new (std::nothrow) ListViewAccServer(pAccPropSvc);
        if (pLVServer)
        {
            pLVServer->m_pAccProvider = provider;

            MSAAPROPID propid = PROPID_ACC_HELP;
            pAccPropSvc->SetHwndPropServer(hControl, (DWORD)OBJID_CLIENT, CHILDID_SELF, &propid, 1, pLVServer, ANNO_CONTAINER);
            pLVServer->Release();
        }
        return pLVServer;
    }
    return NULL;
}
示例#21
0
	void remote_host::get_clsid( const CATID& cat_id, LPCOLESTR server_name, CLSID& server_id )
	{
		DWPRINT( L"get_clsid( %s )\n", server_name );

		CATID Implist[1] = { cat_id };
		ATL::CComPtr<IEnumCLSID> iEnum;
		HRESULT result = root_->EnumClassesOfCategories( 1, Implist, 0, NULL, &iEnum );
		if (FAILED(result))
		{
			throw opc_exception( result, OLESTR("Failed to get enum for categeories") );
		}

		GUID glist;
		ULONG actual;
		while((result = iEnum->Next( 1, &glist, &actual )) == S_OK)
		{
			cotask_holder<OLECHAR> progID;
			cotask_holder<OLECHAR> userType;
			HRESULT res = root_->GetClassDetails( glist, progID.addr(), userType.addr() );

			if(FAILED(res))
			{
				throw opc_exception( res, OLESTR("Failed to get ProgId from ClassId") );
			}
			else
			{
				DWPRINT( L"progId = %s\n", progID );
				if ( lstrcmpW( progID.get(), server_name ) == 0 )
				{
					res = root_->CLSIDFromProgID( progID.get(), &server_id );

					if ( FAILED(res) )
					{
						throw opc_exception( res, OLESTR("IOPCServerList::CLSIDFromProgID - Failed to get ClassId from ProgId") );
					}

					return;
				}
			}
		}
	}
示例#22
0
/**
 * Opens the Door! :)
 *
 * Parameters:
 * >szDoor
 * Path to lock device for the door.
 *
 * Returns:
 * N/A.
 */
void perco_exchange::openDoor(_In_ STLADD string_unique_ptr_t&& szDoor)
{
    ATL::CComPtr<PERCo_S20_SDK::IExchangeMain> percoXchg;
    if (SUCCEEDED(percoXchg.CoCreateInstance(__uuidof(PERCo_S20_SDK::CoExchangeMain))))
    {
        if (SUCCEEDED(percoXchg->SetConnect(PERCO_HOST, PERCO_PORT, PERCO_LOGIN, PERCO_PWD)))
        {
            BSTR szDBVersion;
            BSTR szSDKVersion;
            if (!percoXchg->CheckVersion(&szDBVersion, &szSDKVersion))
            {
                ATL::CComPtr<IXMLDOMDocument2> request = getSendCommandsRequest(std::move(szDoor));
                AtlTrace2(ATL::atlTraceGeneral, 0, "Sending the 'sendcommands' request.\r\n");
                if (request && SUCCEEDED(percoXchg->ExecuteCommand(request)))
                {
                    AtlTrace2(ATL::atlTraceGeneral, 0, "PERCo has responded to the 'sendcommands' request.\r\n");
                }
            }
            percoXchg->DisConnect();
        }
    }
    else
    {
        AtlTrace2(ATL::atlTraceCOM, 0, "'PERCo_S20_SDK::IExchangeMain' ain't registered.\r\n");
    }
}
示例#23
0
	//*
	void local_host::get_clsid( const CATID& cat_id, LPCOLESTR server_name, CLSID& server_id )
	{
#if defined _DEBUG && defined _CONSOLE
		wprintf( L"get_clsid( %s )\n", server_name );
#endif

		CATID Implist[1] = { cat_id };
		ATL::CComPtr<IEnumCLSID> iEnum;
		HRESULT result = root_->EnumClassesOfCategories(1, Implist,0, NULL, &iEnum);
		if (FAILED(result))
		{
			throw opc_exception( result, OLESTR("Failed to get enum for categeories") );
		}

		GUID glist;
		ULONG actual;
		while((result = iEnum->Next(1, &glist, &actual)) == S_OK)
		{
			cotask_holder<OLECHAR> progID;

			HRESULT res = ProgIDFromCLSID(glist, progID.addr());			
			if(FAILED(res))
			{
				throw opc_exception( res, OLESTR("Failed to get ProgId from ClassId") );
			}
			else 
			{
#if defined _DEBUG && defined _CONSOLE
				wprintf( L"progId = %s\n", progID );
#endif
				if ( lstrcmpW( progID.get(), server_name ) == 0 )
				{
					server_id = glist;

					return;					
				}																
			}
		}
	}
示例#24
0
void dumpTypeLibrary(IDispatch* dispatchToDump, std::wostream& toOutput)
{
    toOutput << L"Start dumping!" << std::endl;
    COMUTILS_RETURN_IF_FAILED_START;

    UINT typeLibCount = 0;
    COMUTILS_RETURN_IF_FAILED(dispatchToDump->GetTypeInfoCount(&typeLibCount), toOutput, L"Failed to get type count");

    toOutput << "Type Library count: " << typeLibCount << std::endl;
    if (typeLibCount == 0) return;

    ATL::CComPtr<ITypeInfo> typeInfoOfObj = NULL;
    COMUTILS_RETURN_IF_FAILED(dispatchToDump->GetTypeInfo(NULL, LOCALE_SYSTEM_DEFAULT, &typeInfoOfObj), toOutput, L"Failed to get type info");
    toOutput << L"DEBUG: Got type info!" << std::endl;
    toOutput << L"DEBUG: Ptr to ITypeLib: " << std::hex << (int)typeInfoOfObj.p << std::dec << std::endl;

    ATL::CComPtr<ITypeLib> typeLibOfObj = NULL;
    UINT index = 0;
    COMUTILS_RETURN_IF_FAILED(typeInfoOfObj->GetContainingTypeLib(&typeLibOfObj, &index), toOutput, L"Failed to get type lib");
    toOutput << "DEBUG: Got type lib with index " << index << std::endl;
    
    /*

    TYPEATTR* descriptor = NULL;
    COMUTILS_RETURN_IF_FAILED(typeInfoOfObj->GetTypeAttr(&descriptor), toOutput, L"Failed to get descriptor!");
    toOutput << L"DEBUG: Got descriptor!" << std::endl;
    toOutput << std::hex << (UINT)descriptor << std::dec << std::endl;

    dumpTYPEATTR(descriptor, toOutput);
    
    
    typeInfoOfObj->ReleaseTypeAttr(descriptor);

    toOutput << L"DEBUG: Released descriptor!" << std::endl;

    */

}
示例#25
0
HRESULT CreateSeparatorLink(IShellLink **ppsl)
{
	ATL::CComPtr<IPropertyStore> pps;
	HRESULT hr = pps.CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER);
	if (FAILED(hr))
		return hr;

	PROPVARIANT propvar;
	hr = InitPropVariantFromBoolean(TRUE, &propvar);
	if (FAILED(hr))
		return hr;

	hr = pps->SetValue(PKEY_AppUserModel_IsDestListSeparator, propvar);
	if (SUCCEEDED(hr)) {
		hr = pps->Commit();
		if (SUCCEEDED(hr))
		{
			hr = pps.QueryInterface(ppsl);
		}
	}
	PropVariantClear(&propvar);
	return hr;
}
//-------------------------------------------------------------------------------------------------
ALVR_RESULT Terminate()
{
    g_MouseInput.Terminate();

    g_pFenceD3D11.Release();


    g_pLvrDevice.Release();

    ::DestroyWindow(g_hWindow);

    g_D3DHelper.Terminate();

#if defined(AFFINITY_WORK_AROUND)
    m_pLvrAffinity.Release();
#endif

    g_pFactory = NULL;

    ::FreeLibrary(g_hLiquidVRDLL);

    return ALVR_OK;
}
//-------------------------------------------------------------------------------------------------
ALVR_RESULT Init()
{
    HRESULT hr = S_OK;

    //---------------------------------------------------------------------------------------------
    // Init ALVR
    //---------------------------------------------------------------------------------------------

    ALVR_RESULT res = ALVR_OK;
    g_hLiquidVRDLL = LoadLibraryW(ALVR_DLL_NAME);
    CHECK_RETURN(g_hLiquidVRDLL != NULL, ALVR_FAIL, L"DLL " << ALVR_DLL_NAME << L" is not found");


    ALVRInit_Fn pInit = (ALVRInit_Fn)GetProcAddress(g_hLiquidVRDLL, ALVR_INIT_FUNCTION_NAME);
    res = pInit(ALVR_FULL_VERSION, (void**)&g_pFactory);
    CHECK_ALVR_ERROR_RETURN(res, ALVR_INIT_FUNCTION_NAME << L"failed");

#if defined(AFFINITY_WORK_AROUND)

    res = g_pFactory->CreateGpuAffinity(&m_pLvrAffinity);
    //    CHECK_ALVR_ERROR_RETURN(res, L"CreateGpuAffinity() failed");

    if(m_pLvrAffinity != NULL)
    {
        res = m_pLvrAffinity->EnableGpuAffinity(ALVR_GPU_AFFINITY_FLAGS_NONE);
        CHECK_ALVR_ERROR_RETURN(res, L"EnableGpuAffinity() failed");

        res = m_pLvrAffinity->DisableGpuAffinity();
        CHECK_ALVR_ERROR_RETURN(res, L"EnableGpuAffinity() failed");
    }
#endif

    //---------------------------------------------------------------------------------------------
    // create D3D11 device
    //---------------------------------------------------------------------------------------------
    res = g_D3DHelper.CreateD3D11Device();
    CHECK_ALVR_ERROR_RETURN(res, L"CreateD3D11Device() failed");


    res = g_pFactory->CreateALVRDeviceExD3D11(g_D3DHelper.m_pd3dDevice, NULL, &g_pLvrDevice);
    CHECK_ALVR_ERROR_RETURN(res, L"CreateALVRDeviceExD3D11() failed");

    res = g_pLvrDevice->CreateFence(&g_pFenceD3D11);
    CHECK_ALVR_ERROR_RETURN(res, L"CreateFence() failed");

    //---------------------------------------------------------------------------------------------
    // create window
    //---------------------------------------------------------------------------------------------
    HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);

    WNDCLASSEX wcex     = {0};
    wcex.cbSize         = sizeof(WNDCLASSEX);
    wcex.style          = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
    wcex.lpfnWndProc    = MyDefWindowProcW;
    wcex.cbClsExtra     = 0;
    wcex.cbWndExtra     = 0;
    wcex.hInstance      = hInstance;
    wcex.hIcon          = NULL;
    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW + 1);
    wcex.lpszClassName  = L"SimpleMGPU";
    wcex.hIconSm        = NULL;

    RegisterClassEx(&wcex);

    int posX = 0;
    int posY = 0;

    UINT count=0;
    int adapterIDLocal = 0;

    DISPLAY_DEVICE displayDevice;
    displayDevice.cb = sizeof(displayDevice);

    while(true)
    {

        if(EnumDisplayDevices(NULL, count, &displayDevice, 0) == FALSE)
        {
            break;
        }
        if(displayDevice.StateFlags & DISPLAY_DEVICE_ACTIVE)
        {
            if(displayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
            {
                break;
            }
            adapterIDLocal++;
        }
        count++;
    }
    EnumDisplayMonitors(NULL, NULL, MyDisplayEnumProc, (LPARAM)displayDevice.DeviceName);
    // find adapter and provide coordinates
    unsigned int width =  (g_MonitorWorkArea.right - g_MonitorWorkArea.left) * 2 / 3;
    unsigned int height =  (g_MonitorWorkArea.bottom - g_MonitorWorkArea.top) * 2 / 3;
    posX = (g_MonitorWorkArea.left + g_MonitorWorkArea.right) / 2 - width / 2;
    posY = (g_MonitorWorkArea.top + g_MonitorWorkArea.bottom) / 2 - height / 2;

    //    GetWindowPosition(posX, posY);
    g_hWindow = CreateWindow(L"SimpleMGPU", L"SimpleMGPU", WS_POPUP,
                             posX, posY, width, height, NULL, NULL, hInstance, NULL);
    CHECK_RETURN(g_hWindow != NULL, ALVR_FAIL, L"Window failed to create");

    ::ShowWindow(g_hWindow, SW_NORMAL);
    ::UpdateWindow(g_hWindow);

    //---------------------------------------------------------------------------------------------
    // Create swap chain
    //---------------------------------------------------------------------------------------------

    res = g_D3DHelper.CreateSwapChain(g_hWindow, g_iBackbufferCount);
    CHECK_ALVR_ERROR_RETURN(res, L"CreateSwapChain() failed");

    //---------------------------------------------------------------------------------------------
    // prepare 3D scene
    //---------------------------------------------------------------------------------------------
    res = g_D3DHelper.Create3DScene(width, height, true);
    CHECK_ALVR_ERROR_RETURN(res, L"Create3DScene() failed");

    g_MouseInput.Init((HINSTANCE)GetModuleHandle(NULL), g_hWindow, &g_D3DHelper, 200);
    g_MouseInput.SetEmulation(true);

    return ALVR_OK;
}
示例#28
0
	void SetProgressValue(ULONGLONG Completed)
	{
		TaskbarList->SetProgressValue(hwnd, Completed, Total);
	}
示例#29
0
	~ProgressTaskBar()
	{
		TaskbarList->SetProgressState(hwnd, TBPF_NOPROGRESS);
	}
示例#30
0
/**
* Create XML document to send 'sendcommands' request via the 'PERCo_S20_SDK::IExchangeMain'.
*
* Parameters:
 * >szDoor
 * Path to lock device for the door.
*
* Returns:
* XML document instance.
*/
ATL::CComPtr<IXMLDOMDocument2> perco_exchange::getSendCommandsRequest(_In_ STLADD string_unique_ptr_t&& szDoor) const
{
    ATL::CComPtr<IXMLDOMDocument2> document;
    if (SUCCEEDED(document.CoCreateInstance(CLSID_DOMDocument60, nullptr, CLSCTX_INPROC_SERVER)))
    {
        ATL::CComPtr<IXMLDOMProcessingInstruction> processingInstruction;
        if (SUCCEEDED(document->createProcessingInstruction(
            TEXT("xml"), TEXT("version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\""), &processingInstruction)))
        {
            document->appendChild(processingInstruction, nullptr);
            // Create root <documentrequest> element.
            ATL::CComPtr<IXMLDOMElement> documentRequest;
            if (SUCCEEDED(document->createElement(TEXT("documentrequest"), &documentRequest)))
            {
                ATL::CComPtr<IXMLDOMAttribute> attribute;
                if (SUCCEEDED(document->createAttribute(TEXT("type"), &attribute)))
                {
                    ATL::CComVariant value(TEXT("sendcommands"));
                    if (SUCCEEDED(attribute->put_value(value)) &&
                        SUCCEEDED(documentRequest->setAttributeNode(attribute, nullptr)) &&
                        SUCCEEDED(document->appendChild(documentRequest, nullptr)))
                    {
                        attribute.Release();
                        ATL::CComPtr<IXMLDOMElement> login;
                        if (SUCCEEDED(document->createElement(TEXT("login"), &login)) &&
                            SUCCEEDED(document->createAttribute(TEXT("loginname"), &attribute)))
                        {
                            value = TEXT("login name");
                            if (SUCCEEDED(attribute->put_value(value)) &&
                                SUCCEEDED(login->setAttributeNode(attribute, nullptr)) &&
                                SUCCEEDED(documentRequest->appendChild(login, nullptr)))
                            {
                                ATL::CComPtr<IXMLDOMElement> command;
                                if (SUCCEEDED(document->createElement(TEXT("command"), &command)))
                                {
                                    attribute.Release();
                                    if (SUCCEEDED(document->createAttribute(TEXT("commandnumber"), &attribute)))
                                    {
                                        // cmd #120 is "unlock device reader".
                                        value = "120";
                                        if (SUCCEEDED(attribute->put_value(value)))
                                        {
                                            command->setAttributeNode(attribute, nullptr);
                                        }
                                    }
                                    attribute.Release();
                                    if (SUCCEEDED(document->createAttribute(TEXT("commandname"), &attribute)))
                                    {
//                                        value = L"Открыть (разблокировать) ИУ";
                                        value = L"";
                                        if (SUCCEEDED(attribute->put_value(value)))
                                        {
                                            command->setAttributeNode(attribute, nullptr);
                                        }
                                    }
                                    attribute.Release();
                                    if (SUCCEEDED(document->createAttribute(TEXT("commandpath"), &attribute)))
                                    {
                                        value = szDoor->c_str();
                                        if (SUCCEEDED(attribute->put_value(value)))
                                        {
                                            command->setAttributeNode(attribute, nullptr);
                                        }
                                    }
                                    attribute.Release();
                                    if (SUCCEEDED(document->createAttribute(TEXT("devicename"), &attribute)))
                                    {
//                                        value = L"Считыватель №2";
                                        value = L"";
                                        if (SUCCEEDED(attribute->put_value(value)))
                                        {
                                            command->setAttributeNode(attribute, nullptr);
                                        }
                                    }
                                    attribute.Release();
                                    if (SUCCEEDED(document->createAttribute(TEXT("typename"), &attribute)))
                                    {
//                                        value = L"ReaderTI1_";
                                        value = L"";
                                        if (SUCCEEDED(attribute->put_value(value)))
                                        {
                                            command->setAttributeNode(attribute, nullptr);
                                        }
                                    }
                                    if (SUCCEEDED(login->appendChild(command, nullptr)))
                                    {
                                        ATL::CComPtr<IXMLDOMElement> commandAttributes;
                                        if (SUCCEEDED(
                                            document->createElement(TEXT("command_attributes"), &commandAttributes)) &&
                                            SUCCEEDED(command->appendChild(commandAttributes, nullptr)))
                                        {
                                            ATL::CComPtr<IXMLDOMElement> commandAttribute;
                                            if (SUCCEEDED(
                                                document->createElement(TEXT("command_attribute"), &commandAttribute)))
                                            {
                                                attribute.Release();
                                                if (SUCCEEDED(
                                                    document->createAttribute(TEXT("displayname"), &attribute)))
                                                {
//                                                    value = L"Время разблокировки";
                                                    value = L"";
                                                    if (SUCCEEDED(attribute->put_value(value)))
                                                    {
                                                        commandAttribute->setAttributeNode(attribute, nullptr);
                                                    }
                                                }
                                                attribute.Release();
                                                if (SUCCEEDED(document->createAttribute(TEXT("value"), &attribute)))
                                                {
                                                    value = L"5";
                                                    if (SUCCEEDED(attribute->put_value(value)))
                                                    {
                                                        commandAttribute->setAttributeNode(attribute, nullptr);
                                                    }
                                                }
                                                attribute.Release();
                                                if (SUCCEEDED(
                                                    document->createAttribute(TEXT("rangeindex"), &attribute)))
                                                {
                                                    value = L"1";
                                                    if (SUCCEEDED(attribute->put_value(value)))
                                                    {
                                                        commandAttribute->setAttributeNode(attribute, nullptr);
                                                    }
                                                }
                                                if (FAILED(commandAttributes->appendChild(commandAttribute, nullptr)))
                                                {
                                                    document.Release();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    szDoor.reset();
    return document;
}