コード例 #1
0
ファイル: ATLSecurity.cpp プロジェクト: Jinjiego/VCSamples
bool DisplayHelp()
{
	CPath path;
	if (!::GetModuleFileName(NULL, CStrBufA(path, MAX_PATH), MAX_PATH))
		return false;
	path.StripPath();

	CString str;
	str.FormatMessage(
		_T("Checks the security descriptor on a named object.\n")
		_T("\n")
		_T("Usage: %1 [-?] [-at|-no_at] [-file|-regkey|-service|-kernel|-printer] [objectname]*\n")
		_T("  -?        Display this help message\n")
		_T("  -at       Examine the process access token (default)\n")
		_T("  -no_at    Don't examine the process access token\n")
		_T("  -file     objectname is the name of a file to examine (default)\n")
		_T("  -regkey   objectname is the name of a registry key to examine\n")
		_T("  -service  objectname is the name of a service to examine\n")
		_T("  -kernel   objectname is the name of a kernel object to examine\n")
		_T("            these can be semaphores, events, mutexes, waitable timers, and file mappings\n")
		_T("  -printer  objectname is the name of a printer to examine\n")
		_T("  objectname defaults to \\\\.\\A:\n")
		_T("Example: %1 C:\\boot.ini\n")
		_T("\n")
		_T("Note: \\\\.\\A: is not the same as A:\n")
		_T("Checking \\\\.\\A: checks access to the floppy drive,\n")
		_T("Checking A: checks access to the root directory"),
		path);
	Log(str);

	return false;
}
コード例 #2
0
ファイル: Patch.cpp プロジェクト: Teivaz/TortoiseGit
int CPatch::Parse(const CString& pathfile, bool parseBody)
{
	m_PathFile = pathfile;

	CFile PatchFile;

	if (!PatchFile.Open(m_PathFile, CFile::modeRead))
		return -1;

	PatchFile.Read(CStrBufA(m_Body, (UINT)PatchFile.GetLength()), (UINT)PatchFile.GetLength());
	PatchFile.Close();

	try
	{
		int start=0;
		CStringA one;
		one=m_Body.Tokenize("\n",start);

		if (start == -1)
			return -1;
		one=m_Body.Tokenize("\n",start);
		if(one.GetLength()>6)
			CGit::StringAppend(&m_Author, (BYTE*)(LPCSTR)one + 6, CP_UTF8, one.GetLength() - 6);

		if (start == -1)
			return -1;
		one=m_Body.Tokenize("\n",start);
		if(one.GetLength()>6)
			CGit::StringAppend(&m_Date, (BYTE*)(LPCSTR)one + 6, CP_UTF8, one.GetLength() - 6);

		if (start == -1)
			return -1;
		one=m_Body.Tokenize("\n",start);
		if(one.GetLength()>9)
		{
			CGit::StringAppend(&m_Subject, (BYTE*)(LPCSTR)one + 9, CP_UTF8, one.GetLength() - 9);
			while (m_Body.GetLength() > start && m_Body.GetAt(start) == _T(' '))
			{
				one = m_Body.Tokenize("\n", start);
				CGit::StringAppend(&m_Subject, (BYTE*)(LPCSTR)one, CP_UTF8, one.GetLength());
			}
		}

		if (!parseBody)
			return 0;

		if (start + 1 < m_Body.GetLength())
			CGit::StringAppend(&m_strBody, (BYTE*)(LPCSTR)m_Body + start + 1, CP_UTF8, m_Body.GetLength() - start - 1);
	}
	catch (CException *)
	{
		return -1;
	}

	return 0;
}