Ejemplo n.º 1
1
BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved )  
{
    if( fdwReason == DLL_PROCESS_ATTACH )
    {
        if( MH_Initialize() != MH_OK )
        {
            return FALSE;
        }

        if( MH_CreateHook(&CreateProcessA, &HookedCreateProcessA, reinterpret_cast<void**>(&OrigCreateProcessA)) != MH_OK )
        {
            return FALSE;
        }

        if( MH_EnableHook(&CreateProcessA) != MH_OK )
        {
            return FALSE;
        }

        if( MH_CreateHook(&CreateProcessW, &HookedCreateProcessW, reinterpret_cast<void**>(&OrigCreateProcessW)) != MH_OK )
        {
            return FALSE;
        }

        if( MH_EnableHook(&CreateProcessW) != MH_OK )
        {
            return FALSE;
        }

        if( MH_CreateHook(&ResumeThread, &HookedResumeThread, reinterpret_cast<void**>(&OrigResumeThread)) != MH_OK )
        {
            return FALSE;
        }

        if( MH_EnableHook(&ResumeThread) != MH_OK )
        {
            return FALSE;
        }

        if( MH_CreateHook(&LoadLibraryW, &HookedLoadLibraryW, reinterpret_cast<void**>(&OrigLoadLibraryW)) != MH_OK )
        {
            return FALSE;
        }

        if( MH_EnableHook(&LoadLibraryW) != MH_OK )
        {
            return FALSE;
        }

        HookD3D9(::GetModuleHandleW(L"d3d9.dll"));

        std::wstring moduleFilename = GetModulePath(hinstDLL);
        WstrToUtf8(moduleFilename, &g_moduleFilenameUtf8);
    }
    return TRUE;
}
Ejemplo n.º 2
0
BOOL CTestList::Create( CWnd* pParentWnd )
{
  BOOL b = CSizingControlBarG::Create( _T("Test list"), pParentWnd, 1967, WS_CLIPCHILDREN );

	SetSCBStyle(GetSCBStyle() | SCBS_SHOWEDGES | SCBS_SIZECHILD);

  if( !b )
		return FALSE;

	SetBarStyle( GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC );

	m_treeList.Create( WS_VISIBLE | WS_CHILD | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_HASLINES | TVS_SHOWSELALWAYS, CRect( 0, 0, 0, 0 ), this, IDC_TREE );

	if( !AddFilesFromPath( GetModulePath( NULL ) + _T("\\Test files\\"), TVI_ROOT ) )
	{
		AddFilesFromPath( GetModulePath( NULL ) +  _T("../../\\components\\QHTM\\Test\\Test files\\"), TVI_ROOT );
	}


	CFont font;
	font.CreateStockObject( DEFAULT_GUI_FONT );
	m_treeList.SetFont( &font );

  return TRUE;
}
Ejemplo n.º 3
0
CWizardInfo::CWizardInfo()
{
	m_bEVCCompa = false;
	m_nOrientType = 1;
	m_nStringType = 0;
	m_bUseString = true;
	m_bOrientAware = false;
	m_bFullScreen = false;
	m_bCreateViewClass = true;
	m_nMenuType = 0;
	m_bEnableScroll = false;
	m_bEnableZoom = false;

	bEnableActiveX = false;
	bCppFiles = false;
	bHostActiveX = false;
	bStatusBar = false;
	bVS2005 = false;
	bVCExpress = false;
	nAppType = 0;
	nViewType = 0;
	bVS60 = true;
	bVS2002 = false;
	bVS2003 = false;
	bVS2008 = false;
	bVS2005 = false;
	bUseView = true;
	nSDKType	= 2;

	templatePath = GetModulePath(_Module.m_hInst)+_T("\\templates");
	cfgPath = GetModulePath(NULL)+_T("\\setup.ini");
	cfgApp = _T("WTLMobileAppWizard");
//	ar_view.push_back(view_type("Generic Window","WTL_VIEWTYPE_GENERIC"));
//	ar_view.push_back(view_type("Form (Dialog Based)","WTL_VIEWTYPE_FORM","CDialogImpl"));
//	ar_view.push_back(view_type("ListBox","WTL_VIEWTYPE_LISTBOX","CListBox","WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | LBS_NOINTEGRALHEIGHT | LBS_NOTIFY | LBS_WANTKEYBOARDINPUT"));
//	ar_view.push_back(view_type("Edit","WTL_VIEWTYPE_EDIT","CEdit","WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_HSCROLL | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | ES_NOHIDESEL"));

	ar_view.push_back("Generic Window");
	ar_view.push_back("Form (Dialog Based)");
	ar_view.push_back("Property Sheet");
	ar_view.push_back("ListBox");
	ar_view.push_back("Edit");
	ar_view.push_back("List View");
	ar_view.push_back("Tree View");
	ar_view.push_back("HTML Browse Control");
	ar_view.push_back("InkX Control");
	ar_view.push_back("RichInk control");

	ar_app.push_back("WTL_APPTYPE_SDI");
	ar_app.push_back("WTL_APPTYPE_DLG");

	ar_lang.push_back(_T("1033"));
	nAppLang = 0;
	load_lang();
}
std::wstring CResourceManager::GetFilePath(WebsiteType eWebsiteType, LPCTSTR lpszSiteID, LPCTSTR lpszFileName)
{
	//由于UAC问题,此路径有可能放到%appdata%中
	//std::wstring strPath = GetModulePath();
	//USES_CONVERSION;
	//std::wstring strPath = A2W(getAppdataPath());
	std::wstring strPath = GetModulePath();


	strPath += _T("\\BankInfo");
	if (eWebsiteType != Website_None)
	{
		static LPCTSTR lpszCategoryName[] = { NULL, _T("banks") };
		strPath += _T("\\");
		strPath += lpszCategoryName[eWebsiteType];
	}
	if (lpszSiteID[0])
	{
		strPath += _T("\\");
		strPath += lpszSiteID;
	}
	strPath += _T("\\");
	strPath += lpszFileName;
	return strPath;
}
Ejemplo n.º 5
0
/**
 * @brief Show contributors list.
 * Opens Contributors.txt into notepad.
 */
