예제 #1
0
void UpdateNativeImage(bool bInstall)
{
	const std_string strNGen = FindNGen();
	if(strNGen.size() == 0) return;

	const std_string strKeePassExe = GetKeePassExePath();
	if(strKeePassExe.size() == 0) return;

	std_string strParam = (bInstall ? _T("") : _T("un"));
	strParam += _T("install \"");
	strParam += strKeePassExe + _T("\"");

	SHELLEXECUTEINFO sei;
	ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO));
	sei.cbSize = sizeof(SHELLEXECUTEINFO);
	sei.fMask = SEE_MASK_NOCLOSEPROCESS;
	sei.lpVerb = _T("open");
	sei.lpFile = strNGen.c_str();
	sei.lpParameters = strParam.c_str();
	sei.nShow = SW_HIDE;
	ShellExecuteEx(&sei);

	if(sei.hProcess != NULL)
	{
		WaitForSingleObject(sei.hProcess, 16000);
		CloseHandle(sei.hProcess);
	}
}
예제 #2
0
void FindNGenRec(const std_string& strPath, std_string& strNGenPath,
	ULONGLONG& ullVersion)
{
	const std_string strSearch = strPath + _T("*.*");
	const std_string strNGen = _T("ngen.exe");

	WIN32_FIND_DATA wfd;
	ZeroMemory(&wfd, sizeof(WIN32_FIND_DATA));
	HANDLE hFind = FindFirstFile(strSearch.c_str(), &wfd);
	if(hFind == INVALID_HANDLE_VALUE) return;

	while(true)
	{
		if((wfd.cFileName[0] == 0) || (_tcsicmp(wfd.cFileName, _T(".")) == 0) ||
			(_tcsicmp(wfd.cFileName, _T("..")) == 0)) { }
		else if((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
			FindNGenRec((strPath + wfd.cFileName) + _T("\\"), strNGenPath, ullVersion);
		else if(_tcsicmp(wfd.cFileName, strNGen.c_str()) == 0)
		{
			const std_string strFullPath = strPath + strNGen;
			const ULONGLONG ullThisVer = SiuGetFileVersion(strFullPath);
			if(ullThisVer >= ullVersion)
			{
				strNGenPath = strFullPath;
				ullVersion = ullThisVer;
			}
		}

		if(FindNextFile(hFind, &wfd) == FALSE) break;
	}

	FindClose(hFind);
}
예제 #3
0
void EnsureTerminatingSeparator(std_string& strPath)
{
	if(strPath.size() == 0) return;
	if(strPath.c_str()[strPath.size() - 1] == _T('\\')) return;

	strPath += _T("\\");
}
예제 #4
0
void FindNGenRec(const std_string& strPath, std_string& strNGenPath, FILETIME& ftCreation)
{
	const std_string strSearch = strPath + _T("*.*");
	const std_string strNGen = _T("ngen.exe");

	WIN32_FIND_DATA wfd;
	ZeroMemory(&wfd, sizeof(WIN32_FIND_DATA));
	HANDLE hFind = FindFirstFile(strSearch.c_str(), &wfd);
	if(hFind == INVALID_HANDLE_VALUE) return;

	while(true)
	{
		if((wfd.cFileName[0] == 0) || (_tcsicmp(wfd.cFileName, _T(".")) == 0) ||
			(_tcsicmp(wfd.cFileName, _T("..")) == 0)) { }
		else if((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
			FindNGenRec((strPath + wfd.cFileName) + _T("\\"), strNGenPath, ftCreation);
		else if(_tcsicmp(wfd.cFileName, strNGen.c_str()) == 0)
		{
			if((wfd.ftCreationTime.dwHighDateTime > ftCreation.dwHighDateTime) ||
				((wfd.ftCreationTime.dwHighDateTime == ftCreation.dwHighDateTime) &&
				(wfd.ftCreationTime.dwLowDateTime > ftCreation.dwLowDateTime)))
			{
				strNGenPath = strPath + wfd.cFileName;
				ftCreation = wfd.ftCreationTime;
			}
		}

		if(FindNextFile(hFind, &wfd) == FALSE) break;
	}

	FindClose(hFind);
}
예제 #5
0
void CheckDotNetInstalled()
{
	OSVERSIONINFO osv;
	ZeroMemory(&osv, sizeof(OSVERSIONINFO));
	osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	GetVersionEx(&osv);
	if(osv.dwMajorVersion >= 6) return; // .NET ships with Vista and higher

	const std_string strNGen = FindNGen();
	if(strNGen.size() == 0)
	{
		std_string strMsg = _T("KeePass 2.x requires the Microsoft .NET Framework >= 2.0, ");
		strMsg += _T("however this framework currently doesn't seem to be installed ");
		strMsg += _T("on your computer. Without this framework, KeePass will not run.\r\n\r\n");
		strMsg += _T("The Microsoft .NET Framework is available as free download from the ");
		strMsg += _T("Microsoft website.\r\n\r\n");
		strMsg += _T("Do you want to visit the Microsoft website now?");

		const int nRes = MessageBox(NULL, strMsg.c_str(), _T("KeePass Setup"),
			MB_ICONQUESTION | MB_YESNO);
		if(nRes == IDYES)
		{
			SHELLEXECUTEINFO sei;
			ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO));
			sei.cbSize = sizeof(SHELLEXECUTEINFO);
			sei.lpVerb = _T("open");
			sei.lpFile = _T("http://msdn.microsoft.com/en-us/netframework/aa569263.aspx");
			sei.nShow = SW_SHOW;
			ShellExecuteEx(&sei);
		}
	}
}
예제 #6
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
	LPTSTR lpCmdLine, int nCmdShow)
{
	UNREFERENCED_PARAMETER(hInstance);
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);
	UNREFERENCED_PARAMETER(nCmdShow);

	INITCOMMONCONTROLSEX icc;
	ZeroMemory(&icc, sizeof(INITCOMMONCONTROLSEX));
	icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
	icc.dwICC = ICC_STANDARD_CLASSES;
	InitCommonControlsEx(&icc);

	std_string strCmdLine = GetCommandLine();
	boost::trim_if(strCmdLine, boost::is_any_of(g_lpPathTrimChars));

	std::transform(strCmdLine.begin(), strCmdLine.end(), strCmdLine.begin(), tolower);

	if((strCmdLine.size() >= g_strNGenInstall.size()) && (strCmdLine.substr(
		strCmdLine.size() - g_strNGenInstall.size()) == g_strNGenInstall))
	{
		UpdateNativeImage(false);
		Sleep(200);
		UpdateNativeImage(true);
	}

	if((strCmdLine.size() >= g_strNGenUninstall.size()) && (strCmdLine.substr(
		strCmdLine.size() - g_strNGenUninstall.size()) == g_strNGenUninstall))
	{
		UpdateNativeImage(false);
	}

	if((strCmdLine.size() >= g_strPreLoadRegister.size()) && (strCmdLine.substr(
		strCmdLine.size() - g_strPreLoadRegister.size()) == g_strPreLoadRegister))
	{
		RegisterPreLoad(true);
	}

	if((strCmdLine.size() >= g_strPreLoadUnregister.size()) && (strCmdLine.substr(
		strCmdLine.size() - g_strPreLoadUnregister.size()) == g_strPreLoadUnregister))
	{
		RegisterPreLoad(false);
	}

	if((strCmdLine.size() >= g_strNetCheck.size()) && (strCmdLine.substr(
		strCmdLine.size() - g_strNetCheck.size()) == g_strNetCheck))
	{
		CheckDotNetInstalled();
	}

	return 0;
}
예제 #7
0
	void cFreeType::makeLine(sFreeTypeFontDesc const& desc, std_string const& str, cFreeTypeLine& line)
	{
		cFreeTypeFont* font = m_ftFontCash->get(desc.m_name);
		if (!font)
		{
			assert(0 && _T("failed find font"));
			return ;
		}
		font->setSize(desc.m_size);

		line.setStr(str);

		TCHAR const* c_str = str.c_str();
		for (size_t i = 0; i < str.length(); ++i)
		{
			line.addGlyph(m_ftGlyphCash->getKey(desc, font->getFace(), c_str[i]));
		}
	}
