Ejemplo n.º 1
0
FileLock::FileLock(const fs::path& file)
{
    fd = open(file.string().c_str(), O_RDWR);
    if (fd == -1) {
        reason = GetErrorReason();
    }
}
Ejemplo n.º 2
0
FileLock::FileLock(const fs::path& file)
{
    hFile = CreateFileW(file.wstring().c_str(),  GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
        nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
    if (hFile == INVALID_HANDLE_VALUE) {
        reason = GetErrorReason();
    }
}
Ejemplo n.º 3
0
bool FileLock::TryLock()
{
    if (hFile == INVALID_HANDLE_VALUE) {
        return false;
    }
    _OVERLAPPED overlapped = {0};
    if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, 0, 0, &overlapped)) {
        reason = GetErrorReason();
        return false;
    }
    return true;
}
Ejemplo n.º 4
0
bool FileLock::TryLock()
{
    if (fd == -1) {
        return false;
    }
    struct flock lock;
    lock.l_type = F_WRLCK;
    lock.l_whence = SEEK_SET;
    lock.l_start = 0;
    lock.l_len = 0;
    if (fcntl(fd, F_SETLK, &lock) == -1) {
        reason = GetErrorReason();
        return false;
    }
    return true;
}
Ejemplo n.º 5
0
/**
 * @param strLogText - error log text.
 */