void CAboutDlg::OnBnClickedOpenContributors()
{
	String defPath = GetModulePath();
	// Don't add quotation marks yet, CFile doesn't like them
	String docPath = defPath + ContributorsPath;
	HINSTANCE ret = 0;
	
	if (paths_DoesPathExist(docPath.c_str()) == IS_EXISTING_FILE)
	{
		// Now, add quotation marks so ShellExecute() doesn't fail if path
		// includes spaces
		docPath.insert(0, _T("\""));
		docPath.insert(docPath.length(), _T("\""));
		ret = ShellExecute(m_hWnd, NULL, _T("notepad"), docPath.c_str(), defPath.c_str(), SW_SHOWNORMAL);

		// values < 32 are errors (ref to MSDN)
		if ((int)ret < 32)
		{
			// Try to open with associated application (.txt)
			ret = ShellExecute(m_hWnd, _T("open"), docPath.c_str(), NULL, NULL, SW_SHOWNORMAL);
			if ((int)ret < 32)
				ResMsgBox1(IDS_ERROR_EXECUTE_FILE, _T("Notepad.exe"), MB_ICONSTOP);
		}
	}
	else
		ResMsgBox1(IDS_ERROR_FILE_NOT_FOUND, docPath.c_str(), MB_ICONSTOP);
}
Ejemplo n.º 6
0
	std::wstring GetAppDirectory()
	{
		std::wstring path;

		std::wstring appname = GetEnvironmentVariable(L"BEARLIB_APPNAME");
		if (!appname.empty())
		{
			// Might be a fully qualified or relative to CWD filename.
			if (FileExists(appname) || FileExists(appname = (GetCurrentDirectory() + appname)))
				path = appname;
		}

		if (path.empty())
		{
			// Retrieve executable location.
			path = GetModulePath();
		}

		// Strip off possible filename portion.
		size_t slash_pos = path.find_last_of(kPathSeparator);
		if (slash_pos != std::wstring::npos)
			path = path.substr(0, slash_pos);

		// If nothing or error occured, fall back to CWD.
		if (path.empty())
		{
			// Failed despite all attempts.
			path = L".";
		}

		if (path.back() != kPathSeparator)
			path += kPathSeparator;

		return path;
	}
