コード例 #1
0
ファイル: IbnCommandWnd.cpp プロジェクト: alex765022/IBN
void CIbnCommandWnd::SendFile(CComPtr<IXMLDOMNode>	&pRootNode)
{
    USES_CONVERSION;

    CComBSTR bsTmpFileName;


    CComPtr<IXMLDOMNode>	pFileNode;
    pRootNode->selectSingleNode(CComBSTR(L"request/file"),&pFileNode);
    if(pFileNode==NULL)
        return;
    pFileNode->get_text(&bsTmpFileName);

    CComPtr<IXMLDOMNodeList>	pRecipientIdNodeList	=	NULL;
    pRootNode->selectNodes(CComBSTR(L"request/recipients/id"),&pRecipientIdNodeList);
    if(pRecipientIdNodeList==NULL)
        return;

    SendFileInfo *pSendFileInfo = new SendFileInfo();

    long listLength	=	0;
    pRecipientIdNodeList->get_length(&listLength);

    CString strRecepientId = _T("");

    for(int index=0; index<listLength; index++)
    {
        CComBSTR bsUserId;

        CComPtr<IXMLDOMNode>	pIdNode	=	NULL;
        pRecipientIdNodeList->get_item(index,&pIdNode);

        pIdNode->get_text(&bsUserId);

        strRecepientId = W2CT(bsUserId);

        pSendFileInfo->RecepientID += strRecepientId;
        pSendFileInfo->RecepientID += _T(",");
    }



    if(listLength==1)
    {
        int globalId = _ttol(strRecepientId);
        CUser user;
        if(pMessenger->GetUserByGlobalId(globalId, user))
        {
            pSendFileInfo->RecepientName = 	user.GetShowName();
        }
        else
            pSendFileInfo->RecepientName = _T("Screen Capture User Group");
    }
    else
        pSendFileInfo->RecepientName = _T("Screen Capture User Group");
    pSendFileInfo->Description = GetString(IDS_SCREEN_CAPTURE_NAME);
    pSendFileInfo->File = W2CT(bsTmpFileName);

    pMessenger->PostMessage(WM_SEND_FILE2, (WPARAM)pSendFileInfo);
}
コード例 #2
0
ファイル: trace.cpp プロジェクト: hackshields/antivirus
	static void outputDebugStringV(
								const wchar_t*	module,
								const wchar_t*	format,
								va_list			args)
	{
		USES_CONVERSION;
		wchar_t		szBuffer[2048]=L"";
		const int	nBuffer=sizeof(szBuffer)/sizeof(szBuffer[0]);
		int result=0;

		if(0)//if(module)
		{
			const int nCharsToStore=nBuffer/2;
			result=_snwprintf(szBuffer, nCharsToStore, L"%ls: ", module);
			szBuffer[nCharsToStore-1]=0;
			if(result < 0)
				wcscat(szBuffer, L"...\n");
			OutputDebugString(W2CT(szBuffer));
		};
		const int nCharsToStore=nBuffer/2;
		result=_vsnwprintf(szBuffer, nCharsToStore, format, args);
		szBuffer[nCharsToStore-1]=0;
		if(result < 0)
			wcscat(szBuffer, L"...\n");
		OutputDebugString(W2CT(szBuffer));
	};
