コード例 #1
0
wxString LLDBVariable::ToString(const wxString& alternateName) const
{
    wxString asString;
    if(alternateName.IsEmpty()) {
        asString << GetName();
    } else {
        asString << alternateName;
    }

    wxString v;
    if(!GetSummary().IsEmpty()) {
        v << GetSummary();
    }

    if(!GetValue().IsEmpty()) {
        if(!v.IsEmpty()) {
            v << " ";
        }
        v << GetValue();
    }

    v.Trim().Trim(false);
    if(v == "unable to read data") {
        v.Clear();
    }

    if(!v.IsEmpty()) {
        asString << " = " << v;
    }

    if(!m_type.IsEmpty()) {
        asString << " [" << GetType() << "]";
    }
    return asString;
}
コード例 #2
0
ファイル: properties.cpp プロジェクト: EtlamGit/minutor
void Properties::ParseList(QTreeWidgetItem* node, const IterableT& seq) {
  typename IterableT::const_iterator it, itEnd = seq.end();
  int i = 0;
  // skip 1 sized arrays
  if (seq.size() == 0) {
    // empty
    if (node)
      node->setData(1, Qt::DisplayRole, "<empty>");
  } else if (seq.size() == 1) {
    CreateTree(node, seq.first());
    if (node)
      node->setData(1, Qt::DisplayRole, GetSummary("[0]", seq.first()));
  } else {
    for (it = seq.begin(); it != itEnd; ++it) {
      QTreeWidgetItem* child = new QTreeWidgetItem();
      QString key = QString("[%1]").arg(i++);
      child->setData(0, Qt::DisplayRole, key);
      child->setData(1, Qt::DisplayRole, GetSummary(key, *it));
      CreateTree(child, *it);

      if (node)
        node->addChild(child);
      else
        ui->propertyView->addTopLevelItem(child);
    }
  }
}
コード例 #3
0
ファイル: properties.cpp プロジェクト: EtlamGit/minutor
QString Properties::GetSummary(const QString& key, const QVariant& v) {
  QString ret;
  QMap<QString, QString>::const_iterator it = summary.find(key);
  if (it != summary.end()) {
    ret = *it;
    QRegularExpression re("(\\{.*?\\})");
    QRegularExpressionMatchIterator matches = re.globalMatch(*it);
    while (matches.hasNext()) {
      QRegularExpressionMatch m = matches.next();
      QString pattern = m.captured(0);
      QString evaluated =
          EvaluateSubExpression(pattern.mid(1, pattern.size() - 2), v);
      // if a lookup fails, then don't return anything
      if (evaluated.size() == 0) {
        ret = "";
        break;
      }
      ret.replace(pattern, evaluated);
    }
  } else if ((QMetaType::Type)v.type() == QMetaType::QVariantList) {
    ret = QString("(%1 items)").arg(v.toList().size());
  } else if ((QMetaType::Type)v.type() == QMetaType::QVariantMap) {
    ret = GetSummary("", v);
  }
  return ret;
}
コード例 #4
0
ファイル: console.cpp プロジェクト: alexlee188/UBW-emulator
int main(int argc, char* argv[])
{
    BOOLEAN bQuit;
    DWORD selection;
    bQuit = false;

    // Load DLL when it is necessary, i.e. on start-up!
    LoadDLL();

    // Always a good idea to initialize the handles
    myOutPipe = myInPipe = INVALID_HANDLE_VALUE;

    printf("Microchip Technology Inc., 2004\r\n");
    printf("===============================\r\n");
    while(!bQuit)
    {
        printf("Select an option\r\n");
        printf("[1] Get MPUSBAPI Version\r\n");
        printf("[2] Summarize Instances\r\n");
        printf("[3] Set Configuration\r\n");
        printf("[4] Get Descriptor Information\r\n");
        printf("[5] Quit\r\n>>");
        scanf("%d",&selection);

        switch(selection)
        {
            case 1:
                temp = MPUSBGetDLLVersion();
                printf("MPUSBAPI Version: %d.%d\r\n",HIWORD(temp),LOWORD(temp));
                break;
            case 2:
                GetSummary();
                break;
            case 3:
                SetConfigurationExample();
                break;
            case 4:
                GetDescritorExample();
                break;
            case 5:
                bQuit = true;
                break;
            default:
                break;
        }// end switch

        fflush(stdin);printf("\r\n");
    }//end while

    // Always check to close all handles before exiting!
    if (myOutPipe != INVALID_HANDLE_VALUE) MPUSBClose(myOutPipe);
    if (myInPipe != INVALID_HANDLE_VALUE) MPUSBClose(myInPipe);
    myOutPipe = myInPipe = INVALID_HANDLE_VALUE;

    // Always check to close the library too.
    if (libHandle != NULL) FreeLibrary(libHandle);

    return 0;
}//end main
コード例 #5
0
ファイル: properties.cpp プロジェクト: EtlamGit/minutor
void Properties::ParseIterable(QTreeWidgetItem* node, const IterableT& seq) {
  typename IterableT::const_iterator it, itEnd = seq.end();
  for (it = seq.begin(); it != itEnd; ++it) {
    QTreeWidgetItem* child = new QTreeWidgetItem();
    child->setData(0, Qt::DisplayRole, it.key());
    child->setData(1, Qt::DisplayRole, GetSummary(it.key(), it.value()));
    CreateTree(child, it.value());
    if (node)
      node->addChild(child);
    else
      ui->propertyView->addTopLevelItem(child);
  }
}
コード例 #6
0
ファイル: DoReport.cpp プロジェクト: 510908220/dumper
void DoReport(LPCTSTR lpstrCmdLine, BOOL *pIsHandled)
{
	WSADATA wsaData = {0};
	WSAStartup(MAKEWORD(2, 2), &wsaData);

	//LogFinal(LOG::KBugReport) << L"Bugreport启动命令行: " << lpstrCmdLine;

	REPORT_CONTEXT report;
	std::wstring strProductName;

	const TCHAR * p = _tcsstr(lpstrCmdLine, _T("pid="));
	if (p)
	{
		*pIsHandled = TRUE;

		DWORD client_process_id = _tcstoul(p + _tcslen(_T("pid=")), 0, 0);

		p = _tcsstr(lpstrCmdLine, _T("context="));
		if (p)
		{
			void *addr = (void*)_tcstoul(p + _tcslen(_T("context=")), 0, 0);
			//YYBrowser Begin
			//by ZC. 2013-10-30 11:26.
			// hClientProcess客户进程,即是启动YGCrashReport的进程,不一定是崩溃的目标进程。
			HANDLE client_process_handle = ::OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, FALSE, client_process_id);
			// 崩溃目标进程。			
			HANDLE target_process_handle = NULL;
			//YYBrowser End
			if (!client_process_handle)
				LogFinal(LOG::KBugReport) << L"打开进程句柄失败";

			//解释REPORT_PARAMS
			CRASH_LAUNCH_PARAMS crash_launch_params = {0};
			DWORD cbRead = 0;
			if (addr && ::ReadProcessMemory(client_process_handle, addr, &crash_launch_params, sizeof(crash_launch_params), &cbRead))
			{
				LogFinal(LOG::KBugReport) << L"读取REPORT_PARAMS成功";
				
				std::set<std::wstring> setSuspectModule;
				std::set<std::wstring> setModule;
				std::wstring strPathNoExt = GenerateNewFilePath(crash_launch_params.dwPID);					

				report.strZipFilePath = strPathNoExt + _T(".zip");
				report.strOSVer = GetOSVer();

				AtoW(crash_launch_params.szProductName, -1, strProductName);
				
				report.dwReportId = crash_launch_params.dwReportId;
				report.strUserId = crash_launch_params.szUserId;
				report.strProductId = crash_launch_params.szProductId;
				report.strProductVer = crash_launch_params.szProductVer;
				report.strProductVerDetail = crash_launch_params.szProductVerDetail;
				//AtoW(crash_launch_params.szRestartExePath, -1, report.wstrRestartExePath);

				report.strDynaReleaseVer = crash_launch_params.szDynaReleaseVer;
			
				WriteBugInfo(report.dwReportId);
				report.dwCount24Hour = GetBugCount(report.dwReportId);

				//parse 自定义文件路径
				if (crash_launch_params.nFileCount > 0)
				{
					char *pPaths = new char[MAX_PATH * crash_launch_params.nFileCount];
					if (::ReadProcessMemory(client_process_handle, crash_launch_params.lpszCustomFilePaths, pPaths, MAX_PATH * crash_launch_params.nFileCount, &cbRead))
					{
						for (UINT k = 0; k < cbRead / MAX_PATH; k++)
						{
							std::wstring wstrPath;
							AtoW(pPaths + k * MAX_PATH, -1, wstrPath);
							report.vecOtherFilePath.push_back(wstrPath);
						}
					}
					delete [] pPaths;
					pPaths = NULL;
				}	
				
				//生成log
				std::string strLog;
				char szTemp[1024] = {0};


				//Date
				time_t curTime = 0;
				time(&curTime);
				strftime(szTemp, _countof(szTemp)-1, "%Y-%m-%d %H.%M.%S\r\n", localtime(&curTime));
				strLog += szTemp;
				strLog += "\r\n";

				//异常信息
				strLog += "Exception:\r\n";
				const char *pModName = strrchr(crash_launch_params.szExcepModPath, '\\');
				if (pModName)
					pModName++;
				else
					pModName = crash_launch_params.szExcepModPath;
			
				report.strExcepModuleName = pModName;
				_snprintf_s(szTemp, _countof(szTemp), _TRUNCATE, "Module=%s\r\n", pModName);
				strLog += szTemp;

				//YYBrowser Begin
				//打开目标进程。by ZC. 2013-10-30 11:30.
				target_process_handle = ::OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, FALSE, crash_launch_params.dwPID);
				//YYBrowser End
				//YYBrowser Begin
				//从目标进程中读出结构异常。by ZC. 2013-10-30 11:28.
				if (crash_launch_params.pExceptionInfo) {
					EXCEPTION_RECORD excep = {0};
					CONTEXT ct = {0};
					EXCEPTION_POINTERS ptr = {0};
					if (::ReadProcessMemory(target_process_handle, crash_launch_params.pExceptionInfo, &ptr, sizeof(ptr), &cbRead)
						&& ::ReadProcessMemory(target_process_handle, ptr.ExceptionRecord, &excep, sizeof(excep), &cbRead)
						&& ::ReadProcessMemory(target_process_handle, ptr.ContextRecord, &ct, sizeof(ct), &cbRead))
					{
						report.dwExcepAddr = (DWORD)excep.ExceptionAddress;
						report.dwExcepCode = excep.ExceptionCode;
						report.strExcepDiscription = GetExceptionDescription(excep.ExceptionCode);

						_snprintf_s(szTemp, _countof(szTemp), _TRUNCATE, "ExceptionCode=0x%08x, %s\r\n", excep.ExceptionCode, GetExceptionDescription(excep.ExceptionCode));
						strLog += szTemp;

						_snprintf_s(szTemp, _countof(szTemp), _TRUNCATE, "eip=0x%08x, ebp=0x%08x, esp=0x%08x, eax=0x%08x, ebx=0x%08x, ecx=0x%08x, edx=0x%08x, esi=0x%08x, edi=0x%08x\r\n", ct.Eip, ct.Ebp, ct.Esp, ct.Eax, ct.Ebx, ct.Ecx, ct.Edx, ct.Esi, ct.Edi);
						strLog += szTemp;
					}
					strLog += "\r\n";
				}
				//YYBrowser End

				strLog += "Summary:\r\n";
				strLog += GetSummary(client_process_handle);
				strLog += "UserId(YY)=" + report.strUserId + "\r\n";
				strLog += "ProductVer=" + report.strProductVer + "\r\n";
				strLog += "DynaReleaseVer=" + report.strDynaReleaseVer + "\r\n";				
				strLog += "ProductVerDetail=" + report.strProductVerDetail + "\r\n";
				_snprintf_s(szTemp, _countof(szTemp), _TRUNCATE, "ReportId=%u\r\n", report.dwReportId);
				strLog += szTemp;

				strLog += "\r\n";
				
				std::string strLoginHistoryLog;
				std::string strLoginHistory = ReadLoginHistory(strLoginHistoryLog);

				//用户自定义信息
				strLog += "CustomProperty:\r\n";
				char *pCustomProperty = new char[crash_launch_params.cchCustomProperty + 1];
				if (::ReadProcessMemory(client_process_handle, crash_launch_params.lpszCustomProperty, pCustomProperty, crash_launch_params.cchCustomProperty, &cbRead))
				{
					pCustomProperty[cbRead/sizeof(char)] = 0;

					report.strCustomProperty = pCustomProperty;
					
				}

				strLog += report.strCustomProperty;

				if(strLoginHistory.size()>0)
				{
					if(report.strCustomProperty.size()>0)
					{
						report.strCustomProperty+="&";
					}

					report.strCustomProperty+=strLoginHistory;
				}
			
				if(strLoginHistoryLog.size()>0)
				{
					strLog += "\r\n";
					strLog += strLoginHistoryLog;
				}
				strLog += "\r\n";

				//CallStack
				strLog += "Call Stack:\r\n";
				char *pCallStack = new char[crash_launch_params.cchCallStack + 1];
				cbRead = 0;
				if (::ReadProcessMemory(client_process_handle, crash_launch_params.lpszCallStack, pCallStack, crash_launch_params.cchCallStack, &cbRead))
				{
					pCallStack[cbRead/sizeof(char)] = 0;
					strLog += pCallStack;
				}
				strLog += "\r\n";

				//收集进程列表&检测运行环境
				std::string  strProcListA;
				std::wstring strProcListW;
				report.dwRunEnvironment = CheckRunEnvironment(strProcListW);
				WtoA(strProcListW.c_str(), -1, strProcListA);
				strLog += "Process List:\r\n";
				strLog += strProcListA;
				strLog += "\r\n";

				//收集版本的语言种类,不写入日志
				report.strProductLang = GetLanguageName();

				//模块列表
				strLog += "Module List:\r\n";
				strLog += GetModuleList(target_process_handle,&setModule,&setSuspectModule);
				strLog += "\r\n";
				
				//程序Log
				strLog += "Log:\r\n";
				TCHAR szExePath[MAX_PATH] = {0};
				GetModuleFileNameEx(target_process_handle, NULL, szExePath, _countof(szExePath));
				TCHAR *p = _tcsrchr(szExePath, _T('.'));
				if (p)
					*p = 0;
				TCHAR* pExeName = _tcsrchr(szExePath, _T('\\'));
				if (pExeName)
					pExeName++;
				else
					pExeName = szExePath;
				
				const DWORD dwMaxLogSize = 1024 * 200;
			//	char *pContent = new char [dwMaxLogSize];
			//	GetLastLog(pExeName, reportParams.dwPID, 0, pContent, dwMaxLogSize);
			//	strLog += pContent;
			//	delete [] pContent;
			//	pContent = NULL;
				strLog += "\r\n\r\n";
				/************************************************************************/
				/*功能:在日志文件中添加安装目录下所有dll和rcc文件的md5*/	
                /***************************只有yy.exe崩溃时,才会计算相关文件的md5*/
                if (StrCmpIA(crash_launch_params.szProductId, "YY") == 0)
                {
                    strLog += "[List *.dll and *.rcc files MD5:] \r\n\r\n";		
                    TCHAR szCurrentProcesspath[MAX_PATH] = {0};                
                    if ( GetModuleFileName(NULL,szCurrentProcesspath,_countof(szCurrentProcesspath)) > 0)
                    {
                        TCHAR* p_findDir = _tcsrchr(szCurrentProcesspath,_T('\\'));    
                        std::wstring rawCurrentProcessPath = szCurrentProcesspath;
                        std::wstring strCurrentProcesspath  =  rawCurrentProcessPath.substr(0, p_findDir - szCurrentProcesspath);

                        strLog += dwCalculateMD5(strCurrentProcesspath.c_str());                  
                    }
                    else
                    {
                        strLog += "Get the files'MD5 failed!";
                    }
                }
                else
                {
                    strLog += "Hint:\r\nThe crash was caused by the other products except the YY!";
                }				
                /************************************************************************/
				TCHAR szLogPath[_MAX_PATH] = {0};
				_sntprintf_s(szLogPath, _countof(szLogPath), _TRUNCATE, _T("%s.txt"), strPathNoExt.c_str());
				report.strLogPath = szLogPath;

				LogFinal(LOG::KBugReport) << L"写入log文件: " << szLogPath;
				
				HANDLE hFile = ::CreateFile(szLogPath, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, NULL, NULL);
				DWORD dwWriten = 0;
				::WriteFile(hFile, strLog.c_str(), strLog.size(), &dwWriten, NULL);
				::CloseHandle(hFile);
	
				//生成dump
				TCHAR szDumpPath[_MAX_PATH] = {0};
				_sntprintf_s(szDumpPath, _countof(szDumpPath), _TRUNCATE, _T("%s.dmp"), strPathNoExt.c_str());

				LogFinal(LOG::KBugReport) << L"生成dump文件: " << szDumpPath;
				int nDumpType = (MiniDumpNormal|MiniDumpWithHandleData|MiniDumpWithIndirectlyReferencedMemory|MiniDumpWithUnloadedModules|MiniDumpWithProcessThreadData);
				if (!CreateDump(szDumpPath, crash_launch_params.dwPID, crash_launch_params.dwTID, crash_launch_params.pExceptionInfo, nDumpType, MyMiniDumpCallBack, &crash_launch_params))
				{
					crash_launch_params.curCustomDataIdx = 0;
					CreateDump(szDumpPath, crash_launch_params.dwPID, crash_launch_params.dwTID, crash_launch_params.pExceptionInfo, MiniDumpNormal, MyMiniDumpCallBack, &crash_launch_params);
				}
				report.strDumpPath = szDumpPath;

				//生成fulldump
				CRegKey key;
				LONG lResult = key.Open(HKEY_CURRENT_USER, _T("Software\\duowan\\bugreport"), KEY_READ);
				if (ERROR_SUCCESS == lResult)
				{
					TCHAR	szFullDump[1024] = {0};
					DWORD dwSize = _countof(szFullDump);
					lResult = key.QueryValue(szFullDump, _T("fulldump"), &dwSize);
					if (ERROR_SUCCESS == lResult)
					{
						szFullDump[dwSize] = 0;
						if (_tcsicmp(szFullDump, _T("yes")) == 0)
						{
							nDumpType = (MiniDumpNormal 
								| MiniDumpWithFullMemory 
								| MiniDumpWithIndirectlyReferencedMemory 
								| MiniDumpWithHandleData
								| MiniDumpWithUnloadedModules
								| MiniDumpWithProcessThreadData);

							TCHAR szFullDumpPath[_MAX_PATH] = {0};
							::GetTempPath(_countof(szFullDumpPath), szFullDumpPath);
							_tcsncat_s(szFullDumpPath, _countof(szFullDumpPath), _T("duowan\\fulldump.dmp"), _TRUNCATE);

							LogFinal(LOG::KBugReport) << L"生成fulldump文件: " << szFullDumpPath;

							CreateDump(szFullDumpPath, crash_launch_params.dwPID, crash_launch_params.dwTID, crash_launch_params.pExceptionInfo, nDumpType, MyMiniDumpCallBack, &crash_launch_params);
						}
					}
				}

				::SetEvent(crash_launch_params.evDumpComplete);

				if (crash_launch_params.bShowReportUI)
				{
					LogFinal(LOG::KBugReport) << L"开始弹出崩溃界面";
					
					std::string strRecv;
					bool bShowModifyStatus = false;

					//if(GetBugModifyStatus(&report,strRecv))
					//{
					//	const char* p = strstr(strRecv.c_str(),"return=true");
					//	if(p)
					//	{
					//		bShowModifyStatus = true;
					//	}
					//}

					CMessageLoop theLoop;
					_Module.AddMessageLoop(&theLoop);

					CDlgReport dlgMain(strProductName.c_str(), &report, crash_launch_params.dwPID, &setModule, &setSuspectModule, bShowModifyStatus, strRecv.c_str());
					dlgMain.Create(NULL);

					dlgMain.ShowWindow(SW_SHOW);

					theLoop.Run();

					_Module.RemoveMessageLoop();
				}
				else
				{
					SendReport(&report, &setModule, &setSuspectModule);
				}
			}
			else
			{
				LogFinal(LOG::KBugReport) << L"读取崩溃进程REPORT_PARAMS失败";
			}

			::CloseHandle(target_process_handle);
			::CloseHandle(client_process_handle);
		}
	}
}