void CExpressModeDlg::GetErrorLog(CString& strLogText)
{
	strLogText.Empty();
	if (! m_pXMLElementDocument)
		return;
	HRESULT hRes;

	static const TCHAR szDividerMsg[] = _T("----------------------------------------\r\n");
	static const TCHAR szNewLine[] = _T("\r\n");

	CString strApplication;
	GetXMLNodeText(m_pXMLElementDocument, OLESTR("./application"), strApplication);
	if (! strApplication.IsEmpty())
	{
		static const TCHAR szAppMsg[] = _T("Application: ");

		strLogText += szAppMsg;
		strLogText += strApplication;
		strLogText += szNewLine;
	}

	CString strVersion;
	GetXMLNodeText(m_pXMLElementDocument, OLESTR("./version"), strVersion);
	if (! strVersion.IsEmpty())
	{
		static const TCHAR szVersionMsg[] = _T("Version: ");

		strLogText += szVersionMsg;
		strLogText += strVersion;
		strLogText += szNewLine;
	}

	CString strComputer;
	GetXMLNodeText(m_pXMLElementDocument, OLESTR("./computer"), strComputer);
	if (! strComputer.IsEmpty())
	{
		static const TCHAR szComputerNameMsg[] = _T("Computer: ");

		strLogText += szComputerNameMsg;
		strLogText += strComputer;
		strLogText += szNewLine;
	}

	CString strUser;
	GetXMLNodeText(m_pXMLElementDocument, OLESTR("./user"), strUser);
	if (! strUser.IsEmpty())
	{
		static const TCHAR szUserNameMsg[] = _T("User: "******"./timestamp"), strTimeStamp);
	if (! strTimeStamp.IsEmpty())
	{
		ULONGLONG uiTimeStamp = _tcstoui64(strTimeStamp, NULL, 0);
		if (uiTimeStamp != 0)
		{
			GetDateTimeString(uiTimeStamp, strTimeStamp);
			if (! strTimeStamp.IsEmpty())
			{
				static const TCHAR szDateTimeMsg[] = _T("Date: ");

				strLogText += szDateTimeMsg;
				strLogText += strTimeStamp;
				strLogText += szNewLine;
			}
		}
	}

	CString strErrorReason;
	GetErrorReason(strErrorReason);
	if (! strErrorReason.IsEmpty())
	{
		static const TCHAR szErrorMsg[] = _T("\r\nError Reason:\r\n");

		strLogText += szErrorMsg;
		strLogText += szDividerMsg;
		strLogText += strErrorReason;
	}

	CString strUserMessage;
	if (GetXMLNodeText(m_pXMLElementDocument, OLESTR("./usermsg"), strUserMessage) &&
		! strUserMessage.IsEmpty())
	{
		static const TCHAR szUserMsg[] = _T("\r\n\r\nUser Message:\r\n");

		strLogText += szUserMsg;
		strLogText += szDividerMsg;
		strLogText += strUserMessage;
	}

	CComPtr<IXMLDOMNode> pXMLNodeSysError;
	if (SelectXMLNode(m_pXMLElementDocument, OLESTR("./syserror"), pXMLNodeSysError))
	{
		CString strSysErrorCode;
		GetXMLNodeText(pXMLNodeSysError, OLESTR("./code"), strSysErrorCode);
		if (! strSysErrorCode.IsEmpty())
		{
			static const TCHAR szSysErrorMsg[] = _T("\r\n\r\nSystem Error:\r\n");

			strLogText += szSysErrorMsg;
			strLogText += szDividerMsg;
			strLogText += strSysErrorCode;

			CString strSysErrorDescription;
			GetXMLNodeText(pXMLNodeSysError, OLESTR("./description"), strSysErrorDescription);
			if (! strSysErrorDescription.IsEmpty())
			{
				strLogText += _T(" - ");
				strLogText += strSysErrorDescription;
			}
		}
	}

	CComPtr<IXMLDOMNode> pXMLNodeComError;
	if (SelectXMLNode(m_pXMLElementDocument, OLESTR("./comerror"), pXMLNodeComError))
	{
		CString strComErrorDescription;
		GetXMLNodeText(pXMLNodeComError, OLESTR("./description"), strComErrorDescription);
		CString strComErrorHelpFile;
		GetXMLNodeText(pXMLNodeComError, OLESTR("./helpfile"), strComErrorHelpFile);
		CString strComErrorSource;
		GetXMLNodeText(pXMLNodeComError, OLESTR("./source"), strComErrorSource);
		CString strComErrorGuid;
		GetXMLNodeText(pXMLNodeComError, OLESTR("./guid"), strComErrorGuid);

		if (! strComErrorDescription.IsEmpty() ||
			! strComErrorHelpFile.IsEmpty() ||
			! strComErrorSource.IsEmpty() ||
			! strComErrorGuid.IsEmpty())
		{
			static const TCHAR szCOMErrorMsg[] = _T("\r\n\r\nCOM Error:\r\n");
			static const TCHAR szDescriptionMsg[] = _T("Description: ");
			static const TCHAR szHelpFileMsg[] = _T("Help File:   ");
			static const TCHAR szSourceMsg[] = _T("Source:      ");
			static const TCHAR szGuidMsg[] = _T("GUID:        ");

			strLogText += szCOMErrorMsg;
			strLogText += szDividerMsg;

			BOOL bNotEmpty = FALSE;

			if (! strComErrorDescription.IsEmpty())
			{
				bNotEmpty = TRUE;
				strLogText += szDescriptionMsg;
				strLogText += strComErrorDescription;
			}

			if (! strComErrorHelpFile.IsEmpty())
			{
				if (bNotEmpty)
					strLogText += szNewLine;
				else
					bNotEmpty = TRUE;
				strLogText += szHelpFileMsg;
				strLogText += strComErrorHelpFile;
			}

			if (! strComErrorSource.IsEmpty())
			{
				if (bNotEmpty)
					strLogText += szNewLine;
				else
					bNotEmpty = TRUE;
				strLogText += szSourceMsg;
				strLogText += strComErrorSource;
			}

			if (! strComErrorGuid.IsEmpty())
			{
				if (bNotEmpty)
					strLogText += szNewLine;
				else
					bNotEmpty = TRUE;
				strLogText += szGuidMsg;
				strLogText += strComErrorGuid;
			}
		}
	}

	CComPtr<IXMLDOMNode> pXMLNodeRegisters;
	if (SelectXMLNode(m_pXMLElementDocument, OLESTR("./registers"), pXMLNodeRegisters))
	{
		static const TCHAR szRegistersMsg[] = _T("\r\n\r\nRegisters:\r\n");

		CString strRegValue;

		switch (GetPlatform())
		{
		case TPLAT_X86:
			{
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./eax"), strRegValue);
				DWORD dwEAX = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./ebx"), strRegValue);
				DWORD dwEBX = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./ecx"), strRegValue);
				DWORD dwECX = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./edx"), strRegValue);
				DWORD dwEDX = _tcstoul(strRegValue, NULL, 0);

				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./esi"), strRegValue);
				DWORD dwESI = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./edi"), strRegValue);
				DWORD dwEDI = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./esp"), strRegValue);
				DWORD dwESP = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./ebp"), strRegValue);
				DWORD dwEBP = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./eip"), strRegValue);
				DWORD dwEIP = _tcstoul(strRegValue, NULL, 0);

				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./cs"), strRegValue);
				DWORD dwCS = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./ds"), strRegValue);
				DWORD dwDS = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./ss"), strRegValue);
				DWORD dwSS = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./es"), strRegValue);
				DWORD dwES = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./fs"), strRegValue);
				DWORD dwFS = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./gs"), strRegValue);
				DWORD dwGS = _tcstoul(strRegValue, NULL, 0);

				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./eflags"), strRegValue);
				DWORD dwEFLAGS = _tcstoul(strRegValue, NULL, 0);

				strRegValue.Format(
					_T("EAX=%08X  EBX=%08X  ECX=%08X  EDX=%08X\r\n")
					_T("ESI=%08X  EDI=%08X  FLG=%08X\r\n")
					_T("EBP=%08X  ESP=%08X  EIP=%08X\r\n")
					_T("CS=%04X  DS=%04X  SS=%04X  ES=%04X  FS=%04X  GS=%04X"),
					dwEAX, dwEBX, dwECX, dwEDX,
					dwESI, dwEDI, dwEFLAGS,
					dwEBP, dwESP, dwEIP,
					dwCS, dwDS, dwSS, dwES, dwFS, dwGS);
			}
			break;
		case TPLAT_X64:
			{
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rax"), strRegValue);
				DWORD dwRAX = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rbx"), strRegValue);
				DWORD dwRBX = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rcx"), strRegValue);
				DWORD dwRCX = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rdx"), strRegValue);
				DWORD dwRDX = _tcstoul(strRegValue, NULL, 0);

				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rsi"), strRegValue);
				DWORD dwRSI = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rdi"), strRegValue);
				DWORD dwRDI = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rsp"), strRegValue);
				DWORD dwRSP = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rbp"), strRegValue);
				DWORD dwRBP = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./rip"), strRegValue);
				DWORD dwRIP = _tcstoul(strRegValue, NULL, 0);

				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./cs"), strRegValue);
				DWORD dwCS = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./ds"), strRegValue);
				DWORD dwDS = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./ss"), strRegValue);
				DWORD dwSS = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./es"), strRegValue);
				DWORD dwES = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./fs"), strRegValue);
				DWORD dwFS = _tcstoul(strRegValue, NULL, 0);
				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./gs"), strRegValue);
				DWORD dwGS = _tcstoul(strRegValue, NULL, 0);

				GetXMLNodeText(pXMLNodeRegisters, OLESTR("./eflags"), strRegValue);
				DWORD dwEFLAGS = _tcstoul(strRegValue, NULL, 0);

				strRegValue.Format(
					_T("RAX=%016X  RBX=%016X\r\n")
					_T("RCX=%016X  RDX=%016X\r\n")
					_T("RSI=%016X  RDI=%016X\r\n")
					_T("FLG=%08X          RBP=%016X\r\n")
					_T("RSP=%016X  RIP=%016X\r\n")
					_T("CS=%04X  DS=%04X  SS=%04X  ES=%04X  FS=%04X  GS=%04X"),
					dwRAX, dwRBX, dwRCX, dwRDX,
					dwRSI, dwRDI, dwEFLAGS,
					dwRBP, dwRSP, dwRIP,
					dwCS, dwDS, dwSS, dwES, dwFS, dwGS);
			}
			break;
		default:
			_ASSERT(FALSE);
		}

		strLogText += szRegistersMsg;
		strLogText += szDividerMsg;
		strLogText += strRegValue;
	}

	CComPtr<IXMLDOMNode> pXMLNodeCpus;
	if (SelectXMLNode(m_pXMLElementDocument, OLESTR("./cpus"), pXMLNodeCpus))
	{
		CString strNumCpus;
		GetXMLNodeText(pXMLNodeCpus, OLESTR("./number"), strNumCpus);
		if (! strNumCpus.IsEmpty() && _tcstoul(strNumCpus, NULL, 0) != 0)
		{
			static const TCHAR szCpuMsg[] = _T("\r\n\r\nCPU:\r\n");
			static const TCHAR szArchitectureMsg[] = _T("Architecture: ");
			static const TCHAR szNumCpusMsg[] = _T("Number of Processors:  ");
			static const TCHAR szCpuDescriptionsMsg[] = _T("\r\nProcessors Descriptions:");

			strLogText += szCpuMsg;
			strLogText += szDividerMsg;

			CString strArchitecture;
			GetXMLNodeText(pXMLNodeCpus, OLESTR("./architecture"), strArchitecture);
			if (! strArchitecture.IsEmpty())
			{
				strLogText += szArchitectureMsg;
				strLogText += strArchitecture;
				strLogText += szNewLine;
			}

			strLogText += szNumCpusMsg;
			strLogText += strNumCpus;
			strLogText += szCpuDescriptionsMsg;

			CString strCpuDescription;
			CComPtr<IXMLDOMNodeList> pXMLNodeListCpus;
			if (SelectXMLNodes(pXMLNodeCpus, OLESTR("./cpu"), pXMLNodeListCpus))
			{
				for (int iItemPos = 1; ; ++iItemPos)
				{
					CComPtr<IXMLDOMNode> pXMLNodeCpu;
					hRes = pXMLNodeListCpus->nextNode(&pXMLNodeCpu);
					CHECK_HRESULT(hRes);
					if (hRes != S_OK)
						break;

					GetXMLNodeText(pXMLNodeCpu, OLESTR("./description"), strCpuDescription);
					TCHAR szItemPos[16];
					_itot_s(iItemPos, szItemPos, countof(szItemPos), 10);

					strLogText += szNewLine;
					strLogText += szItemPos;
					strLogText += _T(". ");
					strLogText += strCpuDescription;
				}
			}
		}
	}

	CComPtr<IXMLDOMNode> pXMLNodeOs;
	if (SelectXMLNode(m_pXMLElementDocument, OLESTR("./os"), pXMLNodeOs))
	{
		static const TCHAR szOSMsg[] = _T("\r\n\r\nOperating System:\r\n");
		static const TCHAR szOsVersionMsg[] = _T("OS Version:    ");
		static const TCHAR szBuildNumberMsg[] = _T("Build Number:  ");

		CString strOsVersion;
		GetXMLNodeText(pXMLNodeOs, OLESTR("./version"), strOsVersion);
		CString strServicePack;
		GetXMLNodeText(pXMLNodeOs, OLESTR("./spack"), strServicePack);
		CString strBuildNumber;
		GetXMLNodeText(pXMLNodeOs, OLESTR("./build"), strBuildNumber);

		strLogText += szOSMsg;
		strLogText += szDividerMsg;
		strLogText += szOsVersionMsg;
		strLogText += strOsVersion;
		if (! strServicePack.IsEmpty())
		{
			strLogText += _T(' ');
			strLogText += strServicePack;
		}
		strLogText += szNewLine;
		strLogText += szBuildNumberMsg;
		strLogText += strBuildNumber;
	}

	CComPtr<IXMLDOMNode> pXMLNodeMemory;
	if (SelectXMLNode(m_pXMLElementDocument, OLESTR("./memory"), pXMLNodeMemory))
	{
		static const TCHAR szMemMsg[] = _T("\r\n\r\nMemory Usage:\r\n");

		CString strMemValue;

		GetXMLNodeText(pXMLNodeMemory, OLESTR("./load"), strMemValue);
		DWORD dwCurMemLoad = _tcstoul(strMemValue, NULL, 0);
		GetXMLNodeText(pXMLNodeMemory, OLESTR("./totalphys"), strMemValue);
		DWORD dwTotalPhysMem = _tcstoul(strMemValue, NULL, 0);
		GetXMLNodeText(pXMLNodeMemory, OLESTR("./availphys"), strMemValue);
		DWORD dwAvailPhysMem = _tcstoul(strMemValue, NULL, 0);
		GetXMLNodeText(pXMLNodeMemory, OLESTR("./totalpage"), strMemValue);
		DWORD dwTotalPageMem = _tcstoul(strMemValue, NULL, 0);
		GetXMLNodeText(pXMLNodeMemory, OLESTR("./availpage"), strMemValue);
		DWORD dwAvailPageMem = _tcstoul(strMemValue, NULL, 0);

		strMemValue.Format(
			_T("Current Memory Load:         %lu%%\r\n")
			_T("Total Physical Memory:       %lu MB\r\n")
			_T("Available Physical Memory:   %lu MB\r\n")
			_T("Total Page File Memory:      %lu MB\r\n")
			_T("Available Page File Memory:  %lu MB"),
			dwCurMemLoad,
			dwTotalPhysMem / (1024 * 1024),
			dwAvailPhysMem / (1024 * 1024),
			dwTotalPageMem / (1024 * 1024),
			dwAvailPageMem / (1024 * 1024));

		strLogText += szMemMsg;
		strLogText += szDividerMsg;
		strLogText += strMemValue;
	}

	CStackEntry StackEntry;
	CComPtr<IXMLDOMNodeList> pXMLNodeListThreads;
	if (SelectXMLNodes(m_pXMLElementDocument, OLESTR("./threads/thread"), pXMLNodeListThreads))
	{
		static const TCHAR szTraceMsg[] = _T("\r\nStack Trace: ");
		static const TCHAR szThreadIDMsg[] = _T(", TID: ");
		static const TCHAR szThreadMsg[] = _T(" Thread");

		strLogText += szNewLine;

		CString strThreadID, strThreadStatus;
		for (;;)
		{
			CComPtr<IXMLDOMNode> pXMLNodeThread;
			hRes = pXMLNodeListThreads->nextNode(&pXMLNodeThread);
			CHECK_HRESULT(hRes);
			if (hRes != S_OK)
				break;

			GetXMLNodeText(pXMLNodeThread, OLESTR("./id"), strThreadID);
			GetXMLNodeText(pXMLNodeThread, OLESTR("./status"), strThreadStatus);
			if (! strThreadStatus.IsEmpty())
			{
				strThreadStatus.MakeLower();
				strThreadStatus.SetAt(0, (TCHAR)_totupper(strThreadStatus.GetAt(0)));
				strThreadStatus += szThreadMsg;
			}

			strLogText += szTraceMsg;
			strLogText += strThreadStatus;
			strLogText += szThreadIDMsg;
			strLogText += strThreadID;
			strLogText += szNewLine;
			strLogText += szDividerMsg;

			CComPtr<IXMLDOMNodeList> pXMLNodeListStackFrames;
			if (SelectXMLNodes(pXMLNodeThread, OLESTR("./stack/frame"), pXMLNodeListStackFrames))
			{
				for (;;)
				{
					CComPtr<IXMLDOMNode> pXMLNodeStackFrame;
					hRes = pXMLNodeListStackFrames->nextNode(&pXMLNodeStackFrame);
					CHECK_HRESULT(hRes);
					if (hRes != S_OK)
						break;
					GetStackEntry(pXMLNodeStackFrame, StackEntry);

					if (! StackEntry.m_strModule.IsEmpty())
					{
						strLogText += _T('\"');
						strLogText += StackEntry.m_strModule;
						strLogText += _T('\"');
					}
					if (! StackEntry.m_strAddress.IsEmpty())
					{
						strLogText += _T(" at ");
						strLogText += StackEntry.m_strAddress;
					}
					if (! StackEntry.m_strFunctionInfo.IsEmpty())
					{
						strLogText += _T(", ");
						strLogText += StackEntry.m_strFunctionInfo;
					}

					if (! StackEntry.m_strSourceFile.IsEmpty())
					{
						strLogText += _T(" in ");
						strLogText += StackEntry.m_strSourceFile;
					}

					if (! StackEntry.m_strLineInfo.IsEmpty())
					{
						strLogText += _T(", ");
						strLogText += StackEntry.m_strLineInfo;
					}

					strLogText += szNewLine;
				}
			}
		}
	}

	CString strCommandLine;
	GetXMLNodeText(m_pXMLElementDocument, OLESTR("./cmdline"), strCommandLine);
	if (! strCommandLine.IsEmpty())
	{
		static const TCHAR szCommandLineMsg[] = _T("\r\nCommand Line:\r\n");

		strLogText += szCommandLineMsg;
		strLogText += szDividerMsg;
		strLogText += strCommandLine;
	}

	CString strCurrentDirectory;
	GetXMLNodeText(m_pXMLElementDocument, OLESTR("./curdir"), strCurrentDirectory);
	if (! strCurrentDirectory.IsEmpty())
	{
		static const TCHAR szCurrentDirMsg[] = _T("\r\n\r\nCurrent Directory:\r\n");

		strLogText += szCurrentDirMsg;
		strLogText += szDividerMsg;
		strLogText += strCurrentDirectory;
	}

	CComPtr<IXMLDOMNodeList> pXMLNodeListEnvVars;
	if (SelectXMLNodes(m_pXMLElementDocument, OLESTR("./environment/variable"), pXMLNodeListEnvVars))
	{
		static const TCHAR szEnvironmentMsg[] = _T("\r\n\r\nEnvironment Variables:\r\n");

		strLogText += szEnvironmentMsg;
		strLogText += szDividerMsg;

		CString strVarName, strVarValue;
		for (;;)
		{
			CComPtr<IXMLDOMNode> pXMLNodeEnvVar;
			hRes = pXMLNodeListEnvVars->nextNode(&pXMLNodeEnvVar);
			CHECK_HRESULT(hRes);
			if (hRes != S_OK)
				break;

			GetXMLNodeText(pXMLNodeEnvVar, OLESTR("./name"), strVarName);
			GetXMLNodeText(pXMLNodeEnvVar, OLESTR("./value"), strVarValue);

			strLogText += strVarName;
			strLogText += _T('=');
			strLogText += strVarValue;
			strLogText += szNewLine;
		}
	}

	CComPtr<IXMLDOMNodeList> pXMLNodeListProcesses;
	if (SelectXMLNodes(m_pXMLElementDocument, OLESTR("./processes/process"), pXMLNodeListProcesses))
	{
		static const TCHAR szProcessMsg[] = _T("\r\nProcess: ");
		static const TCHAR szModulesMsg[] = _T(", Modules:\r\n");
		static const TCHAR szProcessIDMsg[] = _T(", PID: ");
		static const TCHAR szBaseMsg[] = _T(", Base: ");

		CString strProcessID, strProcessName, strModuleName, strModuleVersion, strModuleBase;
		for (;;)
		{
			CComPtr<IXMLDOMNode> pXMLNodeProcess;
			hRes = pXMLNodeListProcesses->nextNode(&pXMLNodeProcess);
			CHECK_HRESULT(hRes);
			if (hRes != S_OK)
				break;

			GetXMLNodeText(pXMLNodeProcess, OLESTR("./name"), strProcessName);
			GetXMLNodeText(pXMLNodeProcess, OLESTR("./id"), strProcessID);

			strLogText += szProcessMsg;
			strLogText += strProcessName;
			strLogText += szProcessIDMsg;
			strLogText += strProcessID;
			strLogText += szModulesMsg;
			strLogText += szDividerMsg;

			CComPtr<IXMLDOMNodeList> pXMLNodeListModules;
			if (SelectXMLNodes(pXMLNodeProcess, OLESTR("./modules/module"), pXMLNodeListModules))
			{
				for (;;)
				{
					CComPtr<IXMLDOMNode> pXMLNodeModule;
					hRes = pXMLNodeListModules->nextNode(&pXMLNodeModule);
					CHECK_HRESULT(hRes);
					if (hRes != S_OK)
						break;

					GetXMLNodeText(pXMLNodeModule, OLESTR("./name"), strModuleName);
					GetXMLNodeText(pXMLNodeModule, OLESTR("./version"), strModuleVersion);
					GetXMLNodeText(pXMLNodeModule, OLESTR("./base"), strModuleBase);

					strLogText += strModuleName;

					if (! strModuleVersion.IsEmpty())
					{
						strLogText += _T(" (");
						strLogText += strModuleVersion;
						strLogText += _T(')');
					}

					if (! strModuleBase.IsEmpty())
					{
						PVOID ptrBaseAddress = (PVOID)_tcstoui64(strModuleBase, NULL, 0);
						if (ptrBaseAddress != NULL)
						{
							strModuleBase.Format(_T("%08lX"), ptrBaseAddress);
							strLogText += szBaseMsg;
							strLogText += strModuleBase;
						}
					}

					strLogText += szNewLine;
				}
			}
		}
	}
}
Ejemplo n.º 6
0
void CExpressModeDlg::SetErrorReasonText()
{
	CString strErrorReason;
	GetErrorReason(strErrorReason);
	m_txtErrorReason.SetWindowText(strErrorReason);
}