Ejemplo n.º 7
0
BOOL CExceptionParser::WriteDump(LPEXCEPTION_POINTERS pException)
{
	HANDLE hDumpFile;

//    int idx = m_ppFinalizers[0]->GetIdx();
	LPCTSTR szModulePath=GetModulePath();
	char szDumpFileName[MAX_PATH];
	SYSTEMTIME CurTime;

	PrintLog("开始制作Dump文件");

	GetLocalTime(&CurTime);

	sprintf(szDumpFileName,"%s\\Dump%d-%02d-%02d %02d-%02d-%02d.dmp",
		(LPCTSTR)szModulePath,
		CurTime.wYear,CurTime.wMonth,CurTime.wDay,
		CurTime.wHour,CurTime.wMinute,CurTime.wSecond);

	hDumpFile=CreateFile(szDumpFileName,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);

	if(hDumpFile!=INVALID_HANDLE_VALUE)
	{		
		PrintLog("开始写入Dump文件%s",szDumpFileName);

		static DWORD ProcessID=GetCurrentProcessId();

		static MINIDUMP_EXCEPTION_INFORMATION ExceptionInfo;
		static MINIDUMP_EXCEPTION_INFORMATION * pExceptionInfo=NULL;

		if(pException)
		{
			ExceptionInfo.ThreadId=GetCurrentThreadId();
			ExceptionInfo.ExceptionPointers=pException;
			ExceptionInfo.ClientPointers=true;
			pExceptionInfo=&ExceptionInfo;
		}
		
		

		if(MiniDumpWriteDump(m_hProcess,ProcessID,hDumpFile,
			MiniDumpNormal,pExceptionInfo,NULL,NULL))
		{
			PrintLog("写入Dump文件成功%s",(LPCTSTR)szDumpFileName);
			CloseHandle(hDumpFile);
			return TRUE;
		}
		else
		{
			PrintLog("写入Dump文件失败%s",(LPCTSTR)szDumpFileName);
		}
		CloseHandle(hDumpFile);
		
	}
	else
	{
		PrintLog("打开Dump文件失败%s",(LPCTSTR)szDumpFileName);
	}

	return FALSE;
}
Ejemplo n.º 8
0
void CControlTestDialog::OnBnClickedButtonTestImageButton()
{
	// TODO: 在此添加控件通知处理程序代码
	this->ResetTest();

	CUIButton *pBtn = new CUIButton();

	m_pTestWnd = pBtn;
	
	CRect rcClient;
	this->GetClientRect( rcClient );
	const CRect rcSt( 20,80, rcClient.Width()-20, 120 );

	pBtn->Create( _T( "" ), WS_CHILD | WS_VISIBLE, rcSt, this, 1000 );

	tstring strAppDir = ParsePath( GetModulePath().c_str() ).m_strDirectory;

	tstring  strLogoPath= strAppDir + _T( "res\\chs\\btn_login_normal.jpg" );
	tstring strDisPath = strAppDir + _T( "res\\chs\\btn_login_direct.jpg" );
	pBtn->SetImage( strLogoPath.c_str(), strLogoPath.c_str(), strDisPath.c_str() );

	pBtn->SetTransparentMask( TRUE, RGB( 255,0,255) );

	pBtn->ShowWindow( SW_SHOW );

}
Ejemplo n.º 9
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
	HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to 