예제 #8
0
	bool cSceneManager::createScene(std_string const& filename, int loadingType)
	{
		cSerializeBsd serialize;
		cSerializeBsd::sData data;

		if (!serialize.load(filename, data))
			return false;

		m_worldOctree->addScene(data.getOctreeOnce(), true);
		m_terrain = data.getTerrainOnce();
		m_terrain->initialize();
		memcpy(&m_cullFigure, &data.m_cullFigure, sizeof (sCullFigure));

		assert(m_terrain);

		BUID buid;
		std_string _filename;
		std_string bmdName;
		std_string passName = cFileHelper::getPassNameInFullPassT(filename.c_str());

		if (LOADING_BACKGROUND == loadingType)
		{
			for (UINT i = 0; i < data.getRdSize(); ++i)
			{
				buid = data.m_rdList[i].m_buid;
				cSerializeBmd::makeFileName(buid, bmdName);
				_filename = passName + bmdName;

				sModelLoadInfo info(buid, _filename);
				info.m_pos = data.m_rdList[i].m_position;
				info.m_radian = 0.0f;
				info.m_isScene = true;
				info.m_shareType = (uint)(ST_IB | ST_VB);
				m_modelCache->addLoadingList(info);

				m_entityMgr->createEntity<cEntityModel>(info.getBuid());
			}
		}
		else if (LOADING_DIRECT == loadingType)
		{
			for (UINT i = 0; i < data.getRdSize(); ++i)
			{
				buid = data.m_rdList[i].m_buid;
				cSerializeBmd::makeFileName(buid, bmdName);
				_filename = passName + bmdName;

				createEntity<cEntityModel>(_filename, buid, data.m_rdList[i].m_position, 1.0f, loadingType);
			}
		}
		else if (LOADING_ACCESS == loadingType)
		{
		}

		return true;
	}