コード例 #3
0
ファイル: InviteChatDlg.cpp プロジェクト: alex765022/IBN
void CInviteChatDlg::OnMcChatDetails()
{
	USES_CONVERSION;
	CChatCreateDlg	*pChatDetailsDlg = new CChatCreateDlg(pMessenger);

	pChatDetailsDlg->Create(CChatCreateDlg::CCDM_DETAIL,W2CT(m_Chat.GetName()),W2CT(m_Chat.GetDescription()),NULL,&(m_Chat.GetUsers()),m_Chat.GetId());
	pMessenger->AddToAllCloseWindow(pChatDetailsDlg->GetSafeHwnd());
	// Load UserCollections to  CChatCreateDlg [8/8/2002]
	pChatDetailsDlg->ShowWindow(SW_SHOW);
}
コード例 #4
0
int WINAPI DetourMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
{
	USES_CONVERSION;
	wstring msg(W2CT(lpText));
	if(msg.find(L"当前安全设置禁止") != wstring::npos)
		return IDOK;
	if(msg.find(L"功能失败") != wstring::npos)
		return IDOK;
	return mhMessageBox(hWnd, W2CT(lpText), W2CT(lpCaption), uType);
}
コード例 #5
0
ファイル: CodeCoverage.cpp プロジェクト: tomstaijen/opencover
/// <summary>Handle <c>ICorProfilerCallback::ModuleAttachedToAssembly</c></summary>
/// <remarks>Inform the host that we have a new module attached and that it may be 
/// of interest</remarks>
HRESULT STDMETHODCALLTYPE CCodeCoverage::ModuleAttachedToAssembly( 
    /* [in] */ ModuleID moduleId,
    /* [in] */ AssemblyID assemblyId)
{
    std::wstring modulePath = GetModulePath(moduleId);
    std::wstring assemblyName = GetAssemblyName(assemblyId);
    ATLTRACE(_T("::ModuleAttachedToAssembly(%X => %s, %X => %s)"), 
        moduleId, W2CT(modulePath.c_str()), 
        assemblyId, W2CT(assemblyName.c_str()));
    m_allowModules[modulePath] = m_host.TrackAssembly((LPWSTR)modulePath.c_str(), (LPWSTR)assemblyName.c_str());
    m_allowModulesAssemblyMap[modulePath] = assemblyName;

    return S_OK; 
}
コード例 #6
0
void CLibraryDetailView::OnFindItemW(NMLVFINDITEM* pNotify, LRESULT* pResult)
{
	USES_CONVERSION;
	LPCTSTR pszFind = W2CT( (LPCWSTR)pNotify->lvfi.psz );
	
	GET_LIST();
	CQuickLock oLock( Library.m_pSection );

	for ( int nLoop = 0 ; nLoop < 2 ; nLoop++ )
	{
		for ( int nItem = pNotify->iStart ; nItem < pList->GetItemCount() ; nItem++ )
		{
			if ( CLibraryFile* pFile = Library.LookupFile( m_pList[ nItem ].nIndex ) )
			{
				if ( pNotify->lvfi.flags & LVFI_STRING )
				{
					if ( _tcsnicmp( pszFind, pFile->m_sName, _tcslen( pszFind ) ) == 0 )
					{
						*pResult = nItem;
						return;
					}
				}
			}
		}
		pNotify->iStart = 0;
	}

	*pResult = -1;
}
コード例 #7
0
ファイル: ShellMgr.Cpp プロジェクト: Bizonu/amclibrary
BOOL CShellMgr::GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags, LPTSTR lpFriendlyName)
{
	BOOL bSuccess = TRUE;
	STRRET str = { STRRET_CSTR };

	if (lpsf->GetDisplayNameOf(lpi, dwFlags, &str) == NOERROR)
	{
		USES_CONVERSION;

		switch (str.uType)
		{
		case STRRET_WSTR:
			lstrcpy(lpFriendlyName, W2CT(str.pOleStr));
			::CoTaskMemFree(str.pOleStr);
			break;
		case STRRET_OFFSET:
			lstrcpy(lpFriendlyName, (LPTSTR)lpi + str.uOffset);
			break;
		case STRRET_CSTR:
			lstrcpy(lpFriendlyName, A2CT(str.cStr));
			break;
		default:
			bSuccess = FALSE;
			break;
		}
	}
	else
	{
		bSuccess = FALSE;
	}

	return bSuccess;
}
コード例 #8
0
ファイル: WGUrlReceiver.cpp プロジェクト: naroya/freedownload
void CWGUrlReceiver::CheckRapidshare()
{
	USES_CONVERSION;
	extern LPCTSTR strcmpi_m (LPCTSTR pszWhere, LPCTSTR pszWhat);
	fsURL url;
	if (IR_SUCCESS != url.Crack (W2CT (m_dlInfo.bstrUrl)))
		return;
	if (_tcsicmp (url.GetHostName (), _T("rapidshare.com")) == 0 ||
			strcmpi_m (url.GetHostName (), _T("*.rapidshare.com")) == 0)
	{
		tstring strPath = url.GetPath ();
		LPCTSTR psz = _tcsrchr (strPath.c_str (), _T('#'));
		if (psz)
		{
			strPath.erase (strPath.begin () + (psz-strPath.c_str ()), strPath.end ());
			fsURL url2;
			TCHAR szUrl [10000] = _T("");
			DWORD dwSize = _countof (szUrl);
			if (IR_SUCCESS == url2.Create (url.GetInternetScheme (), url.GetHostName (), url.GetPort (), 
					url.GetUserName (), url.GetPassword (), strPath.c_str (), szUrl, &dwSize))
			{
				m_dlInfo.bstrUrl = T2CW (szUrl);
			}
		}
	}
}
コード例 #9
0
int WINAPI DetourMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
{
    USES_CONVERSION;
    wstring msg(W2CT(lpText));
    if(msg.find(L"当前安全设置禁止") != wstring::npos)
        return IDOK;
    if(msg.find(L"功能失败") != wstring::npos)
        return IDOK;
    if(msg.find(L"Adobe Flash Player") != wstring::npos)
    {
        if(FlashAlertTime > 0)
            return IDCANCEL;
        else
        {
            lpText = L"您没有安装Adobe Flash Player,点击确定将访问Adobe.com,请您下载安装";
            FlashAlertTime = 2;
        }
    }
    return mhMessageBox(hWnd, W2CT(lpText), W2CT(lpCaption), uType);
}
コード例 #10
0
ファイル: UserAcct.cpp プロジェクト: borgified/Allegiance
HRESULT TCUserAccount::SetRunAsUser(LPCTSTR szAppID, LPCTSTR szPassword)
{
  // Not supported under Windows9x
  if (IsWin9x())
    return S_FALSE;

  // Fail if Init has not been called successfully
  if (!m_hPolicy || m_spSIDPrincipal.IsNull())
    return E_UNEXPECTED;

  // Concatenate the user name onto the domain name
  USES_CONVERSION;
  UINT cch = wcslen(m_spszDomainName) + wcslen(m_spszUserName) + 2;
  LPTSTR pszUserName = (LPTSTR)_alloca(cch * sizeof(TCHAR));
  _tcscpy(pszUserName, W2CT(m_spszDomainName));
  _tcscat(pszUserName, TEXT("\\"));
  _tcscat(pszUserName, W2CT(m_spszUserName));

  // Delegate to the static method
  return SetRunAsUser(szAppID, pszUserName, szPassword);
}
コード例 #11
0
ファイル: InviteChatDlg.cpp プロジェクト: alex765022/IBN
void CInviteChatDlg::SetInfo(CChat &Chat, CUser &user, BSTR Data)
{
	USES_CONVERSION;

	m_User	= user;

	m_Chat	=	Chat;
	
	CString strNickText;
	strNickText.Format(GetString(IDS_INVITE_CHAT_NICK_NAME),m_User.GetShowName());
	m_Nick.SetWindowText(strNickText);

	m_bsHTML	=	L"<HTML><HEAD><META http-equiv=Content-Type content='text/html;charset=UTF-16'/><STYLE>P{margin: 0 0 0 0;}</STYLE></HEAD><BODY bottomMargin=2 leftMargin=2 rightMargin=2 topMargin=2>";
	m_bsHTML	+= Data;
	m_bsHTML	+= L"</BODY></HTML>";

	m_edit.Navigate(_T("about:blank"),0,0,0,0);

	CString strWindowsCaption;
	strWindowsCaption.Format(GetString(IDD_INVITE_CHAT_DIALOG_TEXT),W2CT(m_Chat.GetName()));
	
	SetWindowText(strWindowsCaption);
	
	UpdateData(FALSE);
	
	if(m_User.IsBad())
	{
		if(!Handle)
		{
			if(pMessenger->ConnectEnable())
			{
				theNet2.LockTranslator();
				try
				{
					Handle = pSession->UserDetails(m_User.GetGlobalID(),1);
					if(Handle)
					{
						Block();
						theNet2.AddToTranslator(Handle,this->GetSafeHwnd());
					}
				}
				catch (_com_error&) 
				{
					ASSERT(FALSE);
				}
				
				theNet2.UnlockTranslator();
			}
		}
	}
}
コード例 #12
0
ファイル: PageMesTemplate.cpp プロジェクト: alex765022/IBN
BOOL CPageMesTemplates::SaveSettings()
{
	UpdateData();

	WriteOptionInt(IDS_OFSMESSENGER,IDS_SEND_MESSAGE_TEMPLATE_AUTO,m_ShowAuto);

	CComPtr<IXMLDOMDocument>	pMTDoc	=	NULL;
	pMTDoc.CoCreateInstance(CLSID_DOMDocument40,NULL,CLSCTX_INPROC_SERVER);

	if(pMTDoc)
	{
		USES_CONVERSION;

		CComBSTR	bsRootXML	=	L"<message_templates/>";

		VARIANT_BOOL	varLoad	=	VARIANT_FALSE;
		pMTDoc->loadXML(bsRootXML,&varLoad);

		//-------------------------------------------------------------------------------------
		CComPtr<IXMLDOMNode>	pRoot;

		pMTDoc->selectSingleNode(L"message_templates",&pRoot);

		for(int Index = 0; Index<m_TemplateList.GetItemCount();Index++)
		{
			CComPtr<IXMLDOMNode>	pItem;
			insertSingleNode(pRoot,CComBSTR(L"mt"),NULL,NULL,&pItem);

			
			insertSingleNode(pItem,CComBSTR(L"name"),NULL,T2BSTR(m_TemplateList.GetItemText(Index,0)));
			insertSingleNode(pItem,CComBSTR(L"text"),NULL,T2BSTR(m_TemplateList.GetItemText(Index,1)));
		}

		//-------------------------------------------------------------------------------------

		CString strSection;
		strSection.Format(_T("%s\\%s\\%d"),GetString(IDS_INFO),m_UserRole,m_UserId);

		CComBSTR bsOutXML;
		pMTDoc->get_xml(&bsOutXML);

		//-------------------------------------------------------------------------------------

		CString strMessageTemplateXML = W2CT(bsOutXML);
			
		SetRegFileText(strSection,GetString(IDS_MESSAGE_TEMPLATES_REG),strMessageTemplateXML);
	}

	return CMcSettingsPage::SaveSettings();
}
コード例 #13
0
ファイル: CodeCoverage.cpp プロジェクト: vaidhy/opencover
/// <summary>Handle <c>ICorProfilerCallback::ModuleAttachedToAssembly</c></summary>
/// <remarks>Inform the host that we have a new module attached and that it may be 
/// of interest</remarks>
HRESULT STDMETHODCALLTYPE CCodeCoverage::ModuleAttachedToAssembly( 
    /* [in] */ ModuleID moduleId,
    /* [in] */ AssemblyID assemblyId)
{
	if (m_chainedProfiler != NULL)
		m_chainedProfiler->ModuleAttachedToAssembly(moduleId, assemblyId);

    std::wstring modulePath = GetModulePath(moduleId);
    std::wstring assemblyName = GetAssemblyName(assemblyId);
    /*ATLTRACE(_T("::ModuleAttachedToAssembly(...) => (%X => %s, %X => %s)"), 
        moduleId, W2CT(modulePath.c_str()), 
        assemblyId, W2CT(assemblyName.c_str()));*/
    m_allowModules[modulePath] = m_host.TrackAssembly((LPWSTR)modulePath.c_str(), (LPWSTR)assemblyName.c_str());
    m_allowModulesAssemblyMap[modulePath] = assemblyName;

    if (m_allowModules[modulePath]){
        ATLTRACE(_T("::ModuleAttachedToAssembly(...) => (%X => %s, %X => %s)"),
            moduleId, W2CT(modulePath.c_str()),
            assemblyId, W2CT(assemblyName.c_str()));
    }

    return S_OK; 
}
コード例 #14
0
/// <summary>Handle <c>ICorProfilerCallback::ModuleAttachedToAssembly</c></summary>
/// <remarks>Inform the host that we have a new module attached and that it may be 
/// of interest</remarks>
HRESULT STDMETHODCALLTYPE CCodeInjection::ModuleAttachedToAssembly( 
    /* [in] */ ModuleID moduleId,
    /* [in] */ AssemblyID assemblyId)
{
    ULONG dwNameSize = 512;
    WCHAR szAssemblyName[512] = {0};
    COM_FAIL_RETURN(m_profilerInfo3->GetAssemblyInfo(assemblyId, 
        dwNameSize, &dwNameSize, szAssemblyName, NULL, NULL), S_OK);
    ATLTRACE(_T("::ModuleAttachedToAssembly(%X => ?, %X => %s)"), 
        moduleId, assemblyId, W2CT(szAssemblyName));

    if (lstrcmp(L"ProfilerTarget", szAssemblyName) == 0) {
        
        m_targetMethodRef = 0;
        // get reference to injected
        mdModuleRef injectedRef;
        COM_FAIL_RETURN(GetInjectedRef(moduleId, injectedRef), S_OK);

        // get interfaces
        CComPtr<IMetaDataEmit> metaDataEmit;
        COM_FAIL_RETURN(m_profilerInfo3->GetModuleMetaData(moduleId, 
            ofRead | ofWrite, IID_IMetaDataEmit, (IUnknown**)&metaDataEmit), S_OK);

        static COR_SIGNATURE methodCallSignature[] = 
        {
            IMAGE_CEE_CS_CALLCONV_DEFAULT,   
            0x01,                                   
            ELEMENT_TYPE_VOID,
            ELEMENT_TYPE_OBJECT
        };

        // get method to call
        mdTypeRef classTypeRef;
        COM_FAIL_RETURN(metaDataEmit->DefineTypeRefByName(injectedRef, 
             L"Injected.Logger", &classTypeRef), S_OK);
        COM_FAIL_RETURN(metaDataEmit->DefineMemberRef(classTypeRef, 
            L"Log", methodCallSignature, 
            sizeof(methodCallSignature), &m_targetMethodRef), S_OK);

        // get object ref
        mdModuleRef mscorlibRef;
        COM_FAIL_RETURN(GetMsCorlibRef(moduleId, mscorlibRef), S_OK);    
        COM_FAIL_RETURN(metaDataEmit->DefineTypeRefByName(mscorlibRef, 
             L"System.Object", &m_objectTypeRef), S_OK);
    }

    return S_OK;
}
コード例 #15
0
bool vmsBindStatusCallback::CheckIfFileNameEncoded(LPCSTR pszFileName)
{
	if (strlen (pszFileName) < 13)
		return false;

	if (strnicmp (pszFileName, "=?UTF-8?", 8))
		return false;

	LPCSTR psz = pszFileName + 8;
	if (*psz != 'B' && *psz != 'b') 
		return false;
	if (psz [1] != '?')
		return false; 

	psz += 2;

	string str;
	while (psz [1] && (*psz != '?' || psz [1] != '='))
		str += *psz++;

	if (*psz != '?' || psz [1] != '=')
		return false; 

	LPBYTE pb = new BYTE [str.length ()];
	
	int len = base64_decode (str.c_str (), pb);
	if (len <= 0)
	{
		delete [] pb;
		return false; 
	}

	LPWSTR pwsz = new wchar_t [len+1];
	*pwsz = 0;
	len = MultiByteToWideChar (CP_UTF8, 0, (LPCSTR)pb, len, pwsz, len);
	if (len > 0)
		pwsz [len] = 0;
	USES_CONVERSION;
	m_tstrFileName = W2CT (pwsz);

	delete [] pb;
	delete [] pwsz;

	return true;
}
コード例 #16
0
/// <summary>Handle <c>ICorProfilerCallback::JITCompilationStarted</c></summary>
/// <remarks>The 'workhorse' </remarks>
HRESULT STDMETHODCALLTYPE CCodeInjection::JITCompilationStarted( 
        /* [in] */ FunctionID functionId, /* [in] */ BOOL fIsSafeToBlock) 
{
    ModuleID moduleId; mdToken funcToken;
    std::wstring methodName = GetMethodName(functionId, 
        moduleId, funcToken);
    ATLTRACE(_T("::JITCompilationStarted(%X -> %s)"), 
        functionId, W2CT(methodName.c_str()));

    if (L"ProfilerTarget.Program.TargetMethod" == methodName && 
        m_targetMethodRef !=0 ) {
        // get method body
        LPCBYTE pMethodHeader = NULL;
        ULONG iMethodSize = 0;
        COM_FAIL_RETURN(m_profilerInfo3->GetILFunctionBody(
            moduleId, funcToken, &pMethodHeader, &iMethodSize), 
            S_OK);

        // parse IL
        Method instMethod((IMAGE_COR_ILMETHOD*)pMethodHeader); // <--

        // insert new IL block
        InstructionList instructions;
        instructions.push_back(new Instruction(CEE_LDARG_0));
        instructions.push_back(new Instruction(CEE_CALL, m_targetMethodRef));

        instMethod.InsertSequenceInstructionsAtOriginalOffset(
            1, instructions);

        instMethod.DumpIL();

        // allocate memory
        CComPtr<IMethodMalloc> methodMalloc;
        COM_FAIL_RETURN(m_profilerInfo3->GetILFunctionBodyAllocator(
            moduleId, &methodMalloc), S_OK);
        void* pNewMethod = methodMalloc->Alloc(instMethod.GetMethodSize());

        // write new method
        instMethod.WriteMethod((IMAGE_COR_ILMETHOD*)pNewMethod);
        COM_FAIL_RETURN(m_profilerInfo3->SetILFunctionBody(moduleId, 
            funcToken, (LPCBYTE) pNewMethod), S_OK);
    }

    return S_OK;
}
コード例 #17
0
ファイル: DbOledb.cpp プロジェクト: okigan/dblib
BOOL COledbRecordset::GetColumnName(short iIndex, TCHAR* pstrName, UINT cchMax)
{
   _ASSERTE(IsOpen());
   _ASSERTE(cchMax>0);
   _ASSERTE(!::IsBadWritePtr(pstrName, cchMax));
   iIndex = iIndex + m_iAdjustIndex;
   _ASSERTE(iIndex>=0 && iIndex<m_nCols);
   // Find entry in the NULL-terminated string buffer
   LPCWSTR pwstr = m_pwstrNameBuffer;
   if( pwstr == NULL ) return FALSE;
   while( iIndex > 0 ) {
      pwstr += ::lstrlenW(pwstr) + 1;
      iIndex--;
   }
   // Copy name
   USES_CONVERSION;
   ::lstrcpyn(pstrName, W2CT(pwstr), cchMax);
   return TRUE;
}
コード例 #18
0
ファイル: DbOledb.cpp プロジェクト: okigan/dblib
BOOL COledbRecordset::GetField(short iIndex, CString& pData)
{
   _ASSERTE(IsOpen());
   iIndex += m_iAdjustIndex;
   _ASSERTE(iIndex>=0 && iIndex<m_nCols);
   // NOTE: We should never be forced to convert between MBCS/UNICODE because
   //       the column binding sets up the desired TCHAR type.
   USES_CONVERSION;
   switch( m_rgBindings[iIndex].wType ) {
   case DBTYPE_STR:
      pData = A2CT( (char*) ((LPBYTE) m_pData + m_rgBindings[iIndex].obValue) );
      return TRUE;
   case DBTYPE_WSTR:
      pData = W2CT( (WCHAR*) ((LPBYTE) m_pData + m_rgBindings[iIndex].obValue) );
      return TRUE;
   default:
      _ASSERTE(false);
      return FALSE;
   }
}
コード例 #19
0
// CCodeInjection
HRESULT STDMETHODCALLTYPE CCodeInjection::Initialize( 
    /* [in] */ IUnknown *pICorProfilerInfoUnk) 
{
    OLECHAR szGuid[40]={0};
    int nCount = ::StringFromGUID2(CLSID_CodeInjection, szGuid, 40);
    ATLTRACE(_T("::Initialize - %s"), W2CT(szGuid));
    
    m_profilerInfo3 = pICorProfilerInfoUnk;
    if (m_profilerInfo3 == NULL) return E_FAIL;

    DWORD dwMask = 0;
    dwMask |= COR_PRF_MONITOR_MODULE_LOADS;			// Controls the ModuleLoad, ModuleUnload, and ModuleAttachedToAssembly callbacks.
    dwMask |= COR_PRF_MONITOR_JIT_COMPILATION;	    // Controls the JITCompilation, JITFunctionPitched, and JITInlining callbacks.
    dwMask |= COR_PRF_DISABLE_INLINING;				// Disables all inlining.
    dwMask |= COR_PRF_DISABLE_OPTIMIZATIONS;		// Disables all code optimizations.

    m_profilerInfo3->SetEventMask(dwMask);

    return S_OK;
}
コード例 #20
0
ファイル: WGUrlReceiver.cpp プロジェクト: naroya/freedownload
void CWGUrlReceiver::CheckYouTubePicture(){
	if (m_dlInfo.bstrUrl.Length() == 0)
		return;

	fsURL url;
	if (IR_SUCCESS != url.Crack(W2CT(m_dlInfo.bstrUrl)))
		return;

	std::wstring sUrl(m_dlInfo.bstrUrl);
	auto youTubeParserDllMgr = vmsYouTubeParserDllMgr::get();
	if (!youTubeParserDllMgr)
	{
		return;
	}
	auto extractor = youTubeParserDllMgr->objectsHolder()->createResourceObject(L"");
	std::wstring youTubeID;
	if (extractor && extractor->object()->extractIDFromImageURL(sUrl, youTubeID)){
		std::wstring youTubeDownloadURL = extractor->object()->createDownloadURLFromID(youTubeID);
		m_dlInfo.bstrUrl = T2CW(youTubeDownloadURL.c_str());
	}
}
コード例 #21
0
ファイル: DropTarget.cpp プロジェクト: techpub/archive-code
HRESULT CMainFrameDropTarget::PasteHDROP(COleDataObject &data)
{
	HRESULT hrPasteResult = E_FAIL;
	HANDLE hMem;
	if ((hMem = data.GetGlobalData(CF_HDROP)) != NULL)
	{
		LPDROPFILES lpDrop;
		if ((lpDrop = (LPDROPFILES)GlobalLock(hMem)) != NULL)
		{
			if (lpDrop->fWide)
			{
				LPCWSTR pszFileNameW = (LPCWSTR)((LPBYTE)lpDrop + lpDrop->pFiles);
				while (*pszFileNameW != L'\0')
				{
					USES_CONVERSION;
					if (FAILED(AddUrlFileContents(W2CT(pszFileNameW))))
						break;
					hrPasteResult = S_OK;
					pszFileNameW += wcslen(pszFileNameW) + 1;
				}
			}
			else
			{
				LPCSTR pszFileNameA = (LPCSTR)((LPBYTE)lpDrop + lpDrop->pFiles);
				while (*pszFileNameA != '\0')
				{
					USES_CONVERSION;
					if (FAILED(AddUrlFileContents(A2CT(pszFileNameA))))
						break;
					hrPasteResult = S_OK;
					pszFileNameA += strlen(pszFileNameA) + 1;
				}
			}
			GlobalUnlock(hMem);
		}
		GlobalFree(hMem);
	}
	return hrPasteResult;
}
コード例 #22
0
ファイル: SysParams.cpp プロジェクト: RyanZDM/DataSyncService
BOOL CSysParams::GetStringValue(_RecordsetPtr pRS, LONG lIndex, LPTSTR *ppBuf, DWORD &dwLen)
{
	_variant_t vRetVal = pRS->Fields->GetItem(_variant_t(lIndex))->GetValue();

	if (VT_NULL == vRetVal.vt)
	{
		dwLen = 0;
		*ppBuf = NULL;
		return TRUE;
	}

	if (VT_BSTR != vRetVal.vt)
		return FALSE;

	dwLen = 0;
	LPCTSTR itemId = W2CT((BSTR)vRetVal.pbstrVal);
	size_t len = _tcslen(itemId) + 1;
	*ppBuf = new TCHAR[len];
	_tcscpy_s(*ppBuf, len, itemId);

	return TRUE;
}
コード例 #23
0
ファイル: HelperAppDlg.cpp プロジェクト: rn10950/RetroZilla
void AppLauncherDlg::OnInitDialog()
{
    USES_CONVERSION;
    nsCOMPtr<nsIMIMEInfo> mimeInfo;
    nsCAutoString url;
    if (mHelperAppLauncher)
    {
        mHelperAppLauncher->GetMIMEInfo(getter_AddRefs(mimeInfo));
        nsCOMPtr<nsIURI> uri;
        mHelperAppLauncher->GetSource(getter_AddRefs(uri));
        uri->GetSpec(url);
    }
    nsMIMEInfoHandleAction prefAction = nsIMIMEInfo::saveToDisk;
    nsAutoString appName;
    nsCAutoString contentType;
    if (mimeInfo)
    {
        mimeInfo->GetPreferredAction(&prefAction);
        mimeInfo->GetApplicationDescription(appName);
        mimeInfo->GetMIMEType(contentType);
    }
    if (prefAction == nsIMIMEInfo::saveToDisk)
    {
        CheckRadioButton(mHwndDlg, IDC_OPENWITHAPP, IDC_SAVETOFILE, IDC_SAVETOFILE);
    }
    else
    {
        CheckRadioButton(mHwndDlg, IDC_OPENWITHAPP, IDC_SAVETOFILE, IDC_OPENWITHAPP);
    }
    SetDlgItemText(mHwndDlg, IDC_URL,
        url.IsEmpty() ? _T("") : A2CT(url.get()));
    SetDlgItemText(mHwndDlg, IDC_APPLICATION,
        appName.IsEmpty() ? _T("<No Application>") : W2CT(appName.get()));
    SetDlgItemText(mHwndDlg, IDC_CONTENTTYPE,
        contentType.IsEmpty() ? _T("") : A2CT(contentType.get()));
}
コード例 #24
0
ファイル: PageMesTemplate.cpp プロジェクト: alex765022/IBN
BOOL CPageMesTemplates::OnInitDialog() 
{
	CMcSettingsPage::OnInitDialog();

	m_ShowAuto =  GetOptionInt(IDS_OFSMESSENGER,IDS_SEND_MESSAGE_TEMPLATE_AUTO,1);

	DWORD dwStyle = m_TemplateList.GetExtendedStyle();
	dwStyle |= LVS_EX_FULLROWSELECT;
	m_TemplateList.SetExtendedStyle(dwStyle);

	m_TemplateList.InsertColumn(0,GetString(IDS_TEMPLATE_NAME),LVCFMT_LEFT,150);
	m_TemplateList.InsertColumn(1,GetString(IDS_TEMPLATE_TEXT),LVCFMT_LEFT,300);

	if(m_UserId)
	{
		// Step 1. Load Color Settings [8/24/2002]
		CString strSection;
		strSection.Format(_T("%s\\%s\\%d"),GetString(IDS_INFO),m_UserRole,m_UserId);

		CString strMessageTemplateXML = GetRegFileText(strSection,GetString(IDS_MESSAGE_TEMPLATES_REG));

		if(strMessageTemplateXML.IsEmpty())
			strMessageTemplateXML = GetString(IDS_DEFAULT_MES_TEMPLATE_XML);


		CComPtr<IXMLDOMDocument>	pMTDoc	=	NULL;
		pMTDoc.CoCreateInstance(CLSID_DOMDocument40,NULL,CLSCTX_INPROC_SERVER);

		if(pMTDoc)
		{
			CComBSTR bsXML;
			bsXML.Attach(strMessageTemplateXML.AllocSysString());
			
			VARIANT_BOOL	varLoad	=	VARIANT_FALSE;
			
			pMTDoc->loadXML(bsXML,&varLoad);

			if(varLoad==VARIANT_FALSE)
			{
				bsXML.Empty();

				strMessageTemplateXML = GetString(IDS_DEFAULT_MES_TEMPLATE_XML);
				bsXML.Attach(strMessageTemplateXML.AllocSysString());

				pMTDoc->loadXML(bsXML,&varLoad);
			}

			if(varLoad==VARIANT_TRUE)
			{
				CComPtr<IXMLDOMNodeList>	pTemplatesList	=	NULL;
					
				pMTDoc->selectNodes(CComBSTR(L"message_templates/mt"),&pTemplatesList);

				if(pTemplatesList!=NULL)
				{
					USES_CONVERSION;

					long ListLength	=	0;
					pTemplatesList->get_length(&ListLength);

					for(int Index=0;Index<ListLength;Index++)
					{
						CComBSTR	bsName, bsText;

						CComPtr<IXMLDOMNode>	pStubNode	=	NULL;
						pTemplatesList->get_item(Index,&pStubNode);

						GetTextByPath(pStubNode, CComBSTR(L"name"),&bsName);
						GetTextByPath(pStubNode, CComBSTR(L"text"),&bsText);

						m_TemplateList.InsertItem(Index,W2CT(bsName));
						m_TemplateList.SetItemText(Index,1,W2CT(bsText));

					}
				}
			}
		}

	}

	UpdateData(FALSE);

	
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
コード例 #25
0
ファイル: CodeCoverage.cpp プロジェクト: tomstaijen/opencover
/// <summary>Handle <c>ICorProfilerCallback::JITCompilationStarted</c></summary>
/// <remarks>The 'workhorse' </remarks>
HRESULT STDMETHODCALLTYPE CCodeCoverage::JITCompilationStarted( 
        /* [in] */ FunctionID functionId,
        /* [in] */ BOOL fIsSafeToBlock)
{
    std::wstring modulePath;
    mdToken functionToken;
    ModuleID moduleId;
    AssemblyID assemblyId;

    if (GetTokenAndModule(functionId, functionToken, moduleId, modulePath, &assemblyId))
    {
        // add the bodies for our cuckoo methods when required
        if (MSCORLIB_NAME == GetAssemblyName(assemblyId))
        {
            if (m_cuckooCriticalToken == functionToken)
            {
                COM_FAIL_RETURNMSG(AddCriticalCuckooBody(moduleId), 
                    _T("    ::JITCompilationStarted => AddCriticalCuckooBody(0x%x)"));
            }

            if (m_cuckooSafeToken == functionToken)
            {
                COM_FAIL_RETURNMSG(AddSafeCuckooBody(moduleId), 
                    _T("    ::JITCompilationStarted => AddSafeCuckooBody(0x%x)"));
            }
        }

        if (!m_allowModules[modulePath]) return S_OK;

        ATLTRACE(_T("::JITCompilationStarted(%X, %d, (%X)%s)"), functionId, functionToken, moduleId, W2CT(modulePath.c_str()));
        
        std::vector<SequencePoint> seqPoints;
        std::vector<BranchPoint> brPoints;

        mdMethodDef injectedVisitedMethod = RegisterSafeCuckooMethod(moduleId);
        
        if (m_host.GetPoints(functionToken, (LPWSTR)modulePath.c_str(), 
            (LPWSTR)m_allowModulesAssemblyMap[modulePath].c_str(), seqPoints, brPoints))
        {
            if (seqPoints.size()==0) return S_OK;

            LPCBYTE pMethodHeader = NULL;
            ULONG iMethodSize = 0;
            COM_FAIL_RETURNMSG(m_profilerInfo2->GetILFunctionBody(moduleId, functionToken, &pMethodHeader, &iMethodSize),
                _T("    ::JITCompilationStarted => GetILFunctionBody(0x%x)"));

            IMAGE_COR_ILMETHOD* pMethod = (IMAGE_COR_ILMETHOD*)pMethodHeader;
            
            CoverageInstrumentation instumentedMethod(pMethod);
            instumentedMethod.IncrementStackSize(2);

            ATLTRACE(_T("::JITCompilationStarted => Instrumenting..."));
            //seqPoints.clear();
            //brPoints.clear();

            instumentedMethod.AddSequenceCoverage(injectedVisitedMethod, seqPoints);
            instumentedMethod.AddBranchCoverage(injectedVisitedMethod, brPoints);
            
            instumentedMethod.DumpIL();

            CComPtr<IMethodMalloc> methodMalloc;
            COM_FAIL_RETURNMSG(m_profilerInfo2->GetILFunctionBodyAllocator(moduleId, &methodMalloc),
                _T("    ::JITCompilationStarted => GetILFunctionBodyAllocator(0x%x)"));
            IMAGE_COR_ILMETHOD* pNewMethod = (IMAGE_COR_ILMETHOD*)methodMalloc->Alloc(instumentedMethod.GetMethodSize());
            instumentedMethod.WriteMethod(pNewMethod);
            COM_FAIL_RETURNMSG(m_profilerInfo2->SetILFunctionBody(moduleId, functionToken, (LPCBYTE) pNewMethod), 
                _T("    ::JITCompilationStarted => SetILFunctionBody(0x%x)"));

            ULONG mapSize = instumentedMethod.GetILMapSize();
            COR_IL_MAP * pMap = (COR_IL_MAP *)CoTaskMemAlloc(mapSize * sizeof(COR_IL_MAP));
            instumentedMethod.PopulateILMap(mapSize, pMap);
            COM_FAIL_RETURNMSG(m_profilerInfo2->SetILInstrumentedCodeMap(functionId, TRUE, mapSize, pMap), 
                _T("    ::JITCompilationStarted => SetILInstrumentedCodeMap(0x%x)"));

            // only do this for .NET4 and above as there are issues with earlier runtimes (Access Violations)
            if (m_runtimeVersion.usMajorVersion >= 4)
                CoTaskMemFree(pMap);
        }
    }
    
    return S_OK; 
}
コード例 #26
0
ファイル: CodeCoverage.cpp プロジェクト: CasparCui/opencover
/// <summary>Handle <c>ICorProfilerCallback::JITCompilationStarted</c></summary>
/// <remarks>The 'workhorse' </remarks>
HRESULT STDMETHODCALLTYPE CCodeCoverage::JITCompilationStarted( 
        /* [in] */ FunctionID functionId,
        /* [in] */ BOOL fIsSafeToBlock)
{
    std::wstring modulePath;
    mdToken functionToken;
    ModuleID moduleId;
    AssemblyID assemblyId;

    if (GetTokenAndModule(functionId, functionToken, moduleId, modulePath, &assemblyId))
    {
        if (OpenCoverSupportRequired(assemblyId, functionId))
            OpenCoverSupportCompilation(functionId, functionToken, moduleId, assemblyId, modulePath);

        CuckooSupportCompilation(assemblyId, functionToken, moduleId);

        if (m_allowModules[modulePath])
        {
            ATLTRACE(_T("::JITCompilationStarted(%X, ...) => %d, %X => %s"), functionId, functionToken, moduleId, W2CT(modulePath.c_str()));

            std::vector<SequencePoint> seqPoints;
            std::vector<BranchPoint> brPoints;

            if (m_host.GetPoints(functionToken, (LPWSTR)modulePath.c_str(),
                (LPWSTR)m_allowModulesAssemblyMap[modulePath].c_str(), seqPoints, brPoints))
            {
                if (seqPoints.size() != 0)
                {
                    LPCBYTE pMethodHeader = NULL;
                    ULONG iMethodSize = 0;
                    COM_FAIL_MSG_RETURN_ERROR(m_profilerInfo2->GetILFunctionBody(moduleId, functionToken, &pMethodHeader, &iMethodSize),
                        _T("    ::JITCompilationStarted(...) => GetILFunctionBody => 0x%X"));

                    IMAGE_COR_ILMETHOD* pMethod = (IMAGE_COR_ILMETHOD*)pMethodHeader;

                    Method instumentedMethod(pMethod);
                    instumentedMethod.IncrementStackSize(2);

                    ATLTRACE(_T("::JITCompilationStarted(...) => Instrumenting..."));
                    //seqPoints.clear();
                    //brPoints.clear();

                    // Instrument method
                    InstrumentMethod(moduleId, instumentedMethod, seqPoints, brPoints);

                    //instumentedMethod.DumpIL();

                    CComPtr<IMethodMalloc> methodMalloc;
                    COM_FAIL_MSG_RETURN_ERROR(m_profilerInfo2->GetILFunctionBodyAllocator(moduleId, &methodMalloc),
                        _T("    ::JITCompilationStarted(...) => GetILFunctionBodyAllocator=> 0x%X"));

                    IMAGE_COR_ILMETHOD* pNewMethod = (IMAGE_COR_ILMETHOD*)methodMalloc->Alloc(instumentedMethod.GetMethodSize());
                    instumentedMethod.WriteMethod(pNewMethod);
                    COM_FAIL_MSG_RETURN_ERROR(m_profilerInfo2->SetILFunctionBody(moduleId, functionToken, (LPCBYTE)pNewMethod),
                        _T("    ::JITCompilationStarted(...) => SetILFunctionBody => 0x%X"));

                    ULONG mapSize = instumentedMethod.GetILMapSize();
                    COR_IL_MAP * pMap = (COR_IL_MAP *)CoTaskMemAlloc(mapSize * sizeof(COR_IL_MAP));
                    instumentedMethod.PopulateILMap(mapSize, pMap);
                    COM_FAIL_MSG_RETURN_ERROR(m_profilerInfo2->SetILInstrumentedCodeMap(functionId, TRUE, mapSize, pMap),
                        _T("    ::JITCompilationStarted(...) => SetILInstrumentedCodeMap => 0x%X"));

                    // only do this for .NET4 and above as there are issues with earlier runtimes (Access Violations)
                    if (m_runtimeVersion.usMajorVersion >= 4)
                        CoTaskMemFree(pMap);

                    // resize the threshold array 
                    if (m_threshold != 0)
                    {
                        if (seqPoints.size() > 0)
                            Resize(seqPoints.back().UniqueId + 1);
                        if (brPoints.size() > 0)
                            Resize(brPoints.back().UniqueId + 1);
                    }
                }
            }
        }
    }
    
    if (m_chainedProfiler != NULL)
        return m_chainedProfiler->JITCompilationStarted(functionId, fIsSafeToBlock);

    return S_OK; 
}
コード例 #27
0
STDMETHODIMP CFDMFlashVideoDownloads::ShowAddDownloadsDialog(BSTR bstrSrcWebPageUrl, SAFEARRAY *psaDownloads)
{
	USES_CONVERSION;

	CComObject <CFdmUiWindow> *pUiWindow = NULL;
	CComObject <CFdmUiWindow>::CreateInstance (&pUiWindow);

	vmsAUTOLOCKSECTION (m_csLastUiWindow);
	m_spLastUiWindow = pUiWindow;
	vmsAUTOLOCKSECTION_UNLOCK (m_csLastUiWindow);

	if (psaDownloads == NULL)
		return E_INVALIDARG;

	UINT cDim = SafeArrayGetDim (psaDownloads);
	if (cDim != 1)
		return E_INVALIDARG;

	LONG lLBound = 0, lUBound = 0;
	SafeArrayGetLBound (psaDownloads, 1, &lLBound);
	SafeArrayGetUBound (psaDownloads, 1, &lUBound);

	std::vector <vmsNewDownloadInfo> *pvDlds = new std::vector <vmsNewDownloadInfo>;

	for (long i = lLBound; i <= lUBound; i++)
	{
		IDispatchPtr spDisp;
		SafeArrayGetElement (psaDownloads, &i, &spDisp);

		IFdmFlvDownloadPtr spFlvDld (spDisp);

		if (spFlvDld == NULL)
		{
			delete pvDlds;
			return E_INVALIDARG;
		}
		IWGUrlReceiverPtr spUrl;
		spFlvDld->get_Url (&spUrl);
		if (spUrl == NULL)
		{
			delete pvDlds;
			return E_INVALIDARG;
		}

		CComBSTR bstr;
		spUrl->get_Url (&bstr);

		CString strUrl = W2CT (bstr);
		bool bSkip = false;

		for (size_t j = 0; j < pvDlds->size (); j++)
		{
			if (pvDlds->at (j).strUrl == strUrl)
			{
				bSkip = true; 
				break;
			}
		}

		if (bSkip)
			continue;

		vmsNewDownloadInfo dlInfo;

		dlInfo.strUrl = W2CA (bstr);

		spUrl->get_Referer (&bstr);
		dlInfo.strReferer = W2CA (bstr);

		spUrl->get_Comment (&bstr);
		dlInfo.strComment = bstr;

		dlInfo.dwWhatIsValid = NDIV_AP;

		dlInfo.ap.dwMask = DWCDAP_FLAGS;
		dlInfo.ap.dwFlags = DWDCDAP_F_FLASHVIDEODOWNLOAD;

		spUrl->get_Cookies (&bstr);
		if (bstr.Length ())
		{
			dlInfo.ap.dwMask |= DWCDAP_COOKIES;
			dlInfo.ap.strCookies = W2CA (bstr);
		}

		spUrl->get_PostData (&bstr);
		if (bstr.Length ())
		{
			dlInfo.ap.dwMask |= DWCDAP_POSTDATA;
			dlInfo.ap.strPostData = W2CA (bstr);
		}

		spUrl->get_FileName (&bstr);
		if (bstr.Length ())
		{
			dlInfo.ap.dwMask |= DWCDAP_FILENAME;
			dlInfo.ap.strFileName = W2CA (bstr);
		}

		spUrl->get_FileSize (&bstr);
		if (bstr.Length ())
		{
			dlInfo.ap.dwMask |= DWCDAP_FILESIZE;
			dlInfo.ap.uFileSize = (UINT64)_wtoi64 (bstr);
		}

		pvDlds->push_back (dlInfo);
	}

	CFlashVideoDownloadsWnd::WmFvdwLparam *lp = new CFlashVideoDownloadsWnd::WmFvdwLparam;
	lp->strSrcWebPageUrl = W2CA(bstrSrcWebPageUrl);
	lp->pvDlds = pvDlds;
	lp->pUiWindow = pUiWindow; 
	if (pUiWindow)
		pUiWindow->AddRef ();
	_pwndFVDownloads->PostMessage (WM_FVDW_CREATEDOWNLOADS, 0, (LPARAM)lp);

	return S_OK;
}
コード例 #28
0
/// <summary>Handle <c>ICorProfilerCallback::ModuleAttachedToAssembly</c></summary>
/// <remarks>Inform the host that we have a new module attached and that it may be 
/// of interest</remarks>
HRESULT STDMETHODCALLTYPE CCodeInjection::ModuleAttachedToAssembly( 
    /* [in] */ ModuleID moduleId,
    /* [in] */ AssemblyID assemblyId)
{
    ULONG dwNameSize = 512;
    WCHAR szAssemblyName[512] = {0};
    COM_FAIL_RETURN(m_profilerInfo3->GetAssemblyInfo(assemblyId, 
        dwNameSize, &dwNameSize, szAssemblyName, NULL, NULL), S_OK);
    ATLTRACE(_T("::ModuleAttachedToAssembly(%X => ?, %X => %s)"), 
        moduleId, assemblyId, W2CT(szAssemblyName));

    if (lstrcmp(L"ProfilerTarget", szAssemblyName) == 0) {
        m_magicExceptionCtor = 0;
        // get reference to mscorlib
        mdModuleRef mscorlibRef;
        COM_FAIL_RETURN(GetMsCorlibRef(moduleId, mscorlibRef), S_OK);

        // get interfaces
        CComPtr<IMetaDataEmit> metaDataEmit;
        COM_FAIL_RETURN(m_profilerInfo3->GetModuleMetaData(moduleId, 
            ofRead | ofWrite, IID_IMetaDataEmit, (IUnknown**)&metaDataEmit), S_OK);

        static COR_SIGNATURE ctorCallSignature[] = 
        {
            IMAGE_CEE_CS_CALLCONV_DEFAULT | IMAGE_CEE_CS_CALLCONV_HASTHIS,   
            0x00,                                   
            ELEMENT_TYPE_VOID
        };

        // get base type and constructor
        mdTypeRef exceptionTypeRef;
        COM_FAIL_RETURN(metaDataEmit->DefineTypeRefByName(mscorlibRef, 
             L"System.Exception", &exceptionTypeRef), S_OK);
        mdMemberRef exceptionCtor;
        COM_FAIL_RETURN(metaDataEmit->DefineMemberRef(exceptionTypeRef, 
            L".ctor", ctorCallSignature, sizeof(ctorCallSignature), 
            &exceptionCtor), S_OK);

        // define new type in our module
        mdTypeDef magicExceptionType;
        COM_FAIL_RETURN(metaDataEmit->DefineTypeDef(
            L"DDDMelbourne2011.MagicException", 
            tdPublic | tdSerializable, exceptionTypeRef, NULL,  
            &magicExceptionType), S_OK);

        // define constructor 
        COM_FAIL_RETURN(metaDataEmit->DefineMethod(magicExceptionType, 
            L".ctor", 
            mdPublic | mdHideBySig | mdSpecialName | mdRTSpecialName, 
            ctorCallSignature, sizeof(ctorCallSignature), 0, 
            miIL | miManaged | miPreserveSig, &m_magicExceptionCtor), S_OK);

        // build and allocate constructor body
        BYTE data[] = {(0x01 << 2) | CorILMethod_TinyFormat, CEE_RET};
        Method ctorMethod((IMAGE_COR_ILMETHOD*)data);
        InstructionList instructions;
        instructions.push_back(new Instruction(CEE_LDARG_0));
        instructions.push_back(new Instruction(CEE_CALL, exceptionCtor));
        ctorMethod.InsertSequenceInstructionsAtOffset(0, instructions);
        ctorMethod.DumpIL();

        CComPtr<IMethodMalloc> methodMalloc;
        COM_FAIL_RETURN(m_profilerInfo3->GetILFunctionBodyAllocator(
            moduleId, &methodMalloc), S_OK);

        void* pMethodBody = methodMalloc->Alloc(ctorMethod.GetMethodSize());
        ctorMethod.WriteMethod((IMAGE_COR_ILMETHOD*)pMethodBody);

        COM_FAIL_RETURN(m_profilerInfo3->SetILFunctionBody(moduleId, 
            m_magicExceptionCtor, (LPCBYTE)pMethodBody), S_OK);
    }

    return S_OK;
}
コード例 #29
0
bool ProfilerCommunication::Initialise(TCHAR *key, TCHAR *ns, TCHAR *processName)
{
	_key = key;
    _processName = processName;

	std::wstring sharedKey = key;
	sharedKey.append(_T("-1"));

    _namespace = ns;

    _mutexCommunication.Initialise((_namespace + _T("\\OpenCover_Profiler_Communication_Mutex_") + _key).c_str());
    if (!_mutexCommunication.IsValid()) return false;
    
    USES_CONVERSION;
    ATLTRACE(_T("ProfilerCommunication::Initialise(...) => Initialised mutexes => %s"), W2CT(sharedKey.c_str()));

    auto resource_name = (_namespace + _T("\\OpenCover_Profiler_Communication_SendData_Event_") + sharedKey);
    _eventProfilerRequestsInformation.Initialise(resource_name.c_str());
    if (!_eventProfilerRequestsInformation.IsValid()) {
        RELTRACE(_T("ProfilerCommunication::Initialise(...) => Failed to initialise resource %s => ::GetLastError() = %d"), W2CT(resource_name.c_str()), ::GetLastError());
        return false;
    }

    resource_name = (_namespace + _T("\\OpenCover_Profiler_Communication_ChunkData_Event_") + sharedKey);
    _eventInformationReadByProfiler.Initialise(resource_name.c_str());
    if (!_eventInformationReadByProfiler.IsValid()) {
        RELTRACE(_T("ProfilerCommunication::Initialise(...) = >Failed to initialise resource %s => ::GetLastError() = %d"), W2CT(resource_name.c_str()), ::GetLastError());
        return false;
    }

    resource_name = (_namespace + _T("\\OpenCover_Profiler_Communication_ReceiveData_Event_") + sharedKey);
    _eventInformationReadyForProfiler.Initialise(resource_name.c_str());
    if (!_eventInformationReadyForProfiler.IsValid()) {
        RELTRACE(_T("ProfilerCommunication::Initialise(...) => Failed to initialise resource %s => ::GetLastError() = %d"), W2CT(resource_name.c_str()), ::GetLastError());
        return false;
    }

    resource_name = (_namespace + _T("\\OpenCover_Profiler_Communication_MemoryMapFile_") + sharedKey);
    _memoryCommunication.OpenFileMapping(resource_name.c_str());
    if (!_memoryCommunication.IsValid()) {
        RELTRACE(_T("ProfilerCommunication::Initialise(...) => Failed to initialise resource %s => ::GetLastError() = %d"), W2CT(resource_name.c_str()), ::GetLastError());
        return false;
    }

    resource_name = (_namespace + _T("\\OpenCover_Profiler_Communication_Semaphore_") + sharedKey);
    _semapore_communication.Initialise(resource_name.c_str());
    if (!_semapore_communication.IsValid()) {
        RELTRACE(_T("ProfilerCommunication::Initialise(...) => Failed to initialise resource %s => ::GetLastError() = %d"), W2CT(resource_name.c_str()), ::GetLastError());
        return false;
    }
    _pMSG = static_cast<MSG_Union*>(_memoryCommunication.MapViewOfFile(0, 0, MAX_MSG_SIZE));

    _hostCommunicationActive = true;

    ATLTRACE(_T("ProfilerCommunication::Initialise(...) => Initialised communication interface => %s"), W2CT(sharedKey.c_str()));

    if (!TrackProcess()){
        RELTRACE(_T("ProfilerCommunication::Initialise(...) => ProfilerCommunication => process is not be tracked"));
        return false;
    }

    ULONG bufferId =  0;
    if (AllocateBuffer(MAX_MSG_SIZE, bufferId))
    {
        std::wstring memoryKey;
        std::wstringstream stream ;
        stream << bufferId;
        stream >> memoryKey;

        _bufferId = bufferId;

        memoryKey = _key + memoryKey;

        ATLTRACE(_T("ProfilerCommunication::Initialise(...) => Re-initialising communication interface => %s"), W2CT(memoryKey.c_str()));

        resource_name = (_namespace + _T("\\OpenCover_Profiler_Communication_SendData_Event_") + memoryKey);
        _eventProfilerRequestsInformation.Initialise(resource_name.c_str());
        if (!_eventProfilerRequestsInformation.IsValid()) {
            RELTRACE(_T("ProfilerCommunication::Initialise(...) => Failed to initialise resource %s => ::GetLastError() = %d"), W2CT(resource_name.c_str()), ::GetLastError());
            _hostCommunicationActive = false;
            return false;
        }

        resource_name = (_namespace + _T("\\OpenCover_Profiler_Communication_ChunkData_Event_") + memoryKey);
        _eventInformationReadByProfiler.Initialise(resource_name.c_str());
        if (!_eventInformationReadByProfiler.IsValid()) {
            RELTRACE(_T("ProfilerCommunication::Initialise(...) => Failed to initialise resource %s => ::GetLastError() = %d"), W2CT(resource_name.c_str()), ::GetLastError());
            _hostCommunicationActive = false;
            return false;
        }

        resource_name = (_namespace + _T("\\OpenCover_Profiler_Communication_ReceiveData_Event_") + memoryKey);
        _eventInformationReadyForProfiler.Initialise(resource_name.c_str());
        if (!_eventInformationReadyForProfiler.IsValid()) {
            RELTRACE(_T("ProfilerCommunication::Initialise(...) => Failed to initialise resource %s => ::GetLastError() = %d"), W2CT(resource_name.c_str()), ::GetLastError());
            _hostCommunicationActive = false;
            return false;
        }

        resource_name = (_namespace + _T("\\OpenCover_Profiler_Communication_MemoryMapFile_") + memoryKey);
        _memoryCommunication.OpenFileMapping(resource_name.c_str());
        if (!_memoryCommunication.IsValid()) {
            RELTRACE(_T("ProfilerCommunication::Initialise(...) => Failed to initialise resource %s => ::GetLastError() = %d"), W2CT(resource_name.c_str()), ::GetLastError());
            _hostCommunicationActive = false;
            return false;
        }

        _pMSG = static_cast<MSG_Union*>(_memoryCommunication.MapViewOfFile(0, 0, MAX_MSG_SIZE));

        resource_name = (_namespace + _T("\\OpenCover_Profiler_Communication_Semaphore_") + memoryKey);
        _semapore_communication.Initialise(resource_name.c_str());
        if (!_semapore_communication.IsValid()) {
            RELTRACE(_T("ProfilerCommunication::Initialise(...) => Failed to initialise resource %s => ::GetLastError() = %d"), W2CT(resource_name.c_str()), ::GetLastError());
            _hostCommunicationActive = false;
            return false;
        }

        ATLTRACE(_T("ProfilerCommunication::Initialise(...) => Re-initialised communication interface => %s"), W2CT(memoryKey.c_str()));

        resource_name = (_namespace + _T("\\OpenCover_Profiler_Results_SendResults_Event_") + memoryKey);
        _eventProfilerHasResults.Initialise(resource_name.c_str());
        if (!_eventProfilerHasResults.IsValid()) {
            RELTRACE(_T("ProfilerCommunication::Initialise(...) => Failed to initialise resource %s => ::GetLastError() = %d"), W2CT(resource_name.c_str()), ::GetLastError());
            _hostCommunicationActive = false;
            return false;
        }

        resource_name = (_namespace + _T("\\OpenCover_Profiler_Results_ReceiveResults_Event_") + memoryKey);
        _eventResultsHaveBeenReceived.Initialise(resource_name.c_str());
        if (!_eventResultsHaveBeenReceived.IsValid()) {
            RELTRACE(_T("ProfilerCommunication::Initialise(...) => Failed to initialise resource %s => ::GetLastError() = %d"), W2CT(resource_name.c_str()), ::GetLastError());
            _hostCommunicationActive = false;
            return false;
        }

        resource_name = (_namespace + _T("\\OpenCover_Profiler_Results_MemoryMapFile_") + memoryKey);
        _memoryResults.OpenFileMapping(resource_name.c_str());
        if (!_memoryResults.IsValid()) {
            RELTRACE(_T("ProfilerCommunication::Initialise(...) => Failed to initialise resource %s => ::GetLastError() = %d"), W2CT(resource_name.c_str()), ::GetLastError());
            _hostCommunicationActive = false;
            return false;
        }

        _pVisitPoints = static_cast<MSG_SendVisitPoints_Request*>(_memoryResults.MapViewOfFile(0, 0, MAX_MSG_SIZE));

        _pVisitPoints->count = 0;

        resource_name = (_namespace + _T("\\OpenCover_Profiler_Results_Semaphore_") + memoryKey);
        _semapore_results.Initialise(resource_name.c_str());
        if (!_semapore_results.IsValid()) {
            RELTRACE(_T("ProfilerCommunication::Initialise(...) => Failed to initialise resource %s => ::GetLastError() = %d"), W2CT(resource_name.c_str()), ::GetLastError());
            _hostCommunicationActive = false;
            return false;
        }

        RELTRACE(_T("ProfilerCommunication::Initialise(...) => Initialised results interface => %s"), W2CT(memoryKey.c_str()));
    }
    else {
コード例 #30
0
// FillList() populates the list control.
void CShellViewImpl::FillList()
{
CComPtr<IEnumIDList> pEnum;
LPITEMIDLIST pidl = NULL;
HRESULT hr;
    
    // Get an enumerator object for the folder's contents.  Since this simple
    // extension doesn't deal with subfolders, we request only non-folder
    // objects.

    hr = m_psfContainingFolder->EnumObjects ( m_hWnd, SHCONTF_NONFOLDERS,
                                              &pEnum );
    
    if ( FAILED(hr) )
        return;
        
    // Stop redrawing to avoid flickering

    m_wndList.SetRedraw ( FALSE );
        
    // Add items.
DWORD dwFetched;

    while ( pEnum->Next(1, &pidl, &dwFetched) == S_OK )
        {
        LVITEM lvi = {0};
        TCHAR szText[MAX_PATH];

        ATLASSERT(1 == dwFetched);  // sanity check

        lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
        lvi.iItem = m_wndList.GetItemCount();
        lvi.iImage = 0;
        
        // Store PIDL to the drive letter, using the lParam member for each item

        TCHAR chDrive = m_PidlMgr.GetData ( pidl );
        lvi.lParam = (LPARAM) m_PidlMgr.Create ( chDrive );
        
        // Column 1: Drive letter

        m_PidlMgr.GetPidlDescription ( pidl, szText );
        lvi.pszText = szText;
        
        m_wndList.InsertItem ( &lvi );

        if ( m_wndList.GetStyle() & LVS_REPORT )
            {
            // Column 2: volume label
            TCHAR szDriveRoot[] = _T("?:\\");
            ULARGE_INTEGER uliFreeSpace, uliTotalSpace;

            *szDriveRoot = chDrive;

            if ( GetVolumeInformation ( szDriveRoot, szText, countof(szText),
                                        NULL, NULL, NULL, NULL, 0 ))
                {
                m_wndList.SetItemText ( lvi.iItem, 1, szText );
                }

            // Columns 3/4: free/total space

            if ( GetDiskFreeSpaceEx ( szDriveRoot, &uliFreeSpace, &uliTotalSpace, NULL ))
                {
                WCHAR szSize[MAX_PATH];
                USES_CONVERSION;

                // Note we use the Unicode API here, since the ANSI one only
                // uses a 32-bit number (max 4 GB) for the size.
                // If you don't mind a dependence on IE 5, use 
                // StrFormatByteSize64() instead.

                StrFormatByteSizeW ( uliFreeSpace.QuadPart, szSize, countof(szSize) );
                m_wndList.SetItemText ( lvi.iItem, 2, W2CT(szSize) );

                StrFormatByteSizeW ( uliTotalSpace.QuadPart, szSize, countof(szSize) );
                m_wndList.SetItemText ( lvi.iItem, 3, W2CT(szSize) );

                /*
                If you don't want the dependency on shlwapi.dll, use the 
                following code, which just shows the numbers unformatted.
                Also take out the '#pragma comment' at the top of this file.

                _stprintf ( szText, _T("%I64u"), uliFreeSpace.QuadPart );
                m_wndList.SetItemText ( lvi.iItem, 2, szText);

                _stprintf ( szText, _T("%I64u"), uliTotalSpace.QuadPart );
                m_wndList.SetItemText ( lvi.iItem, 3, szText );
                */
                }
            }
        }
    
    // Sort the items by drive letter initially.

CListSortInfo sort = { m_psfContainingFolder, SIMPNS_SORT_DRIVELETTER, true };

    m_wndList.SortItems ( CompareItems, (LPARAM) &sort );
    
    if ( m_wndList.GetStyle() & LVS_REPORT )
        {
        m_wndList.SetColumnWidth ( 0, LVSCW_AUTOSIZE_USEHEADER );
        m_wndList.SetColumnWidth ( 1, LVSCW_AUTOSIZE_USEHEADER );
        m_wndList.SetColumnWidth ( 2, LVSCW_AUTOSIZE_USEHEADER );
        m_wndList.SetColumnWidth ( 3, LVSCW_AUTOSIZE_USEHEADER );
        }

    // Redraw the list view.

    m_wndList.SetRedraw ( TRUE );
    m_wndList.Invalidate();
    m_wndList.UpdateWindow();
}