// make the EXE free threaded. This means that calls come in on a random RPC thread.
//	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));

	// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
	::DefWindowProc(NULL, 0, 0, 0L);

	AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES);	// add flags to support other controls

	CSkinManager::GetInstance()->SetSkinPath(GetModulePath()+_T("Skins\\Default\\"));


	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	int nRet = Run(lpstrCmdLine, nCmdShow);

	_Module.Term();
	::CoUninitialize();

	return nRet;
}
Ejemplo n.º 10
0
BOOL
	TestGetModuleName()
{
	BOOL	bRet				= FALSE;

	HMODULE hModule				= NULL;
	TCHAR	tchPath[MAX_PATH]	= {0};


	__try
	{
		GetModulePath(NULL, tchPath, _countof(tchPath));

		hModule = LoadLibrary(L"DynamicLibrary1.dll");
		if (!hModule)
		{
			printf("[%s] LoadLibrary failed. (%d) \n", __FUNCTION__, GetLastError());
			__leave;
		}

		bRet = TRUE;
	}
	__finally
	{
		if (hModule)
		{
			FreeLibrary(hModule);
			hModule = NULL;
		}
	}

	return bRet;
}
Ejemplo n.º 11
0
bool ConsoleHandler::InjectHookDLL()
{
	// allocate memory for parameter in the remote process
	wstring				strHookDllPath(GetModulePath(NULL) + wstring(L"\\ConsoleHook.dll"));

	if (::GetFileAttributes(strHookDllPath.c_str()) == INVALID_FILE_ATTRIBUTES) return false;

	shared_ptr<void>	hRemoteThread;
	shared_ptr<wchar_t>	pszHookDllPathRemote(
							static_cast<wchar_t*>(::VirtualAllocEx(
														m_hConsoleProcess.get(), 
														NULL, 
														strHookDllPath.length()*sizeof(wchar_t), 
														MEM_COMMIT, 
														PAGE_READWRITE)),
							bind<BOOL>(::VirtualFreeEx, m_hConsoleProcess.get(), _1, NULL, MEM_RELEASE));


#pragma warning(push)
#pragma warning(disable: 4127)

	if (pszHookDllPathRemote.get() == NULL) return false;

	// write the memory
	if (!::WriteProcessMemory(
				m_hConsoleProcess.get(), 
				(PVOID)pszHookDllPathRemote.get(), 
				(PVOID)strHookDllPath.c_str(), 
				strHookDllPath.length()*sizeof(wchar_t), 
				NULL))
	{
		return false;
	}

	// get address to LoadLibraryW function
	PTHREAD_START_ROUTINE pfnThreadRoutine = (PTHREAD_START_ROUTINE)::GetProcAddress(::GetModuleHandle(L"Kernel32.dll"), "LoadLibraryW");
	if (pfnThreadRoutine == NULL) return false;

	// start the remote thread
	hRemoteThread = shared_ptr<void>(
						::CreateRemoteThread(
							m_hConsoleProcess.get(), 
							NULL, 
							0, 
							pfnThreadRoutine, 
							(PVOID)pszHookDllPathRemote.get(), 
							0, 
							NULL),
						::CloseHandle);

	if (hRemoteThread.get() == NULL) return false;

	// wait for the thread to finish
//	::WaitForSingleObject(hRemoteThread.get(), INFINITE);
	if (::WaitForSingleObject(hRemoteThread.get(), 10000) == WAIT_TIMEOUT) return false;

#pragma warning(pop)

	return true;
}
Ejemplo n.º 12
0
std::wstring Utils::GetCurrentDir()
{
	std::wstring sPath;
#ifdef _WIN32
    sPath =  GetModulePath(NULL);
    //sPath += L"\\";
#else
    FILE * fp = NULL;
    char res[512] = "";
    wchar_t wres[1024] = L"";
    fp = popen("pwd","r");
    if(fp!=NULL)
    {
        int nBytes = fread(res, 1, 511, fp);
        fclose(fp);
        if(nBytes==0)
            return sPath;
        mbstowcs(wres, res, 1024);
        sPath = std::wstring(wres);
        sPath += L"/";
        sPath.erase(std::remove(sPath.begin(), sPath.end(), L'\r'), sPath.end());
        sPath.erase(std::remove(sPath.begin(), sPath.end(), L'\n'), sPath.end());
    }
#endif
    return sPath;
}
Ejemplo n.º 13
0
void CGlobal::LoadBitmaps()
{
	DeleteBitmaps();

	CString strFileName(_T(""));
	CString sModulePath = GetModulePath() + _T("\\");

	for(UINT i=0; i<IDX_BMP_MAX; i++)
	{
		strFileName = GetBitmapFileName(i);
		if( strFileName.IsEmpty() )
			continue;
		
		strFileName = sModulePath + strFileName;

		m_infoBitmap[i].hBitmap = (HBITMAP)::LoadImage(::AfxGetInstanceHandle(), 
											(LPCTSTR)strFileName, 
											IMAGE_BITMAP, 
											0, 
											0, 
											LR_LOADFROMFILE|LR_CREATEDIBSECTION|LR_DEFAULTSIZE);

		::GetObject(m_infoBitmap[i].hBitmap, sizeof(BITMAP), &m_infoBitmap[i].bitmap);
	}
}
Ejemplo n.º 14
0
void ActivationContextLoader::Initialise(const CStdString& sManifest)
{
	if (CGeneral::FileExists(sManifest))
	{
		m_sManifest = sManifest;
	}
	else
	{
		CPath path;
		path.Combine(GetModulePath(), sManifest);
		m_sManifest = path;
	}

	try
	{
		// Don't do anything if we're not at least running on xp
		m_bShouldLoadActivationContext = ShouldLoadActivationContext();
		if (m_bShouldLoadActivationContext)
		{
			LoadDll();

			if (!IsActivationContextAlreadyActiveForManifest())
			{
				LoadAC();
			}
		}

	}
	catch (std::exception & e)
	{
		CStdString sError = CA2T(e.what());
		LOG_WS_ERROR(sError); 
	}
}
Ejemplo n.º 15
0
BOOL CControlTestDialog::OnInitDialog()
{
	CUIDialog::OnInitDialog();

	// TODO:  在此添加额外的初始化
//	this->SetColor( RGB( 33,65,181 ) );
	
	tstring strAppDir = ParsePath( GetModulePath().c_str() ).m_strDirectory;

	tstring  strLogoPath= strAppDir + _T( "res\\chs\\main_bg.JPG" );
	this->SetImage( strLogoPath.c_str() );

	OnBnClickedButtonTestTransparentMaskImage();
	//this->m_stGreenTextTransLeft.SetTextColor( RGB( 128, 10, 10 ), RGB( 128, 128, 128 ), TRUE );

	//CFont font;
	//BOOL bSuccess = font.CreatePointFont( 12, _T( "宋体" ) );
	//_ASSERT( bSuccess );
	//this->m_stGreenTextTransLeft.SetFont( &font );

	

	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}