예제 #9
0
void CXmlReader::GetNodeName(std_string &strName)
{
	strName.clear();
	if (m_pOpenElement)
	{
		const char* p = m_pOpenElement->Value();
		if (p != NULL)
		{
			strName = UTF8ToTChar(p);
		}
	}
}
예제 #10
0
void CXmlReader::GetNodeContent(std_string &strText)
{
	strText.clear();
	if (m_pOpenElement)
	{
		const char* p = m_pOpenElement->GetText();
		if (p != NULL)
		{
			strText = UTF8ToTChar(p);
		}
	}
}
예제 #11
0
DWORD CPwManager::FindEx(const TCHAR *pszFindString, BOOL bCaseSensitive,
	DWORD searchFlags, DWORD nStart)
{
	if(((searchFlags & PWMS_REGEX) != 0) || (pszFindString == NULL) ||
		(pszFindString[0] == 0))
		return this->Find(pszFindString, bCaseSensitive, searchFlags, nStart, DWORD_MAX);

	const std_string strText = pszFindString;
	if(strText != g_strFindCachedString)
	{
		g_vFindCachedSplitted = SU_SplitSearchTerms(strText.c_str());
		g_strFindCachedString = strText;
	}
	const std::vector<std_string>* pvTerms = &g_vFindCachedSplitted;

	if(pvTerms->size() == 0) return nStart;

	DWORD dwIndex = nStart;
	while(dwIndex != DWORD_MAX)
	{
		bool bAllMatch = true;
		for(size_t i = 0; i < pvTerms->size(); ++i)
		{
			const std_string& strTerm = (*pvTerms)[i];
			const DWORD dwRes = this->Find(strTerm.c_str(), bCaseSensitive,
				searchFlags, dwIndex, DWORD_MAX);

			if(dwRes > dwIndex)
			{
				dwIndex = dwRes;
				bAllMatch = false;
				break;
			}
		}

		if(bAllMatch) break;
	}

	return dwIndex;
}
예제 #12
0
void CXmlReader::GetNodeAttribute(LPCTSTR szKey, std_string &strValue)
{
	strValue.clear();

	if (m_pOpenElement) 
	{
		const char* p = m_pOpenElement->Attribute(TCharToUTF8(szKey));
		if (p != NULL)
		{
			strValue = UTF8ToTChar(p);
		}
	}
}
예제 #13
0
ULONGLONG SiuGetFileVersion(const std_string& strFilePath)
{
	DWORD dwDummy = 0;
	const DWORD dwVerSize = GetFileVersionInfoSize(
		strFilePath.c_str(), &dwDummy);
	if(dwVerSize == 0) return 0;

	boost::scoped_array<BYTE> vVerInfo(new BYTE[dwVerSize]);
	if(vVerInfo.get() == NULL) return 0; // Out of memory

	if(GetFileVersionInfo(strFilePath.c_str(), 0, dwVerSize,
		vVerInfo.get()) == FALSE) return 0;

	VS_FIXEDFILEINFO* pFileInfo = NULL;
	UINT uFixedInfoLen = 0;
	if(VerQueryValue(vVerInfo.get(), _T("\\"), (LPVOID*)&pFileInfo,
		&uFixedInfoLen) == FALSE) return 0;
	if(pFileInfo == NULL) return 0;

	return ((static_cast<ULONGLONG>(pFileInfo->dwFileVersionMS) <<
		32) | static_cast<ULONGLONG>(pFileInfo->dwFileVersionLS));
}
예제 #14
0
	bool sCubeTexture::load(std_string const& filename)
	{
		std_string realPath;
		if (!_getFileSystem()->findRealPath(filename, realPath))
		{
			return false;
		}

		if (!checkHResultReturn(D3DXCreateCubeTextureFromFile(cD3DSystem::getD3DDevice(), realPath.c_str(), &m_tex)))
			return false;

		trace(_T("load texture : %s\n"), filename.c_str());

		return true;
	}
