/** * @param eNumFormat - numeric format. */ void CNumEdit::SetNumFormat(NUM_FORMAT eNumFormat) { if (m_eNumFormat == eNumFormat) return; if (m_hWnd == NULL) { m_eNumFormat = eNumFormat; return; } TCHAR szValue[64]; GetWindowText(szValue, countof(szValue)); if (*szValue) { switch (m_eNumFormat) { case NF_HEX: { UINT64 uValue = _tcstoui64(szValue, NULL, 16); _ui64tot_s(uValue, szValue, countof(szValue), 10); } break; case NF_DEC: { bool bNegative = false; for (int i = 0; ; ++i) { if (szValue[i] != _T(' ')) { if (szValue[i] == _T('-')) bNegative = true; break; } } if (bNegative) { INT64 iValue = _tcstoi64(szValue, NULL, 10); _i64tot_s(iValue, szValue, countof(szValue), 16); } else { UINT64 uValue = _tcstoui64(szValue, NULL, 10); _ui64tot_s(uValue, szValue, countof(szValue), 16); } } break; default: *szValue = _T('\0'); } SetValue(szValue, countof(szValue)); } m_eNumFormat = eNumFormat; UpdateRadixTitle(); }
/** * @param uValue - numeric value. */ void CNumEdit::GetValue(UINT64& uValue) { TCHAR szValue[64]; GetWindowText(szValue, countof(szValue)); switch (m_eNumFormat) { case NF_HEX: uValue = _tcstoui64(szValue, NULL, 16); break; case NF_DEC: uValue = _tcstoui64(szValue, NULL, 10); break; default: uValue = 0; } }
/** * @param strReportName - report file name. */ void CExpressModeDlg::GetReportFileName(CString& strReportName) { strReportName.Empty(); if (! m_pXMLElementDocument) return; CString strTimeStamp; GetXMLNodeText(m_pXMLElementDocument, OLESTR("./timestamp"), strTimeStamp); if (! strTimeStamp.IsEmpty()) { ULONGLONG uiTimeStamp = _tcstoui64(strTimeStamp, NULL, 0); if (uiTimeStamp != 0) { CString strApplication; GetXMLNodeText(m_pXMLElementDocument, OLESTR("./application"), strApplication); if (! strApplication.IsEmpty()) { int nLength = strApplication.GetLength(); for (int i = 0; i < nLength; ++i) { TCHAR chValue = strApplication.GetAt(i); if (_istalnum(chValue)) strReportName += chValue; } strReportName += _T('_'); } SYSTEMTIME DateTime; GetDateTime(uiTimeStamp, DateTime); CString strTimeStamp; strTimeStamp.Format(_T("error_report_%02d%02d%02d-%02d%02d%02d.log"), DateTime.wYear % 100, DateTime.wMonth, DateTime.wDay, DateTime.wHour, DateTime.wMinute, DateTime.wSecond); strReportName += strTimeStamp; } } }
// Get CIEHostWindow ID ULONG_PTR CPlugin::GetNavigateWindowId() const { CString strId = GetNavigateParam("getNavigateWindowId"); #ifdef _M_X64 return _tcstoui64(strId, NULL, 10); #else return _tcstoul(strId, NULL, 10); #endif }
/** * @param pXMLNodeParent - parent XML node. * @param rStackEntry - stack entry information. */ void CExpressModeDlg::GetStackEntry(const CComPtr<IXMLDOMNode>& pXMLNodeParent, CStackEntry& rStackEntry) { GetXMLNodeText(pXMLNodeParent, OLESTR("./module"), rStackEntry.m_strModule); GetXMLNodeText(pXMLNodeParent, OLESTR("./address"), rStackEntry.m_strAddress); GetXMLNodeText(pXMLNodeParent, OLESTR("./function/name"), rStackEntry.m_strFunctionName); GetXMLNodeText(pXMLNodeParent, OLESTR("./function/offset"), rStackEntry.m_strFunctionOffset); GetXMLNodeText(pXMLNodeParent, OLESTR("./file"), rStackEntry.m_strSourceFile); GetXMLNodeText(pXMLNodeParent, OLESTR("./line/number"), rStackEntry.m_strLineNumber); GetXMLNodeText(pXMLNodeParent, OLESTR("./line/offset"), rStackEntry.m_strLineOffset); UpdateStackEntryFromMap(rStackEntry); if (! rStackEntry.m_strFunctionName.IsEmpty()) { rStackEntry.m_strFunctionInfo = rStackEntry.m_strFunctionName; rStackEntry.m_strFunctionInfo += _T("()"); if (! rStackEntry.m_strFunctionOffset.IsEmpty() && _tcstoui64(rStackEntry.m_strFunctionOffset, NULL, 0) != 0) { rStackEntry.m_strFunctionInfo += _T('+'); rStackEntry.m_strFunctionInfo += rStackEntry.m_strFunctionOffset; rStackEntry.m_strFunctionInfo += _T(" byte(s)"); } } else rStackEntry.m_strFunctionInfo.Empty(); if (! rStackEntry.m_strLineNumber.IsEmpty()) { rStackEntry.m_strLineInfo = _T("line "); rStackEntry.m_strLineInfo += rStackEntry.m_strLineNumber; if (! rStackEntry.m_strLineOffset.IsEmpty() && _tcstoui64(rStackEntry.m_strLineOffset, NULL, 0) != 0) { rStackEntry.m_strLineInfo += _T('+'); rStackEntry.m_strLineInfo += rStackEntry.m_strLineOffset; rStackEntry.m_strLineInfo += _T(" byte(s)"); } } else rStackEntry.m_strLineInfo.Empty(); }
/** * @param rStackEntry - stack entry information. */ void CExpressModeDlg::UpdateStackEntryFromMap(CStackEntry& rStackEntry) { if (! rStackEntry.m_strAddress.IsEmpty() && ( rStackEntry.m_strFunctionName.IsEmpty() || rStackEntry.m_strSourceFile.IsEmpty() || rStackEntry.m_strLineNumber.IsEmpty() )) { int nAddrPos = rStackEntry.m_strAddress.Find(_T(':')); if (nAddrPos >= 0) ++nAddrPos; else nAddrPos = 0; PVOID ptrAddress = (PVOID)_tcstoui64((PCTSTR)rStackEntry.m_strAddress + nAddrPos, NULL, 16); if (ptrAddress != NULL) { boost::shared_ptr<CBaseProcessor> pBaseProcessor(GetModuleInfo(rStackEntry.m_strModule)); if (pBaseProcessor.get() != NULL) { boost::shared_ptr<CBaseFnInfo> pFnInfo; DWORD64 dwDisplacement64; if (pBaseProcessor->FindFunctionInfo(ptrAddress, pFnInfo, dwDisplacement64)) { std::string strFunctionName(pFnInfo->GetName()); boost::match_results<std::string::const_iterator> what; if (boost::regex_search(strFunctionName, what, m_rxFunctionName)) rStackEntry.m_strFunctionName = CA2CT(what[1].str().c_str()); else rStackEntry.m_strFunctionName = CA2CT(strFunctionName.c_str()); if (dwDisplacement64 != 0) rStackEntry.m_strFunctionOffset.Format(_T("%I64u"), dwDisplacement64); else rStackEntry.m_strFunctionOffset.Empty(); } boost::shared_ptr<CBaseFileInfo> pFileInfo; boost::shared_ptr<CBaseLineInfo> pLineInfo; DWORD dwDisplacement32; if (pBaseProcessor->FindLineInfo(ptrAddress, pFileInfo, pLineInfo, dwDisplacement32)) { rStackEntry.m_strSourceFile = CA2CT(pFileInfo->GetFileName().c_str()); rStackEntry.m_strLineNumber.Format(_T("%u"), pLineInfo->GetNumber()); if (dwDisplacement32 != 0) rStackEntry.m_strLineOffset.Format(_T("%I32u"), dwDisplacement32); else rStackEntry.m_strLineOffset.Empty(); } } } } }
/** * @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; } } } } }
/** * @param strModule - module file name. * @return pointer to module processor. */ boost::shared_ptr<CBaseProcessor> CExpressModeDlg::GetModuleInfo(const CString& strModule) { boost::shared_ptr<CBaseProcessor> pBaseProcessor; if (strModule.IsEmpty()) return pBaseProcessor; CModuleMap::iterator itModule = m_mapModules.find(strModule); if (itModule == m_mapModules.end()) { if (m_pXMLNodeProcess != NULL) { CString strExpression; strExpression.Format(_T("./modules/module[name=\"%s\"]"), strModule); CComPtr<IXMLDOMNode> pXMLNodeModule; if (SelectXMLNode(m_pXMLNodeProcess, CT2CW(strExpression), pXMLNodeModule)) { CString strBaseAddress; GetXMLNodeText(pXMLNodeModule, OLESTR("./base"), strBaseAddress); PVOID ptrBaseAddress = (PVOID)_tcstoui64(strBaseAddress, NULL, 0); CString strModuleSize; GetXMLNodeText(pXMLNodeModule, OLESTR("./size"), strModuleSize); DWORD dwModuleSize = _tcstoul(strModuleSize, NULL, 0); if (ptrBaseAddress != NULL && dwModuleSize != 0) { TCHAR szModuleName[MAX_PATH]; _tcscpy_s(szModuleName, countof(szModuleName), PathFindFileName(strModule)); TCHAR szMapPdbFolder[MAX_PATH]; m_txtMapPdbFolder.GetWindowText(szMapPdbFolder, countof(szMapPdbFolder)); TCHAR szSystemFolder[MAX_PATH]; GetSystemDirectory(szSystemFolder, countof(szSystemFolder)); TCHAR szMapPdbFile[MAX_PATH]; if (! FindFileByPattern(szMapPdbFolder, szModuleName, _T(".map"), szMapPdbFile) && ! FindFileByPattern(szMapPdbFolder, szModuleName, _T(".pdb"), szMapPdbFile) && ! FindFileByPattern(szSystemFolder, szModuleName, _T(".map"), szMapPdbFile) && ! FindFileByPattern(szSystemFolder, szModuleName, _T(".pdb"), szMapPdbFile)) { return pBaseProcessor; } CBaseProcessor::PROCESSED_FILE_TYPE eProcessedFileType = CBaseProcessor::GetFileType(szMapPdbFile); switch (eProcessedFileType) { case CBaseProcessor::PFT_MAP: { CMapProcessor* pMapProcessor = STATIC_DOWNCAST(CMapProcessor, m_pMapProcessor.get()); if (pMapProcessor == NULL) { pMapProcessor = new CMapProcessor(); pBaseProcessor.reset(pMapProcessor); } pBaseProcessor = m_pMapProcessor; pMapProcessor->LoadMapText(szMapPdbFile); pMapProcessor->SetBaseAddress(ptrBaseAddress); } break; case CBaseProcessor::PFT_PDB: { CPdbProcessor* pPdbProcessor = STATIC_DOWNCAST(CPdbProcessor, m_pPdbProcessor.get()); if (pPdbProcessor == NULL) { pPdbProcessor = new CPdbProcessor(); m_pPdbProcessor.reset(pPdbProcessor); } pBaseProcessor = m_pPdbProcessor; pPdbProcessor->LoadModule(szMapPdbFile, ptrBaseAddress, dwModuleSize); } break; } if (pBaseProcessor.get() != NULL) m_mapModules.insert(CModuleMap::value_type(strModule, pBaseProcessor)); } } } } else pBaseProcessor = itModule->second; return pBaseProcessor; }
ULONGLONG StringToUInt64(LPCTSTR pszString) { return _tcstoui64(pszString,nullptr,0); }
size_t ConvertStrToAddress(CString str) { //int foundIdx = -1; //if ((foundIdx = Spot.Text.FindOneOf(_T("+-"))) != -1) //{ // CString moduleName = Spot.Text.Left(foundIdx); // foundIdx = Spot.Text.GetLength() - foundIdx; // CString remainder = Spot.Text.Right(foundIdx); // foundIdx = 0; // while (1) // { // if (isspace(remainder[foundIdx]) || remainder[foundIdx] == _T('+')) // foundIdx++; // else // break; // } // CString offsetString = remainder.GetBuffer() + foundIdx; // // //offset = strtoul(Spot.Text,NULL,16); // //} CStringArray chunks; if (SplitString(str, "+", chunks) == 0) chunks.Add(str); size_t Final = 0; for (UINT i = 0; i < (UINT)chunks.GetCount(); i++) { CString a = chunks[i]; a.MakeLower(); // Make all lowercase a.Trim(); // Trim whitespace a.Remove(_T('\"')); // Remove quotes bool bPointer = false; bool bMod = false; if (a.Find(_T(".exe")) != -1 || a.Find(_T(".dll")) != -1) bMod = true; if (a[0] == _T('*')) { bPointer = true; a = a.Mid(1); } else if (a[0] == _T('&')) { bMod = true; a = a.Mid(1); } size_t curadd = 0; if (bMod) { for (UINT i = 0; i < MemMapModule.size(); i++) { CString ModName = MemMapModule[i].Name; ModName.MakeLower(); if (StrStr(ModName, a) != NULL) { curadd = MemMapModule[i].Start; bMod = true; break; } } } else { curadd = (size_t)_tcstoui64(a.GetBuffer(), NULL, 16); } Final += curadd; if (bPointer) { if ( ReadMemory( (void*)Final, &Final, sizeof(Final), NULL) == 0) { PrintOut(_T("[ConvertStrToAddress]: Failed to read memory GetLastError() = %s"), Utils::GetLastErrorString().GetString()); } } } return Final; }
BOOL InternalListHandler(HXML node, LPCTSTR jid, LPCTSTR mailboxUrl) { ULONGLONG maxTid = 0; LPCTSTR sMaxTid = NULL; int unreadCount = 0; for (int i = 0; i < xi.getChildCount(node); i++) { LPCTSTR sTid = xi.getAttrValue(xi.getChild(node, i), ATTRNAME_TID); ULONGLONG tid = _tcstoui64(sTid, NULL, 10); if (tid > maxTid) { maxTid = tid; sMaxTid = sTid; } HXML senders = xi.getChildByPath(xi.getChild(node, i), NODENAME_SENDERS, FALSE); for (int j = 0; j < xi.getChildCount(senders); j++) if (xi.getAttrValue(xi.getChild(senders, j), ATTRNAME_UNREAD)) { unreadCount++; break; } } LPCSTR acc = GetJidAcc(jid); if (!acc) return FALSE; if (!unreadCount) { SetupPseudocontact(jid, xi.getAttrValue(node, ATTRNAME_TOTAL_MATCHED), acc); return TRUE; } DWORD settings = ReadNotificationSettings(acc); if (unreadCount > 5) { CloseNotifications(acc, mailboxUrl, jid, FALSE); UnreadMailNotification(acc, jid, mailboxUrl, xi.getAttrValue(node, ATTRNAME_TOTAL_MATCHED)); } else for (int i = 0; i < xi.getChildCount(node); i++) { MAIL_THREAD_NOTIFICATION mtn = { 0 }; HXML thread = xi.getChild(node, i); mtn.subj = xi.getText(xi.getChildByPath(thread, NODENAME_SUBJECT, FALSE)); mtn.snip = xi.getText(xi.getChildByPath(thread, NODENAME_SNIPPET, FALSE)); int threadUnreadCount = 0; HXML senders = xi.getChildByPath(thread, NODENAME_SENDERS, FALSE); for (int j = 0; threadUnreadCount < SENDER_COUNT && j < xi.getChildCount(senders); j++) { HXML sender = xi.getChild(senders, j); if (xi.getAttrValue(sender, ATTRNAME_UNREAD)) { mtn.senders[threadUnreadCount].name = xi.getAttrValue(sender, ATTRNAME_NAME); mtn.senders[threadUnreadCount].addr = xi.getAttrValue(sender, ATTRNAME_ADDRESS); threadUnreadCount++; } } LPCTSTR url = xi.getAttrValue(thread, ATTRNAME_URL); LPCTSTR tid = xi.getAttrValue(thread, ATTRNAME_TID); if (ReadCheckbox(0, IDC_STANDARDVIEW, settings)) FormatMessageUrl(MESSAGE_URL_FORMAT_STANDARD, (LPTSTR)url, mailboxUrl, tid); else if (ReadCheckbox(0, IDC_HTMLVIEW, settings)) FormatMessageUrl(MESSAGE_URL_FORMAT_HTML, (LPTSTR)url, mailboxUrl, tid); else MakeUrlHex((LPTSTR)url, tid); CloseNotifications(acc, url, jid, i); UnreadThreadNotification(acc, jid, url, xi.getAttrValue(node, ATTRNAME_TOTAL_MATCHED), &mtn); } LPCTSTR time = xi.getAttrValue(node, ATTRNAME_RESULT_TIME); WriteJidSetting(LAST_MAIL_TIME_FROM_JID, jid, time); WriteJidSetting(LAST_THREAD_ID_FROM_JID, jid, sMaxTid); return TRUE; }