Ejemplo n.º 16
0
void ActivationContextLoader::LoadDll()
{
    // Get a handle to the DLL module.
 
	CPath dllPath;
	dllPath.Combine(GetModulePath(), WS_ACTIVATIONCONTEXTLOADER_DLL);
	
    m_hinstLib = LoadLibrary(dllPath); 
 
    // If the handle is valid, try to get the function address.
 
    if (m_hinstLib != NULL) 
    { 
		m_funcLAC = (LAC) GetProcAddress(m_hinstLib, WS_ACLOADFUNC); 
													 
		m_funcULAC = (ULAC) GetProcAddress(m_hinstLib, WS_ACUNLOADFUNC);

		m_funcIAAFM = (IAAFM) GetProcAddress(m_hinstLib, WS_ACALREADYACTIVEFUNC);
    } 
	else
	{
		CStdStringA msg;
		msg.Format("LoadLibrary on '%s'failed. Error code: %d.", WS_ACTIVATIONCONTEXTLOADER_DLL_A, GetLastError());
		throw std::exception(msg);
	}
}
Ejemplo n.º 17
0
 CString GetProgramPath(bool bWithExeName/* = false*/)
 {
     CString ret = GetModulePath(nullptr);
     if (!bWithExeName) {
         ret = DirName(ret);
     }
     return ret;
 }