예제 #15
0
void RegisterPreLoad(bool bRegister)
{
	const std_string strPath = GetKeePassExePath();
	if(strPath.size() == 0) return;

	HKEY hKey = NULL;
	if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
		0, KEY_WRITE, &hKey) != ERROR_SUCCESS) return;
	if(hKey == NULL) return;

	const std_string strItemName = _T("KeePass 2 PreLoad");
	std_string strItemValue = _T("\"");
	strItemValue += strPath;
	strItemValue += _T("\" --preload");

	if(bRegister)
		RegSetValueEx(hKey, strItemName.c_str(), 0, REG_SZ,
			(const BYTE*)strItemValue.c_str(), static_cast<DWORD>((strItemValue.size() +
			1) * sizeof(TCHAR)));
	else
		RegDeleteValue(hKey, strItemName.c_str());

	RegCloseKey(hKey);
}
예제 #16
0
	void cSceneManager::renderRenderListShader(cShader* shader, std_string const& technique, cBatchRenderManager::vecEntityList const& renderList)
	{
		if (!shader)
			return ;

		uint pass;
		shader->setTechnique(technique.c_str());
		shader->begin(&pass);

		cBatchRenderManager::vecEntityList::const_iterator it = renderList.begin();
		for (; it != renderList.end(); ++it)
		{
			renderRdShader(shader, pass, it->m_rd);
		}

		shader->end();
	}
예제 #17
0
	void cSceneManager::renderEntitySingleShader(cShader* shader, std_string const& technique, cEntityModel const* entity)
	{
		if (!shader)
			return ;
		if (!entity)
			return ;
		cRenderData* rd = getRenderData(entity->getRenderDataBuid());
		if (!rd)
			return ;

		uint pass;
		shader->setTechnique(technique.c_str());
		shader->begin(&pass);

		renderRdShader(shader, pass, rd);

		shader->end();
	}
