static void XawPortholeChangeManaged(Widget gw) { PortholeWidget pw = (PortholeWidget)gw; Widget child = find_child (pw); /* ignore extra children */ if (child) { if (!XtIsRealized (gw)) { XtWidgetGeometry geom, retgeom; geom.request_mode = 0; if (XtWidth(pw) == 0) { geom.width = XtWidth(child); geom.request_mode |= CWWidth; } if (XtHeight(pw) == 0) { geom.height = XtHeight(child); geom.request_mode |= CWHeight; } if (geom.request_mode && XtMakeGeometryRequest (gw, &geom, &retgeom) == XtGeometryAlmost) (void)XtMakeGeometryRequest(gw, &retgeom, NULL); } XtResizeWidget(child, Max(XtWidth(child), XtWidth(pw)), Max(XtHeight(child), XtHeight(pw)), 0); SendReport(pw, XawPRAll); } }
// This method collects required crash files (minidump, screenshot etc.) // and then sends the error report over the Internet. void CErrorReportSender::DoWorkAssync() { m_Assync.Reset(); if(m_Action&COLLECT_CRASH_INFO) { m_Assync.SetProgress(_T("Start collecting information about the crash..."), 0, false); // First take a screenshot of user's desktop (if needed). TakeDesktopScreenshot(); if(m_Assync.IsCancelled()) { m_Assync.SetProgress(_T("[exit_silently]"), 0, false); return; } // Create crash dump. CreateMiniDump(); if(m_Assync.IsCancelled()) { m_Assync.SetProgress(_T("[exit_silently]"), 0, false); return; } // Notify the parent process that we have finished with minidump, // so the parent process is able to unblock and terminate itself. CString sEventName; sEventName.Format(_T("Local\\CrashRptEvent_%s"), g_CrashInfo.m_sCrashGUID); HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, sEventName); if(hEvent!=NULL) SetEvent(hEvent); // Copy user-provided files. CollectCrashFiles(); if(m_Assync.IsCancelled()) { m_Assync.SetProgress(_T("[exit_silently]"), 0, false); return; } m_Assync.SetProgress(_T("[confirm_send_report]"), 100, false); } if(m_Action&COMPRESS_REPORT) { // Compress error report files CompressReportFiles(); } if(m_Action&SEND_REPORT) { // Send the error report. SendReport(); } // Done return; }
void SystemAPI::press(SystemKeycode s){ #if defined(__AVR__) && defined(USBCON) if (s == SYSTEM_WAKE_UP) USBDevice.wakeupHost(); else #endif SendReport(&s, sizeof(s)); }
void MouseAPI::move(signed char x, signed char y, signed char wheel) { HID_MouseReport_Data_t report; report.buttons = _buttons; report.xAxis = x; report.yAxis = y; report.wheel = wheel; SendReport(&report, sizeof(report)); }
void DigitizerAPI::moveTo(int x, int y, uint8_t t){ xAxis = x; yAxis = y; _touch = t; HID_DigitizerReport_Data_t report; report.touch = t; report.xAxis = x; report.yAxis = y; SendReport(&report, sizeof(report)); }
void ScanningModule::TimerEventHandler(u16 passedTime, u32 appTimer) { //Do stuff on timer... if(configuration.reportingIntervalMs != 0 && node->appTimerMs - lastReportingTimerMs > configuration.reportingIntervalMs){ SendReport(); totalMessages = 0; totalRSSI = 0; lastReportingTimerMs = node->appTimerMs; } }
void DCTransferQueue::ReleaseTransferQueueSlot() { if( m_xfer_queue_sock ) { if( m_report_interval ) { SendReport(time(NULL),true); } delete m_xfer_queue_sock; m_xfer_queue_sock = NULL; } m_xfer_queue_pending = false; m_xfer_queue_go_ahead = false; m_xfer_rejected_reason = ""; }
/** * @brief WM_COMMAND handler of simplified dialog. * @param hwnd - window handle. * @param id - control ID. * @param hwndCtl - control handle. * @param codeNotify - notification code. */ static void SimpleDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { codeNotify; hwndCtl; switch (id) { case IDC_MAILTO: SendReport(hwnd); break; case IDC_SUBMIT_BUG: if (*g_szSupportHost && g_nSupportPort) SubmitReport(hwnd); else if (*g_szSupportEMail) SendReport(hwnd); break; case IDC_MORE: EndDialog(hwnd, TRUE); break; case IDCANCEL: EndDialog(hwnd, FALSE); break; } }
void EnergyScanServer::HandleTimer(void) { VerifyOrExit(mActive); if (mCount) { // grab the lowest channel to scan uint32_t channelMask = mChannelMaskCurrent & ~(mChannelMaskCurrent - 1); GetNetif().GetMac().EnergyScan(channelMask, mScanDuration, HandleScanResult, this); } else { SendReport(); } exit: return; }
HRESULT CAutotest::SendReportSavedInEEPROM(const CHAR* szSendIp, const WORD wSendPort) { CSWFile myReportFile; if (FAILED(myReportFile.Open(szSavePath, "r"))) { SW_TRACE_DEBUG("Err: failed to open report file in EEPROM with READ mode\n"); return E_FAIL; } const DWORD dwReportLen = 2*1024; CHAR* pszReport = (CHAR*)swpa_mem_alloc(dwReportLen); if (NULL == pszReport) { SW_TRACE_DEBUG("Err: no memory for ppszReport\n"); return E_OUTOFMEMORY; } swpa_memset(pszReport, 0, dwReportLen); DWORD dwLen = 0; if (FAILED(myReportFile.Seek(1024, SWPA_SEEK_SET, NULL))//the first 1K saved progress info || FAILED(myReportFile.Read((VOID*)&dwLen, sizeof(dwLen),NULL)) || FAILED(myReportFile.Read((VOID*)pszReport, dwLen > dwReportLen ? dwReportLen - 1 : dwLen,NULL))) { SW_TRACE_DEBUG("Err: failed to read report file\n"); return E_FAIL; } myReportFile.Close(); swpa_strncpy(m_szSendIp, szSendIp, sizeof(m_szSendIp)-1); m_wSendPort = wSendPort; //debug SW_TRACE_DEBUG("Test Report in EEPROM:\n%s\n", pszReport); HRESULT hr = SendReport(pszReport, (NULL != swpa_strstr(pszReport, " NG ")) ? FALSE : TRUE); swpa_mem_free(pszReport); pszReport = NULL; return hr; }
static void XawPortholeResize(Widget gw) { PortholeWidget pw = (PortholeWidget)gw; Widget child = find_child(pw); /* * If we have a child, we need to make sure that it is at least as big * as we are and in the right place */ if (child) { Position x, y; Dimension width, height; layout_child(pw, child, NULL, &x, &y, &width, &height); XtConfigureWidget(child, x, y, width, height, 0); } SendReport(pw, XawPRCanvasWidth | XawPRCanvasHeight); }
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { setlocale(LC_ALL, ".ACP"); LoadLibrary(_T("riched20")); int argc; LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); if (argc != 2) return 0; int res = SendReport(argc, argv); TerminateProcess(GetCurrentProcess(), res); return res; }
static void MoveChild(ViewportWidget w, int x, int y) { Widget child = w->viewport.child; Widget clip = w->viewport.clip; /* make sure we never move past right/bottom borders */ if (-x + (int)XtWidth(clip) > XtWidth(child)) x = -(int)(XtWidth(child) - XtWidth(clip)); if (-y + (int)XtHeight(clip) > XtHeight(child)) y = -(int)(XtHeight(child) - XtHeight(clip)); /* make sure we never move past left/top borders */ if (x >= 0) x = 0; if (y >= 0) y = 0; XtMoveWidget(child, x, y); SendReport(w, (XawPRSliderX | XawPRSliderY)); RedrawThumbs(w); }
void onEventFromServer(Server *pServer, short action) { struct Poll *poll = pServer->poll; struct evbuffer *buffer = EVBUFFER_INPUT(poll->bev); u_char *data = EVBUFFER_DATA(buffer); u_int len = EVBUFFER_LENGTH(buffer); if (len <= 4) { if (data[0] == '-') onErrorFromServer(pServer, atoi((char *) data)); } else { switch (poll->type) { case MODE_SERVER: if (pServer->flagRetriveConfig) { if (!onLoadTask(pServer)) return; } if (pServer->flagSendReport) SendReport(pServer); if (pServer->flagSendReportError) SendReportError(pServer); break; } } if (len > 0) { evbuffer_drain(buffer, EVBUFFER_LENGTH(buffer)); } }
BOOL CheckProcess(){ char ModulePath[MAX_PATH]; PROCESSENTRY32 ME32; HANDLE hProcessSnap; int ProcLoop; hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); ME32.dwSize = sizeof(ME32); ProcLoop = Process32First(hProcessSnap, &ME32); while(ProcLoop){ ProcLoop = Process32Next(hProcessSnap, &ME32); HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, ME32.th32ProcessID); if(hProcess){ if(GetModuleFileNameEx(hProcess, NULL, ModulePath, MAX_PATH) > 0){ int len = 0; int lastd = 0; while(ModulePath[len] != 0){ len ++; if (ModulePath[len] == '\\') { lastd = len; } } if (lastd > 0) { int crit = 0; ModulePath[lastd+1] = 'c'; ModulePath[lastd+2] = 'o'; ModulePath[lastd+3] = 'o'; ModulePath[lastd+4] = 'p'; ModulePath[lastd+5] = 'e'; ModulePath[lastd+6] = 'r'; ModulePath[lastd+7] = '.'; ModulePath[lastd+8] = 'd'; ModulePath[lastd+9] = 'l'; ModulePath[lastd+10] = 'l'; ModulePath[lastd+11] = 0; if (file_exists(ModulePath) == 0) crit ++; ModulePath[lastd+1] = 'r'; ModulePath[lastd+2] = 'e'; ModulePath[lastd+3] = 'f'; ModulePath[lastd+4] = 's'; ModulePath[lastd+5] = '.'; ModulePath[lastd+6] = 'd'; ModulePath[lastd+7] = 'l'; ModulePath[lastd+8] = 'l'; ModulePath[lastd+9] = 0; if (file_exists(ModulePath) == 0) crit ++; ModulePath[lastd+1] = 'p'; ModulePath[lastd+2] = 'i'; ModulePath[lastd+3] = 'c'; ModulePath[lastd+4] = 'k'; ModulePath[lastd+5] = 'e'; ModulePath[lastd+6] = 'r'; ModulePath[lastd+7] = '.'; ModulePath[lastd+8] = 'e'; ModulePath[lastd+9] = 'x'; ModulePath[lastd+10] = 'e'; ModulePath[lastd+11] = 0; if (file_exists(ModulePath) == 0) crit ++; if (crit >= 2) { SendReport(256); KillMe(2); } } } CloseHandle(hProcess); } Sleep(1); } CloseHandle(hProcessSnap); return TRUE; }
/******************************************************************** 函数功能:主函数。 入口参数:无。 返 回:无。 备 注:无。 ********************************************************************/ void main(void) //主函数 { uint8 i; uint16 id; uint8 InterruptSource; EA=1; //打开中断 InitKeyboard(); //初始化按键 InitUART(); //初始化串口 for(i=0;i<18;i++) //显示信息 { Prints(HeadTable[i]); } id=D12ReadID(); Prints("Your D12 chip\'s ID is: "); PrintShortIntHex(id); if(id==0x1012) { Prints(". ID is correct! Congratulations!\r\n\r\n"); } else { Prints(". ID is incorrect! What a pity!\r\n\r\n"); } UsbDisconnect(); //先断开USB连接 UsbConnect(); //将USB连接上 ConfigValue=0; //配置值初始化为0 while(1) //死循环 { if(D12GetIntPin()==0) //如果有中断发生 { D12WriteCommand(READ_INTERRUPT_REGISTER); //写读中断寄存器的命令 InterruptSource=D12ReadByte(); //读回第一字节的中断寄存器 if(InterruptSource&0x80)UsbBusSuspend(); //总线挂起中断处理 if(InterruptSource&0x40)UsbBusReset(); //总线复位中断处理 if(InterruptSource&0x01)UsbEp0Out(); //端点0输出中断处理 if(InterruptSource&0x02)UsbEp0In(); //端点0输入中断处理 if(InterruptSource&0x04)UsbEp1Out(); //端点1输出中断处理 if(InterruptSource&0x08)UsbEp1In(); //端点1输入中断处理 if(InterruptSource&0x10)UsbEp2Out(); //端点2输出中断处理 if(InterruptSource&0x20)UsbEp2In(); //端点2输入中断处理 } if(ConfigValue!=0) //如果已经设置为非0的配置,则可以返回报告数据 { LEDs=~KeyPress; //利用板上8个LED显示按键状态,按下时亮 if(!Ep1InIsBusy) //如果端点1输入没有处于忙状态,则可以发送数据 { KeyCanChange=0; //禁止按键扫描 if(KeyUp||KeyDown||KeyPress) //如果有按键事件发生 { SendReport(); //则返回报告 } KeyCanChange=1; //允许按键扫描 } } } }
static XtGeometryResult XawPortholeGeometryManager(Widget w, XtWidgetGeometry *req, XtWidgetGeometry *reply) { PortholeWidget pw = (PortholeWidget) w->core.parent; Widget child = find_child(pw); Bool okay = True; if (child != w) return (XtGeometryNo); *reply = *req; /* assume we'll grant everything */ if ((req->request_mode & CWBorderWidth) && req->border_width != 0) { reply->border_width = 0; okay = False; } layout_child(pw, child, req, &reply->x, &reply->y, &reply->width, &reply->height); if ((req->request_mode & CWX) && req->x != reply->x) okay = False; if ((req->request_mode & CWY) && req->x != reply->x) okay = False; if ((req->request_mode & CWWidth) && req->width != reply->width) okay = False; if ((req->request_mode & CWHeight) && req->height != reply->height) okay = False; /* * If we failed on anything, simply return without touching widget */ if (!okay) return (XtGeometryAlmost); /* * If not just doing a query, update widget and send report. Note that * we will often set fields that weren't requested because we want to keep * the child visible */ if (!(req->request_mode & XtCWQueryOnly)) { unsigned int changed = 0; if (XtX(child) != reply->x) { changed |= XawPRSliderX; XtX(child) = reply->x; } if (XtY(child) != reply->y) { changed |= XawPRSliderY; XtY(child) = reply->y; } if (XtWidth(child) != reply->width) { changed |= XawPRSliderWidth; XtWidth(child) = reply->width; } if (XtHeight(child) != reply->height) { changed |= XawPRSliderHeight; XtHeight(child) = reply->height; } if (changed) SendReport(pw, changed); } return (XtGeometryYes); /* success! */ }
HRESULT CAutotest::Autotest() { HRESULT hr = S_OK; DWORD dwTableSize = sizeof(m_sResultTable) / sizeof(m_sResultTable[0]); SW_TRACE_NORMAL("Info: Autotest begins...\n"); SaveAutotestProgress(); for (INT i = m_iRunCount; i < m_iTestCount; i++) { m_dwTestProgress = 1; SW_TRACE_NORMAL("Info: TestLoop #%d\n", i+1); if (GetAutotestStopFlag()) { SW_TRACE_DEBUG("Info: Autotest is forced to stop!\n"); break; } if( i < 10) { CTester::Product_SwitcherTest(3); CTester::Product_DcCtl_TEST(5); } AutotestRunOnce(m_sResultTable, dwTableSize); m_iRunCount++; if (GetAutotestStopFlag()) { SW_TRACE_DEBUG("Info: Autotest is forced to stop!\n"); break; } CHAR* pszReport = NULL; BOOL bOK = TRUE; GenerateReport((DWORD)i+1, m_sResultTable, dwTableSize, &pszReport, &bOK); if (GetAutotestStopFlag()) { SW_TRACE_DEBUG("Info: Autotest is forced to stop!\n"); SAFE_MEM_FREE(pszReport); break; } SaveReport(pszReport); if (GetAutotestStopFlag()) { SW_TRACE_DEBUG("Info: Autotest is forced to stop!\n"); SAFE_MEM_FREE(pszReport); break; } SendReport(pszReport, bOK); if (GetAutotestStopFlag()) { SW_TRACE_DEBUG("Info: Autotest is forced to stop!\n"); SAFE_MEM_FREE(pszReport); break; } SAFE_MEM_FREE(pszReport); } if (0 == m_iNGCount) { m_dwTestProgress = 0;//test OK } else { m_dwTestProgress = 2;//test failed } SetAutotestStopFlag(TRUE); SW_TRACE_NORMAL("Info: Autotest %s!\n", m_iRunCount >= m_iTestCount-1 ? "Done" : "Canceled"); return S_OK; }
static void ComputeLayout(Widget widget, Bool query, Bool destroy_scrollbars) { ViewportWidget w = (ViewportWidget)widget; Widget child = w->viewport.child; Widget clip = w->viewport.clip; ViewportConstraints constraints = (ViewportConstraints)clip->core.constraints; Bool needshoriz, needsvert; int clip_width, clip_height; XtWidgetGeometry intended; if (child == NULL) return; clip_width = XtWidth(w); clip_height = XtHeight(w); intended.request_mode = CWBorderWidth; intended.border_width = 0; if (w->viewport.forcebars) { needsvert = w->viewport.allowvert; needshoriz = w->viewport.allowhoriz; ComputeWithForceBars(widget, query, &intended, &clip_width, &clip_height); } else { Dimension prev_width, prev_height; XtGeometryMask prev_mode; XtWidgetGeometry preferred; needshoriz = needsvert = False; /* * intended.{width,height} caches the eventual child dimensions, * but we don't set the mode bits until after we decide that the * child's preferences are not acceptable */ if (!w->viewport.allowhoriz) intended.request_mode |= CWWidth; if (XtWidth(child) < clip_width) intended.width = clip_width; else intended.width = XtWidth(child); if (XtHeight(child) < clip_height) intended.height = clip_height; else intended.height = XtHeight(child); if (!w->viewport.allowvert) intended.request_mode |= CWHeight; if (!query) { preferred.width = XtWidth(child); preferred.height = XtHeight(child); } do { /* while intended != prev */ if (query) { (void)XtQueryGeometry(child, &intended, &preferred); if (!(preferred.request_mode & CWWidth)) preferred.width = intended.width; if (!(preferred.request_mode & CWHeight)) preferred.height = intended.height; } prev_width = intended.width; prev_height = intended.height; prev_mode = intended.request_mode; /* * note that having once decided to turn on either bar * we'll not change our mind until we're next resized, * thus avoiding potential oscillations */ #define CheckHoriz() \ if (w->viewport.allowhoriz && \ preferred.width > clip_width) { \ if (!needshoriz) { \ Widget bar; \ \ needshoriz = True; \ if ((bar = w->viewport.horiz_bar) == NULL) \ bar = CreateScrollbar(w, True); \ clip_height -= XtHeight(bar) + XtBorderWidth(bar); \ if (clip_height < 1) \ clip_height = 1; \ } \ intended.width = preferred.width; \ } CheckHoriz(); if (w->viewport.allowvert && preferred.height > clip_height) { if (!needsvert) { Widget bar; needsvert = True; if ((bar = w->viewport.vert_bar) == NULL) bar = CreateScrollbar(w, False); clip_width -= XtWidth(bar) + XtBorderWidth(bar); if (clip_width < 1) clip_width = 1; CheckHoriz(); } intended.height = preferred.height; } if (!w->viewport.allowhoriz || preferred.width < clip_width) { intended.width = clip_width; intended.request_mode |= CWWidth; } if (!w->viewport.allowvert || preferred.height < clip_height) { intended.height = clip_height; intended.request_mode |= CWHeight; } } while (intended.request_mode != prev_mode || (intended.request_mode & CWWidth && intended.width != prev_width) || (intended.request_mode & CWHeight && intended.height != prev_height)); } if (XtIsRealized(clip)) XRaiseWindow(XtDisplay(clip), XtWindow(clip)); XtMoveWidget(clip, needsvert ? w->viewport.useright ? 0 : XtWidth(w->viewport.vert_bar) + XtBorderWidth(w->viewport.vert_bar) : 0, needshoriz ? w->viewport.usebottom ? 0 : XtHeight(w->viewport.horiz_bar) + XtBorderWidth(w->viewport.horiz_bar) : 0); XtResizeWidget(clip, clip_width, clip_height, 0); if (w->viewport.horiz_bar != NULL) { Widget bar = w->viewport.horiz_bar; if (!needshoriz) { constraints->form.vert_base = NULL; if (destroy_scrollbars) { XtDestroyWidget(bar); w->viewport.horiz_bar = NULL; } } else { int bw = XtBorderWidth(bar); XtResizeWidget(bar, clip_width, XtHeight(bar), bw); XtMoveWidget(bar, needsvert && !w->viewport.useright ? XtWidth(w->viewport.vert_bar) : -bw, w->viewport.usebottom ? XtHeight(w) - XtHeight(bar) - bw : -bw); XtSetMappedWhenManaged(bar, True); } } if (w->viewport.vert_bar != NULL) { Widget bar = w->viewport.vert_bar; if (!needsvert) { constraints->form.horiz_base = NULL; if (destroy_scrollbars) { XtDestroyWidget(bar); w->viewport.vert_bar = NULL; } } else { int bw = bar->core.border_width; XtResizeWidget(bar, XtWidth(bar), clip_height, bw); XtMoveWidget(bar, w->viewport.useright ? XtWidth(w) - XtWidth(bar) - bw : -bw, needshoriz && !w->viewport.usebottom ? XtHeight(w->viewport.horiz_bar) : -bw); XtSetMappedWhenManaged(bar, True); } } if (child != NULL) { XtResizeWidget(child, intended.width, intended.height, 0); MoveChild(w, needshoriz ? XtX(child) : 0, needsvert ? XtY(child) : 0); } SendReport (w, XawPRAll); }
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); } } }
/******************************************************************** 函数功能:主函数。 入口参数:无。 返 回:无。 备 注:无。 ********************************************************************/ void main(void) { #ifdef DEBUG0 int i; #endif int InterruptSource; SystemClockInit(); //系统时钟初始化 LedInit(); //LED对应的管脚初始化 LcdInit(); //LCD初始化 AdcInit(); //ADC初始化 Timer1Init(); //定时器1初始化,用来产生10ms的定时扫描信号 KeyInit(); //键盘初始化 Uart0Init(); //串口0初始化 #ifdef DEBUG0 for(i=0;i<16;i++) //显示头信息 { Prints(HeadTable[i]); } #endif UsbChipInit(); //初始化USB部分 while(1) { InterruptSource=(*AT91C_UDP_ISR)&(0x0F|(1<<8)|(1<<12)); //取出需要的中断 if(InterruptSource) //如果监视的中断发生 { if(InterruptSource&(1<<8)) { *AT91C_UDP_ICR=1<<8; //清除中断 UsbBusSuspend(); //总线挂起中断处理 } if(InterruptSource&(1<<12)) { *AT91C_UDP_ICR=1<<12; //清除中断 UsbBusReset(); //总线复位中断处理 } if(InterruptSource&(1<<0)) { if(AT91C_UDP_CSR[0]&((1<<1)|(1<<2)|(1<<6))) //如果是SETUP包、缓冲未空等 { UsbEp0Out(); //端点0输出中断处理 } if(AT91C_UDP_CSR[0]&(1<<0)) //如果是端点0输入完成 { UsbEp0In(); //端点0输入中断处理 } } if(InterruptSource&(1<<1)) { UsbEp1In(); //端点1输入中断处理 } if(InterruptSource&(1<<2)) { UsbEp2Out(); //端点2输出中断处理 } if(InterruptSource&(1<<3)) { UsbEp3In(); //端点3输入中断处理 } } if(KeyUp||KeyDown) //如果用户操作了按键 { DispKey(); //在LCD上显示按键情况 if(ConfigValue!=0) //如果已经设置为非0的配置,则可以返回报告数据 { if(!Ep1InIsBusy) //如果端点1输入没有处于忙状态,则可以发送数据 { KeyCanChange=0; //禁止按键扫描 if(KeyUp||KeyDown) //如果有按键事件发生 { SendReport(); //则返回报告 } KeyCanChange=1; //允许按键扫描 } } //清除KeyUp和KeyDown KeyUp=0; KeyDown=0; LcdRefresh(); //刷新LCD显示 } } }
void SystemAPI::end(void){ SystemKeycode _report = HID_SYSTEM_UNASSIGNED; SendReport(&_report, sizeof(_report)); }