Ejemplo n.º 18
0
 CString GetAfxModulePath(bool bWithModuleName/* = false*/)
 {
     CString ret = GetModulePath(AfxGetInstanceHandle());
     if (!bWithModuleName) {
         ret = DirName(ret);
     }
     return ret;
 }
Ejemplo n.º 19
0
bool CBonCasClientCardReader::IsAvailable()
{
	TCHAR szPath[MAX_PATH];

	GetModulePath(szPath);

	return ::PathFileExists(szPath) != FALSE;
}
Ejemplo n.º 20
0
BOOL LoadStrings()
{
  // Locate and load the strings file used by installer
  if (*g_sUninstallPath == 0)
    GetModulePath(g_sUninstallPath);

  WCHAR sStringsFile[MAX_PATH];
  _snwprintf(sStringsFile, MAX_PATH, L"%s\\%s", g_sUninstallPath, c_sStringsFile);

  return Strings.LoadStrings(sStringsFile);
}
Ejemplo n.º 21
0
std::wstring Utils::GetDataFolder()
{
    std::wstring sPath;
#ifdef _WIN32
    sPath = GetModulePath(NULL);
    sPath += L"..\\data\\";
#else
    sPath += L"../data/";
#endif
    return sPath;
}
Ejemplo n.º 22
0
/*
 * Retrieve 'module dir path\firefox.exe'
 *
 * @aPathBuffer Buffer to fill
 */