예제 #18
0
void CUpdateCheckEx::AddComponent(const std_string& strLine, UC_COMPONENTS_LIST& vList)
{
	if(strLine.size() == 0) return;

	if(strLine[0] == _T('#')) { ASSERT(FALSE); return; } // Reserved for future use

	std::vector<std_string> vInfo;
	SU_Split(vInfo, strLine, _T("#"));
	if(vInfo.size() < 2) { ASSERT(FALSE); return; }

	std::vector<std_string> vVersion;
	SU_Split(vVersion, vInfo[1], _T("."));
	if(vVersion.size() < 4) { ASSERT(FALSE); return; }

	UC_COMPONENT_INFO c;
	c.strName = vInfo[0];
	c.qwVerAvailable = ((static_cast<UINT64>(_ttol(vVersion[0].c_str())) << 48) |
		(static_cast<UINT64>(_ttol(vVersion[1].c_str())) << 32) |
		(static_cast<UINT64>(_ttol(vVersion[2].c_str())) << 16) |
		static_cast<UINT64>(_ttol(vVersion[3].c_str())));

	vList.push_back(c);
}
예제 #19
0
BOOL CLanguagesDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	NewGUI_TranslateCWnd(this);
	EnumChildWindows(this->m_hWnd, NewGUI_TranslateWindowCb, 0);
	
	NewGUI_XPButton(m_btClose, IDB_CANCEL, IDB_CANCEL);
	NewGUI_XPButton(m_btGetLang, IDB_LANGUAGE, IDB_LANGUAGE);
	NewGUI_XPButton(m_btOpenFolder, IDB_TB_OPEN, IDB_TB_OPEN);

	NewGUI_ConfigSideBanner(&m_banner, this);
	m_banner.SetIcon(AfxGetApp()->LoadIcon(IDI_WORLD),
		KCSB_ICON_LEFT | KCSB_ICON_VCENTER);
	m_banner.SetTitle(TRL("Select Language"));
	m_banner.SetCaption(TRL("Here you can change the user interface language."));

	RECT rcList;
	m_listLang.GetClientRect(&rcList);
	const int wList = rcList.right - rcList.left - GetSystemMetrics(SM_CXVSCROLL);
	const int w2 = (wList * 2) / 20;
	const int w3 = (wList * 3) / 20;
	const int w5 = (wList * 5) / 20;
	m_listLang.InsertColumn(0, TRL("Installed Languages"), LVCFMT_LEFT, w5, 0);
	m_listLang.InsertColumn(1, TRL("Version"), LVCFMT_LEFT, w2, 1);
	m_listLang.InsertColumn(2, TRL("Author"), LVCFMT_LEFT, w5, 2);
	m_listLang.InsertColumn(3, TRL("Contact"), LVCFMT_LEFT, w5, 3);
	m_listLang.InsertColumn(4, TRL("File"), LVCFMT_LEFT, w3, 4);

	// m_ilIcons.Create(CPwSafeApp::GetClientIconsResourceID(), 16, 1, RGB(255,0,255));
	CPwSafeApp::CreateHiColorImageList(&m_ilIcons, IDB_CLIENTICONS_EX, 16);
	m_listLang.SetImageList(&m_ilIcons, LVSIL_SMALL);

	m_listLang.PostMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_SI_REPORT |
		LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_ONECLICKACTIVATE |
		LVS_EX_UNDERLINEHOT | LVS_EX_INFOTIP);

	m_listLang.DeleteAllItems();

	LV_ITEM lvi;
	ZeroMemory(&lvi, sizeof(LV_ITEM));
	lvi.iItem = m_listLang.InsertItem(LVIF_TEXT | LVIF_IMAGE, m_listLang.GetItemCount(),
		_T("English"), 0, 0, 1, NULL);

	CString strTemp;
	
	strTemp = PWM_VERSION_STR;
	lvi.iSubItem = 1; lvi.mask = LVIF_TEXT;
	lvi.pszText = (LPTSTR)(LPCTSTR)strTemp;
	m_listLang.SetItem(&lvi);

	strTemp = PWMX_ENGLISH_AUTHOR;
	lvi.iSubItem = 2; lvi.mask = LVIF_TEXT;
	lvi.pszText = (LPTSTR)(LPCTSTR)strTemp;
	m_listLang.SetItem(&lvi);

	strTemp = PWMX_ENGLISH_CONTACT;
	lvi.iSubItem = 3; lvi.mask = LVIF_TEXT;
	lvi.pszText = (LPTSTR)(LPCTSTR)strTemp;
	m_listLang.SetItem(&lvi);

	strTemp = TRL("Built-in");
	lvi.iSubItem = 4; lvi.mask = LVIF_TEXT;
	lvi.pszText = (LPTSTR)(LPCTSTR)strTemp;
	m_listLang.SetItem(&lvi);

	const std_string strActive = GetCurrentTranslationTable();

	std_string strFilter = SU_DriveLetterToUpper(Executable::instance().getPathOnly());
	strFilter += PWM_DIR_LANGUAGES;
	strFilter += _T("\\*.lng");

	CFileFind ff;
	BOOL bMore = ff.FindFile(strFilter.c_str(), 0);
	while(bMore != FALSE)
	{
		bMore = ff.FindNextFile();

		// Ignore KeePass 2.x LNGX files (these are found even though
		// "*.lng" is specified as file mask)
		CString strFileName = ff.GetFileName();
		strFileName = strFileName.MakeLower();
		if((strFileName.GetLength() >= 5) && (strFileName.Right(5) == _T(".lngx")))
			continue;

		CString strID = ff.GetFileTitle();
		strID = strID.MakeLower();
		if((strID != _T("standard")) && (strID != _T("english")))
		{
			VERIFY(LoadTranslationTable((LPCTSTR)ff.GetFileTitle()));

			strTemp = (LPCTSTR)ff.GetFileTitle();
			// strTemp += _T(" - "); // Name is used as identifier
			// strTemp += TRL("~LANGUAGENAME");

			lvi.iItem = m_listLang.InsertItem(LVIF_TEXT | LVIF_IMAGE,
				m_listLang.GetItemCount(), strTemp, 0, 0, 1, NULL);

			strTemp = TRL("~LANGUAGEVERSION");
			if(strTemp == _T("~LANGUAGEVERSION")) strTemp.Empty();
			lvi.iSubItem = 1; lvi.mask = LVIF_TEXT;
			lvi.pszText = (LPTSTR)(LPCTSTR)strTemp;
			m_listLang.SetItem(&lvi);

			strTemp = TRL("~LANGUAGEAUTHOR");
			if(strTemp == _T("~LANGUAGEAUTHOR")) strTemp.Empty();
			lvi.iSubItem = 2; lvi.mask = LVIF_TEXT;
			lvi.pszText = (LPTSTR)(LPCTSTR)strTemp;
			m_listLang.SetItem(&lvi);

			strTemp = TRL("~LANGUAGEAUTHOREMAIL");
			if(strTemp == _T("~LANGUAGEAUTHOREMAIL")) strTemp.Empty();
			lvi.iSubItem = 3; lvi.mask = LVIF_TEXT;
			lvi.pszText = (LPTSTR)(LPCTSTR)strTemp;
			m_listLang.SetItem(&lvi);

			strTemp = ff.GetFilePath();
			lvi.iSubItem = 4; lvi.mask = LVIF_TEXT;
			lvi.pszText = (LPTSTR)(LPCTSTR)strTemp;
			m_listLang.SetItem(&lvi);
		}
	}

	ff.Close();

	VERIFY(LoadTranslationTable(strActive.c_str()));
	return TRUE;
}
예제 #20
0
BOOL CPwSafeApp::ProcessControlCommands()
{
	LPCTSTR lpTrimChars = _T("\"' \t\r\n\\$%");

	CString strCmdLine = (LPCTSTR)GetCommandLine();
	strCmdLine = strCmdLine.Trim(lpTrimChars);
	strCmdLine = strCmdLine.MakeLower();

	if((strCmdLine.Right(9) == _T("-exit-all")) ||
		(strCmdLine.Right(9) == _T("/exit-all")))
	{
		::PostMessage(HWND_BROADCAST, CPwSafeDlg::GetKeePassControlMessageID(),
			KPCM_EXIT, 0);
		return TRUE;
	}

	if((strCmdLine.Right(10) == _T("-auto-type")) ||
		(strCmdLine.Right(10) == _T("/auto-type")))
	{
		::PostMessage(HWND_BROADCAST, CPwSafeDlg::GetKeePassControlMessageID(),
			KPCM_AUTOTYPE, 0);
		return TRUE;
	}

	if((strCmdLine.Right(9) == _T("-lock-all")) ||
		(strCmdLine.Right(9) == _T("/lock-all")))
	{
		::PostMessage(HWND_BROADCAST, CPwSafeDlg::GetKeePassControlMessageID(),
			KPCM_LOCK, 0);
		return TRUE;
	}

	if((strCmdLine.Right(11) == _T("-unlock-all")) ||
		(strCmdLine.Right(11) == _T("/unlock-all")))
	{
		::PostMessage(HWND_BROADCAST, CPwSafeDlg::GetKeePassControlMessageID(),
			KPCM_UNLOCK, 0);
		return TRUE;
	}

	if((strCmdLine.Right(18).CompareNoCase(KPCLOPT_FILEEXT_UNREG) == 0) ||
		(strCmdLine.Right(18).CompareNoCase(KPCLOPT_FILEEXT_UNREG_ALT) == 0))
	{
		ChangeKdbShellAssociation(FALSE, NULL);
		return TRUE;
	}

	if((strCmdLine.Right(16).CompareNoCase(KPCLOPT_FILEEXT_REG) == 0) ||
		(strCmdLine.Right(16).CompareNoCase(KPCLOPT_FILEEXT_REG_ALT) == 0))
	{
		ChangeKdbShellAssociation(TRUE, NULL);
		return TRUE;
	}

	if((strCmdLine.Right(18) == _T("-clear-urloverride")) ||
		(strCmdLine.Right(18) == _T("/clear-urloverride")))
	{
		CPrivateConfigEx cfg(TRUE);
		cfg.Set(PWMKEY_URLOVERRIDE, _T(""));
		return TRUE;
	}

	if((strCmdLine.Right(16) == _T("-get-urloverride")) ||
		(strCmdLine.Right(16) == _T("/get-urloverride")))
	{
		CPrivateConfigEx cfg(FALSE);
		TCHAR tszUrlOverride[SI_REGSIZE]; tszUrlOverride[0] = 0;
		cfg.Get(PWMKEY_URLOVERRIDE, tszUrlOverride);

		std::basic_string<TCHAR> strOutFile = WU_GetTempDirectory();
		strOutFile += _T("KeePass_UrlOverride.tmp");

		std::basic_string<TCHAR> strContent = _T("[KeePass]\r\n");
		strContent += PWMKEY_URLOVERRIDE;
		strContent += _T("=");
		strContent += tszUrlOverride;
		strContent += _T("\r\n");
		VERIFY(AU_WriteBigFile(strOutFile.c_str(), (const BYTE*)strContent.c_str(),
			static_cast<DWORD>(strContent.size() * sizeof(TCHAR)), FALSE) == PWE_SUCCESS);
		return TRUE;
	}

	// Pre-check whether the option is present or not; if the option is not present,
	// the CmdArgs instance must not be created at this point of time (plugins
	// haven't added option prefixes yet, so creating the CmdArgs instance leads
	// to unknown option errors here)
	int nSetUrl = strCmdLine.Find(_T("-set-urloverride:"));
	if(nSetUrl < 0) nSetUrl = strCmdLine.Find(_T("-set-urloverride="));
	if(nSetUrl < 0) nSetUrl = strCmdLine.Find(_T("/set-urloverride:"));
	if(nSetUrl < 0) nSetUrl = strCmdLine.Find(_T("/set-urloverride="));
	if(nSetUrl >= 0)
	{
		const std_string strUrlOverride = CmdArgs::instance().getUrlOverride();

		CPrivateConfigEx cfg(TRUE);
		cfg.Set(PWMKEY_URLOVERRIDE, strUrlOverride.c_str());
		return TRUE;
	}

	if((strCmdLine.Right(8) == _T("-preload")) ||
		(strCmdLine.Right(8) == _T("/preload")))
		return TRUE;

	return FALSE;
}
	void cNoAlphaShaderAccumulate::renderSingleShader(cShader* shader, std_string const& technique, uint renderMask)
	{
		uint passes;
		shader->setTechnique(technique.c_str());
		shader->setDefaultTexture();
		shader->begin(&passes);

		/*
		*	shader
		*/
		iter_shadercol it_shader = m_list.begin();
		for (; it_shader != m_list.end(); ++it_shader)
		{
			cUberShader* oriShader = _getUberShaderMgr()->get(it_shader->first);
			if (!oriShader)
				continue;

			/*
			*	material
			*/
			map_mtlcol& mtlList = it_shader->second->m_mtlColList;
			iter_mtlcol it_mtl = mtlList.begin();
			for (; it_mtl != mtlList.end(); ++it_mtl)
			{
				/*
				*	mesh
				*/
				vec_meshcol& meshList = it_mtl->second->m_meshColList;
				iter_meshcol it_mesh = meshList.begin();
				for (; it_mesh != meshList.end(); ++it_mesh)
				{
					cMesh* mesh = (*it_mesh)->m_mesh;

					if (!mesh)
					{
						//assert(0 && _T("mesh is NULL"));
						continue;
					}

					if (!(*it_mesh)->m_entity->isValidRenderMask(renderMask))
						continue;

					shader->setMeshParam(mesh, (*it_mesh)->m_entity);

					for (uint p = 0; p < passes; ++p)
					{
						shader->beginPass(p);

						sVBInfo* vbInfo = _getVBMgr()->get(mesh->m_vbBuid);
						sIBInfo* ibInfo = _getIBMgr()->get(mesh->m_ibBuid);

						cRenderer::renderIndexedPrimitive(vbInfo, ibInfo);

						shader->endPass();
					}
				}			
			}
		}

		shader->end();
	}
예제 #22
0
inline basic_cstring<CharT>&
basic_cstring<CharT>::assign( std_string const& s, size_type pos, size_type len )
{
    return *this = self_type( s.c_str() + pos, len );
}
예제 #23
0
inline
basic_cstring<CharT>::basic_cstring( std_string const& s )
: m_begin( s.c_str() )
, m_end( m_begin + s.size() )
{
}
예제 #24
0
파일: Name.cpp 프로젝트: bcontant/TentGine
Name::Name(const std_string& name)
	: hash(GenerateStringHash(name.c_str()))
	, text(name)
{
}
예제 #25
0
HRESULT CUpdateCheckEx::DownloadInfoFile(BYTE** ppbData, std_string& strError)
{
	if(ppbData == NULL) { ASSERT(FALSE); return E_POINTER; }
	*ppbData = NULL;

	/* TCHAR tszFile[MAX_PATH + 34];
	ZeroMemory(tszFile, sizeof(TCHAR) * (MAX_PATH + 34));

	URLDownloadToCacheFile(NULL, PWM_URL_VERSION, tszFile, URLOSTRM_GETNEWESTVERSION,
		0, NULL);

	if(_tcslen(tszFile) != 0)
	{
		FILE* fp = NULL;
		_tfopen_s(&fp, tszFile, _T("rb"));

		if(fp != NULL)
		{
			fseek(fp, 0, SEEK_END);
			const DWORD uFileSize = static_cast<DWORD>(ftell(fp));
			fseek(fp, 0, SEEK_SET);

			if(uFileSize != 0)
			{
				BYTE* pDataBuf = new BYTE[uFileSize + 2];

				fread(pDataBuf, 1, uFileSize, fp);
				fclose(fp);

				pDataBuf[uFileSize] = 0;
				pDataBuf[uFileSize + 1] = 0;

				*ppbData = pDataBuf;
			}
			else
			{
				strError = TRL("Cache error (cannot open cached file).");
				return E_ACCESSDENIED;
			}
		}
		else
		{
			strError = TRL("Cache error (cannot open cached file).");
			return E_ACCESSDENIED;
		}
	}
	else
	{
		strError = TRL("Connect failed, cannot check for updates.");
		return E_ACCESSDENIED;
	} */

	CKpInternetStream s(PWM_URL_VERSION, false);
	s.SetConnectOptions(5000, 1);
	s.SetTransferOptions(5000);

	std::vector<BYTE> vData;
	HRESULT r = s.ReadToEnd(vData);
	s.Close();
	if(FAILED(r) || (vData.size() == 0))
	{
		strError = TRL("Connect failed, cannot check for updates.");
		return r;
	}

	*ppbData = new BYTE[vData.size() + 2];
	(*ppbData)[vData.size()] = 0;
	(*ppbData)[vData.size() + 1] = 0;
	memcpy(*ppbData, &vData[0], vData.size());

	strError.clear();
	return S_OK;
}