static bool GetDesktopBrowserPath(CStringW& aPathBuffer)
{
  if (!GetModulePath(aPathBuffer))
    return false;

  // ceh.exe sits in dist/bin root with the desktop browser. Since this
  // is a firefox only component, this hardcoded filename is ok.
  aPathBuffer.Append(L"\\");
  aPathBuffer.Append(kFirefoxExe);
  return true;
}
Ejemplo n.º 23
0
int GetDefaultConfigureFile(char *out, int OutLength)
{
#ifdef WIN32
	GetModulePath(out, OutLength);
	strcat(out, "\\dnsforwarder.config");
#else
	GetConfigDirectory(out);
	strcat(out, "/config");
#endif
	return 0;
}
Ejemplo n.º 24
0
void CMCUCommonTest::TestGetModulePath()
{
	tstring strPath1 = GetModulePath();

	tstring strPath2;
	TCHAR temp[1024]; 
	::GetModuleFileName( NULL, temp, 1024 );
	strPath2 = temp;

	CPPUNIT_ASSERT_EQUAL( strPath1, strPath2 );
}
Ejemplo n.º 25
0
wstring Utils::GetTestDataFolder()
{
    wstring sPath;
#ifdef _WIN32
    sPath =  GetModulePath(NULL);
    sPath += L"..\\test_data\\";
#else
    sPath =  GetExePath();
    sPath += L"../test_data/";
#endif
    return sPath;
}
Ejemplo n.º 26
0
inline bool GetModuleDirectory(char *out_path, size_t len)
{
    size_t size = GetModulePath(out_path, len);
    while(size>0) {
        if(out_path[size]=='\\') {
            out_path[size+1] = '\0';
            return true;
        }
        --size;
    }
    return false;
}
Ejemplo n.º 27
0
bool CCoBroker::HandleRequestService(const tstring& dstUserId, ULONG dstSvcId, const tstring& srcUserId, ULONG srcSvcId, ULONG rId, ULONG rType, ULONG param, const tstring& params)
{
TRY_CATCH
	HRESULT result;
	EBrokerStartTypes startParam=BST_SAME;
	tstring url;
	{
		tstring::size_type iBeginUrl=params.find(_T(";;"));
		if(iBeginUrl!=tstring::npos)
		{
			tstring::size_type iEndUrl=params.find(_T(";;"),iBeginUrl+2);
			url=params.substr(iBeginUrl+2,(tstring::npos!=iEndUrl)?iEndUrl-iBeginUrl-2:tstring::npos);
		}
	}
	Log.Add(_MESSAGE_,_T("***HandleRequestService*** url=[%s]"),url.c_str());

	const TCHAR SESSION_ID_PARAMETER_NAME[]=_T("supportRequestId=");
	tstring::size_type iWebSId=url.find(SESSION_ID_PARAMETER_NAME);
	if(iWebSId!=tstring::npos&&iWebSId+_countof(SESSION_ID_PARAMETER_NAME)<url.size())
	{
		iWebSId+=_countof(SESSION_ID_PARAMETER_NAME)-1;
		tstring::size_type iWebSIdEnd=url.find_first_of(_T("&#"),iWebSId);
		if(tstring::npos==iWebSIdEnd)
			iWebSIdEnd=url.length();
		tstring sId=url.substr(iWebSId,iWebSIdEnd-iWebSId);
		Log.Add(_MESSAGE_,_T("***HandleRequestService*** sId=[%s]"),sId.c_str());
		SHA1Hash hash_buf;
		CRYPTO_INSTANCE.MakeHash((char*)sId.c_str(),sId.length()*sizeof(tstring::value_type),hash_buf);
		tstring hashString;
		for(int i=0;i<sizeof(hash_buf);++i)
			//hashString+=i2tstring((int)(unsigned char)hash_buf[i],16);
			hashString+=Format(_T("%02x"),(int)(unsigned char)hash_buf[i]);
		url.insert(iWebSIdEnd,tstring(_T("&sri="))+hashString);
	}
	//Log.Add(_WARNING_,_T("***HandleRequestService*** HASHING TURN OFF"));
	Log.Add(_MESSAGE_,_T("***HandleRequestService*** url=[%s]"),url.c_str());
	
	CAtlFile cnfg;
	if(S_OK==cnfg.Create(Format(_T("%s\\%s"),GetModulePath(GetCurrentModule()).c_str(),_T("Broker.cfg")).c_str(),GENERIC_READ,0,OPEN_EXISTING))
	{
		TRY_CATCH
			DWORD readLen=0;
			readLen=GetFileSize(cnfg.m_h,NULL);
			if(INVALID_FILE_SIZE==readLen&&readLen>32768)
				throw MCException_Win("Broker.cfg size obtaining failed or file too large");
			std::auto_ptr<char> buf(new char[readLen]);
			if(!ReadFile(cnfg.m_h,buf.get(),readLen,&readLen,NULL))
				throw MCException_Win("Broker.cfg file reading failed");
			startParam=EBrokerStartTypes(atol(buf.get()));
			Log.Add(_MESSAGE_,_T("***HandleRequestService*** file startParam=[0x%x]"),startParam);
		CATCH_LOG()
	}
Ejemplo n.º 28
0
/**
 * @brief Load any known file filters
 * @todo Preserve filter selection? How?
 */
void FileFilterHelper::LoadAllFileFilters()
{
	// Load filters from all possible subdirectories
	FILEFILTER_FILEMAP patternsLoaded;

	// First delete existing filters
	m_fileFilterMgr->DeleteAllFilters();

	// Program application directory
	m_sGlobalFilterPath = GetModulePath() + _T("\\Filters");
	LoadFileFilterDirPattern(patternsLoaded, (m_sGlobalFilterPath + _T("\\*") + FileFilterExt).c_str());
	LoadFileFilterDirPattern(patternsLoaded, (m_sUserSelFilterPath + _T("\\*") + FileFilterExt).c_str());
}
Ejemplo n.º 29
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 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; 
}
Ejemplo n.º 30
0
ff::String ff::Module::GetPath() const
{
#if METRO_APP
    // Assume that the name is a DLL in the application directory
    Windows::ApplicationModel::Package ^package = Windows::ApplicationModel::Package::Current;
    String path = String::from_pstring(package->InstalledLocation->Path);
    AppendPathTail(path, _name);
    ChangePathExtension(path, ff::String(L"dll"));
    assert(FileExists(path));
    return path;
#else
    assert(_instance != nullptr);
    return GetModulePath(_instance);
#endif
}