// loads the demux into the FilterGraph HRESULT CBDAFilterGraph::LoadDemux() { HRESULT hr = S_OK; hr = CoCreateInstance( CLSID_MPEG2Demultiplexer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, reinterpret_cast<void**>(&m_pDemux) ); if (FAILED (hr)) { ErrorMessageBox(TEXT("Could not CoCreateInstance CLSID_MPEG2Demultiplexer\n")); return hr; } hr = m_pFilterGraph->AddFilter(m_pDemux, L"Demux"); if(FAILED(hr)) { ErrorMessageBox(TEXT("Unable to add demux filter to graph\n")); return hr; } return hr; }
bool FileSystemInitializer::Initialize() { if (initSuccess) return true; try { Platform::SetOrigCWD(); dataDirLocater.LocateDataDirs(); dataDirLocater.Check(); archiveScanner = new CArchiveScanner(); vfsHandler = new CVFSHandler(); initSuccess = true; } catch (const std::exception& ex) { // abort VFS-init thread initFailure = true; // even if we end up here, do not clean up configHandler yet // since it can already have early observers registered that // do not remove themselves until exit Cleanup(false); ErrorMessageBox(ex.what(), "Spring: caught std::exception", MBF_OK | MBF_EXCL); } catch (...) { initFailure = true; Cleanup(false); ErrorMessageBox("", "Spring: caught generic exception", MBF_OK | MBF_EXCL); } return (initSuccess && !initFailure); }
void CMainFrame::OnCmdResetDevice(DWORD dwSlotNo) { ndas::DevicePtr pDevice; if (!ndas::FindDeviceBySlotNumber(pDevice, dwSlotNo)) { return; } if (!pDevice->Enable(FALSE)) { ErrorMessageBox(IDS_ERROR_RESET_DEVICE); return; } ::SetCursor(AtlLoadSysCursor(IDC_WAIT)); CSimpleWaitDlg().DoModal(m_hWnd, 2000); ::SetCursor(AtlLoadSysCursor(IDC_ARROW)); if (!pDevice->Enable(TRUE)) { ErrorMessageBox(IDS_ERROR_RESET_DEVICE); } ndas::UpdateDeviceList(); }
void CNdasDevicePropGeneralPage::OnModifyWriteKey(UINT, int, HWND) { ACCESS_MASK access = m_pDevice->GetGrantedAccess(); if (access & GENERIC_WRITE) { int response = pTaskDialogVerify( m_hWnd, IDS_REMOVE_WRITE_KEY_CONFIRM_TITLE, IDS_REMOVE_WRITE_KEY_CONFIRM, IDS_REMOVE_WRITE_KEY_CONFIRM_DESC, _T("DontConfirmRemoveWriteKey"), TDCBF_YES_BUTTON | TDCBF_NO_BUTTON, IDNO, IDYES); if (IDYES == response) { BOOL fSuccess = m_pDevice->SetAsReadOnly(); if (!fSuccess) { ErrorMessageBox(m_hWnd, IDS_ERROR_REMOVE_WRITE_KEY); } else { _UpdateDeviceData(); } } } else { CNdasDeviceAddWriteKeyDlg dlg; dlg.SetDeviceId(m_pDevice->GetStringId()); dlg.SetDeviceName(m_pDevice->GetName()); INT_PTR iResult = dlg.DoModal(); ATLTRACE("iResult = %d\n", iResult); if (iResult == IDOK) { BOOL fSuccess = m_pDevice->SetAsReadWrite(dlg.GetWriteKey()); if (!fSuccess) { ErrorMessageBox(m_hWnd, IDS_ERROR_ADD_WRITE_KEY); } else { _UpdateDeviceData(); } } else { ; } } }
static int CALLBACK DIJoystick_EnumAxisObjectsProc(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef) { joystick_type* joystick = (joystick_type*)pvRef; DIPROPRANGE diprg; HRESULT hr; joystick->axes[joystick->num_axes].guid = lpddoi->guidType; joystick->axes[joystick->num_axes].name = (TCHAR *)malloc((_tcslen(lpddoi->tszName) + 1) * sizeof(TCHAR)); _tcscpy(joystick->axes[joystick->num_axes].name, lpddoi->tszName); joystick->axes[joystick->num_axes].offset = lpddoi->dwOfs; /*ErrorMessageBox("got axis %s, offset %i",lpddoi->tszName, lpddoi->dwOfs);*/ memset(&diprg, 0, sizeof(DIPROPRANGE)); diprg.diph.dwSize = sizeof(DIPROPRANGE); diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER); diprg.diph.dwObj = lpddoi->dwOfs; diprg.diph.dwHow = DIPH_BYOFFSET; diprg.lMin = 0; diprg.lMax = 255; hr = IDirectInputDevice2_SetProperty(joystick->did, DIPROP_RANGE, &diprg.diph); if (FAILED(hr)) /* if this fails, don't use this axis */ { free(joystick->axes[joystick->num_axes].name); joystick->axes[joystick->num_axes].name = NULL; return DIENUM_CONTINUE; } #ifdef JOY_DEBUG if (FAILED(hr)) { ErrorMessageBox("DirectInput SetProperty() joystick axis %s failed - %s\n", joystick->axes[joystick->num_axes].name, DirectXDecodeError(hr)); } #endif /* Set axis dead zone to 0; we need accurate #'s for analog joystick reading. */ SetDIDwordProperty(joystick->did, DIPROP_DEADZONE, lpddoi->dwOfs, DIPH_BYOFFSET, 0); #ifdef JOY_DEBUG if (FAILED(hr)) { ErrorMessageBox("DirectInput SetProperty() joystick axis %s dead zone failed - %s\n", joystick->axes[joystick->num_axes].name, DirectXDecodeError(hr)); } #endif joystick->num_axes++; return DIENUM_CONTINUE; }
HRESULT CBDAFilterGraph::ChangeChannel( LONG lMajorChannel, LONG lMinorChannel ) { HRESULT hr = S_OK; m_lMajorChannel = lMajorChannel; m_lMinorChannel = lMinorChannel; CComPtr <IScanningTuner> pIScanningTuner; if (!m_pNetworkProvider) { ErrorMessageBox(TEXT("The FilterGraph is not yet built.\n")); return E_FAIL; } hr = m_pNetworkProvider.QueryInterface (&pIScanningTuner); if (FAILED(hr)) { ErrorMessageBox(TEXT("Cannot QI for IScanningTuner\n")); return hr; } // create tune request CComPtr <IATSCChannelTuneRequest> pTuneRequest; hr = CreateATSCTuneRequest( m_lPhysicalChannel, lMajorChannel, lMinorChannel, &pTuneRequest ); if(SUCCEEDED(hr)) { hr = m_pITuner->put_TuneRequest (pTuneRequest); if (FAILED (hr)) ErrorMessageBox(TEXT("Cannot submit tune request\n")); } else { ErrorMessageBox(TEXT("Cannot Change Channels\n")); } return hr; }
static void error_code_messagebox(HWND hwnd, DWORD error_code) { TCHAR title[256]; if (!LoadString(hInst, IDS_ERROR, title, COUNT_OF(title))) lstrcpy(title, TEXT("Error")); ErrorMessageBox(hwnd, title, error_code); }
void MainFunc(int argc, char** argv, int* ret) { #ifdef __MINGW32__ // For the MinGW backtrace() implementation we need to know the stack end. { extern void* stack_end; char here; stack_end = (void*) &here; } #endif while (!Threading::IsMainThread()) ; #ifdef USE_GML set_threadnum(GML_DRAW_THREAD_NUM); #if GML_ENABLE_TLS_CHECK if (gmlThreadNumber != GML_DRAW_THREAD_NUM) { ErrorMessageBox("Thread Local Storage test failed", "GML error:", MBF_OK | MBF_EXCL); } #endif #endif try { SpringApp app; *ret = app.Run(argc, argv); } CATCH_SPRING_ERRORS }
void CDeviceAdvancedPage::OnDeactivateDevice(UINT uCode, int nCtrlID, HWND hwndCtrl) { ATLASSERT(NULL != m_pDevice.get()); CString strMessage = (LPCTSTR) IDS_CONFIRM_DEACTIVATE_DEVICE; CString strTitle = (LPCTSTR) IDS_MAIN_TITLE; ATLASSERT(!strMessage.IsEmpty()); ATLASSERT(!strTitle.IsEmpty()); INT_PTR iResponse = MessageBox( strMessage, strTitle, MB_YESNO | MB_ICONQUESTION); if (IDYES != iResponse) { return; } if (!m_pDevice->Enable(FALSE)) { ErrorMessageBox(m_hWnd, IDS_ERROR_DISABLE_DEVICE); } m_wndDeactivate.EnableWindow(FALSE); m_wndReset.EnableWindow(FALSE); }
LPBYTE CBZDoc::QueryMapView1(LPBYTE pBegin, DWORD dwOffset) { LPBYTE p = pBegin + dwOffset; if(IsOutOfMap1(p)) { if(p == m_pData + m_dwTotal && p == m_pMapStart + m_dwMapSize) return pBegin; // ###1.61a DWORD dwBegin = pBegin - m_pData; VERIFY(::UnmapViewOfFile(m_pMapStart)); m_dwFileOffset = (p - m_pData) & FILEOFFSET_MASK; m_dwMapSize = min(options.dwMaxMapSize, m_dwTotal - m_dwFileOffset); if(m_dwMapSize == 0) { // ###1.61a m_dwFileOffset = (m_dwTotal - (~FILEOFFSET_MASK + 1)) & FILEOFFSET_MASK; m_dwMapSize = m_dwTotal - m_dwFileOffset; } m_pMapStart = (LPBYTE)::MapViewOfFile(m_hMapping, m_bReadOnly ? FILE_MAP_READ : FILE_MAP_WRITE, 0, m_dwFileOffset, m_dwMapSize); TRACE("MapViewOfFile Doc=%X, %X, Offset:%X, Size:%X\n", this, m_pMapStart, m_dwFileOffset, m_dwMapSize); if(!m_pMapStart) { ErrorMessageBox(); AfxPostQuitMessage(0); return NULL; } m_pData = m_pMapStart - m_dwFileOffset; pBegin = m_pData + dwBegin; } return pBegin; }
// RunGraph checks to see if a graph has been built // if not it calls BuildGraph // RunGraph then calls MediaCtrl-Run HRESULT CBDAFilterGraph::RunGraph() { // check to see if the graph is already running if(m_fGraphRunning) return S_OK; HRESULT hr = S_OK; if (m_pIMediaControl == NULL) hr = m_pFilterGraph.QueryInterface (&m_pIMediaControl); if (SUCCEEDED (hr)) { // run the graph hr = m_pIMediaControl->Run(); if(SUCCEEDED(hr)) { m_fGraphRunning = true; } else { // stop parts of the graph that ran m_pIMediaControl->Stop(); ErrorMessageBox(TEXT("Cannot run graph\n")); } } return hr; }
void NewHandler() { LOG_L(L_ERROR, "Failed to allocate memory"); // make sure this ends up in the log also OutputStacktrace(); ErrorMessageBox("Failed to allocate memory", "Spring: Fatal Error", MBF_OK | MBF_CRASH); }
void CNdasDevicePropAdvancedPage::OnDeactivateDevice(UINT uCode, int nCtrlID, HWND hwndCtrl) { ATLASSERT(NULL != m_pDevice.get()); int response = AtlTaskDialogEx( m_hWnd, IDS_MAIN_TITLE, IDS_CONFIRM_DEACTIVATE_DEVICE, IDS_CONFIRM_DEACTIVATE_DEVICE_DESC, TDCBF_YES_BUTTON | TDCBF_NO_BUTTON, TD_INFORMATION_ICON); if (IDYES != response) { return; } if (!m_pDevice->Enable(FALSE)) { ErrorMessageBox(m_hWnd, IDS_ERROR_DISABLE_DEVICE); } m_wndDeactivate.EnableWindow(FALSE); m_wndReset.EnableWindow(FALSE); }
void EAE_Engine::Tools::OutputErrorMessage( const char* const i_errorMessage, const char* const i_optionalFileName ) { // This formatting causes the errors to show up in Visual Studio's "Error List" tab std::cerr << ( i_optionalFileName ? i_optionalFileName : "Asset Build" ) << ": error: " << i_errorMessage << "\n"; ErrorMessageBox(i_errorMessage); // DEBUG_PRINT("For file %s, Asset Build: error: %s\n", i_optionalFileName, i_errorMessage); }
/** * @brief main * @return exit code * @param argc argument count * @param argv array of argument strings * * Main entry point function */ int main(int argc, char* argv[]) { // PROFILE builds exit on execv ... // HEADLESS run mostly in parallel for testing purposes, 100% omp threads wouldn't help then #if !defined(PROFILE) && !defined(HEADLESS) bool restart = false; restart |= SetNvOptimusProfile(argv); restart |= SetOpenMpEnvVars(argv); #ifndef WIN32 if (restart) { std::vector<std::string> args(argc-1); for (int i=1; i<argc; i++) { args[i-1] = argv[i]; } const std::string err = Platform::ExecuteProcess(argv[0], args); ErrorMessageBox(err, "Execv error:", MBF_OK | MBF_EXCL); } #endif #endif int ret = Run(argc, argv); std::string exe = EngineTypeHandler::GetRestartExecutable(); if (exe != "") { std::vector<std::string> args; for (int i=1; i<argc; i++) args.push_back(argv[i]); if (!EngineTypeHandler::RestartEngine(exe, args)) { handleerror(NULL, EngineTypeHandler::GetRestartErrorMessage(), "Missing engine type", MBF_OK | MBF_EXCL); } } return ret; }
static BOOL UnloadHive(HWND hWnd) { WCHAR Caption[128]; LPCWSTR pszKeyPath; HKEY hRootKey; LONG regUnloadResult; /* get the item key to unload */ pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey); /* load and set the caption and flags for dialog */ LoadStringW(hInst, IDS_UNLOAD_HIVE, Caption, COUNT_OF(Caption)); /* Enable the 'restore' privilege, unload the hive, disable the privilege */ EnablePrivilege(SE_RESTORE_NAME, NULL, TRUE); regUnloadResult = RegUnLoadKeyW(hRootKey, pszKeyPath); EnablePrivilege(SE_RESTORE_NAME, NULL, FALSE); if(regUnloadResult == ERROR_SUCCESS) { /* refresh tree and list views */ RefreshTreeView(g_pChildWnd->hTreeWnd); pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey); RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath); } else { ErrorMessageBox(hWnd, Caption, regUnloadResult); return FALSE; } return TRUE; }
void CNdasDevicePropGeneralPage::OnRename(UINT, int, HWND) { CNdasDeviceRenameDlg wndRename; wndRename.SetName(m_pDevice->GetName()); INT_PTR iResult = wndRename.DoModal(); if (IDOK == iResult) { CString strNewName = wndRename.GetName(); if (0 != strNewName.Compare(m_pDevice->GetName())) { if (!m_pDevice->SetName(strNewName)) { ErrorMessageBox(m_hWnd, IDS_ERROR_RENAME_DEVICE); } else { m_wndDeviceName.SetWindowText(strNewName); CString strTitle; strTitle.FormatMessage(IDS_DEVICE_PROP_TITLE, strNewName); GetParent().SetWindowText(strTitle); _UpdateDeviceData(); } } } }
int Run(int argc, char* argv[]) { int ret = -1; #ifdef __MINGW32__ // For the MinGW backtrace() implementation we need to know the stack end. { extern void* stack_end; char here; stack_end = (void*) &here; } #endif Threading::DetectCores(); Threading::SetMainThread(); // run try { SpringApp app(argc, argv); ret = app.Run(); } CATCH_SPRING_ERRORS // check if (a thread in) Spring crashed, if so display an error message Threading::Error* err = Threading::GetThreadError(); if (err != NULL) { ErrorMessageBox(" error: " + err->message, err->caption, err->flags, true); } return ret; }
// Returns true if successful static int DoExchangeItem(HWND hFrom, HWND hTo, int nMinItem) { LVITEM lvi; wchar_t buf[80]; lvi.iItem = ListView_GetNextItem(hFrom, -1, LVIS_SELECTED | LVIS_FOCUSED); if (lvi.iItem < nMinItem) { if (lvi.iItem != -1) // Can't remove the first column ErrorMessageBox("Cannot move selected item"); SetFocus(hFrom); return 0; } lvi.iSubItem = 0; lvi.mask = LVIF_PARAM | LVIF_TEXT; lvi.pszText = buf; lvi.cchTextMax = WINUI_ARRAY_LENGTH(buf); if (ListView_GetItem(hFrom, &lvi)) { // Add this item to the Show and delete it from Available (void)ListView_DeleteItem(hFrom, lvi.iItem); lvi.iItem = ListView_GetItemCount(hTo); (void)ListView_InsertItem(hTo, &lvi); ListView_SetItemState(hTo, lvi.iItem, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); SetFocus(hTo); return lvi.iItem; } return 0; }
void CMainFrame::OnCmdMountDeviceRO(NDAS_LOGICALDEVICE_ID logDeviceId) { ndas::LogicalDevicePtr pLogDevice; if (!ndas::FindLogicalDevice(pLogDevice, logDeviceId)) { ATLTRACE("Invalid logical device id specified: %d\n", logDeviceId); return; } if (!pLogDevice->PlugIn(FALSE)) { ErrorMessageBox(IDS_ERROR_MOUNT_DEVICE_RO); return; } if (!pLogDevice->UpdateStatus()) { // Service Communication failure? return; } if (NDAS_LOGICALDEVICE_STATUS_MOUNT_PENDING == pLogDevice->GetStatus()) { CWaitMountDialog().DoModal(m_hWnd, pLogDevice); } }
static BOOL UnloadHive(HWND hWnd) { TCHAR Caption[128]; LPCTSTR pszKeyPath; HKEY hRootKey; LONG regUnloadResult; /* get the item key to unload */ pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey); /* load and set the caption and flags for dialog */ LoadString(hInst, IDS_UNLOAD_HIVE, Caption, COUNT_OF(Caption)); /* now unload the hive */ regUnloadResult = RegUnLoadKey(hRootKey, pszKeyPath); if(regUnloadResult == ERROR_SUCCESS) { /* refresh tree and list views */ RefreshTreeView(g_pChildWnd->hTreeWnd); pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey); RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath); } else { ErrorMessageBox(hWnd, Caption, regUnloadResult); return FALSE; } return TRUE; }
// LoadNetworkProvider loads network provider HRESULT CBDAFilterGraph::LoadNetworkProvider() { HRESULT hr = S_OK; CComBSTR bstrNetworkType; CLSID CLSIDNetworkType; // obtain tuning space then load network provider if(m_pITuningSpace == NULL) { hr = LoadTuningSpace(); if(FAILED(hr)) { ErrorMessageBox(TEXT("Cannot load TuningSpace\n")); return hr; } } // Get the current Network Type clsid hr = m_pITuningSpace->get_NetworkType(&bstrNetworkType); if (FAILED (hr)) { ErrorMessageBox(TEXT("ITuningSpace::Get Network Type failed\n")); return hr; } hr = CLSIDFromString(bstrNetworkType, &CLSIDNetworkType); if (FAILED (hr)) { ErrorMessageBox(TEXT("Couldn't get CLSIDFromString\n")); return hr; } // create the network provider based on the clsid obtained from the tuning space hr = CoCreateInstance(CLSIDNetworkType, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, reinterpret_cast<void**>(&m_pNetworkProvider)); if (FAILED (hr)) { ErrorMessageBox(TEXT("Couldn't CoCreate Network Provider\n")); return hr; } //add the Network Provider filter to the graph hr = m_pFilterGraph->AddFilter(m_pNetworkProvider, L"Network Provider"); return hr; }
void createDialog(void) { STARTUPINFOA startinfo; WNDCLASSEXA WndClass; g_hInstance = GetModuleHandle(NULL); GetStartupInfoA(&startinfo); WndClass.cbSize = sizeof WndClass; WndClass.style = 0; WndClass.lpfnWndProc = WndProc; WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.hInstance = g_hInstance; WndClass.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_MAINICON)); WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); WndClass.lpszMenuName = MAKEINTRESOURCEA(IDM_MAINMENU); WndClass.lpszClassName = "DrMingw"; WndClass.hIconSm = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_MAINICON)); if (!RegisterClassExA(&WndClass)) { ErrorMessageBox("RegisterClassEx: %s", LastErrorMessage()); exit(EXIT_FAILURE); } g_hWnd = CreateWindowExA( WS_EX_CLIENTEDGE, WndClass.lpszClassName, "Dr. Mingw", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, g_hInstance, NULL ); if (g_hWnd == NULL) { ErrorMessageBox("CreateWindowEx: %s", LastErrorMessage()); exit(EXIT_FAILURE); } ShowWindow(g_hWnd, (startinfo.dwFlags & STARTF_USESHOWWINDOW) ? startinfo.wShowWindow : SW_SHOWDEFAULT); UpdateWindow(g_hWnd); }
void CMainFrame::OnCmdUnregisterDevice(DWORD dwSlotNo) { ndas::DevicePtr pDevice; if (!ndas::FindDeviceBySlotNumber(pDevice, dwSlotNo)) { return; } CString strMessage; strMessage.FormatMessage( IDS_CONFIRM_UNREGISTER_FMT, pDevice->GetName()); int response = pTaskDialogVerify( m_hWnd, IDS_MAIN_TITLE, static_cast<LPCTSTR>(strMessage), static_cast<LPCTSTR>(NULL), _T("DontConfirmUnregister"), TDCBF_YES_BUTTON | TDCBF_NO_BUTTON, IDNO, IDYES); if (IDYES != response) { return; } if (NDAS_DEVICE_STATUS_NOT_REGISTERED != pDevice->GetStatus()) { if (!pDevice->Enable(FALSE)) { ErrorMessageBox(IDS_ERROR_UNREGISTER_DEVICE); ndas::UpdateDeviceList(); return; } } if (!::NdasUnregisterDevice(dwSlotNo)) { ErrorMessageBox(IDS_ERROR_UNREGISTER_DEVICE); } ndas::UpdateDeviceList(); }
// Set our client area for viewing // // Note, what you're not seeing here is a call to // IAMSreamCconfig's GetFormat to obtain the video // format properties that would enable us to set // the viewing window's size HRESULT CBDAFilterGraph::SetVideoWindow( HWND hwndMain ) { CComPtr <IVideoWindow> pVideoWindow; RECT rc; INT cyBorder; INT cy; HRESULT hr = S_OK; // get IVideoWindow interface hr = m_pFilterGraph->QueryInterface (&pVideoWindow); if (FAILED (hr)) { ErrorMessageBox(TEXT("QueryInterface IVideoWindow Failed\n")); return hr; } hr = pVideoWindow->put_Owner (reinterpret_cast <LONG> (hwndMain)); if (FAILED (hr)) { ErrorMessageBox(TEXT("Unable to set video window\n")); return hr; } hr = pVideoWindow->put_WindowStyle (WS_CHILD); if (FAILED (hr)) { ErrorMessageBox(TEXT("Unable to set the style for the video window\n")); return hr; } GetClientRect(hwndMain, &rc); cyBorder = GetSystemMetrics(SM_CYBORDER); cy = cyBorder; rc.bottom -= cy; hr = pVideoWindow->SetWindowPosition( 0, 0, rc.right, rc.bottom ); hr = pVideoWindow->put_Visible (OATRUE); return hr; }
void HandleSignal(int signal) { std::string error; std::queue<std::string> addresses; logOutput.RemoveAllSubscribers(); { LogObject log; if (signal == SIGSEGV) error = "Segmentation fault (SIGSEGV)"; else if (signal == SIGILL) error = "Illegal instruction (SIGILL)"; else if (signal == SIGPIPE) error = "Broken pipe (SIGPIPE)"; else if (signal == SIGIO) error = "IO-Error (SIGIO)"; else if (signal == SIGABRT) error = "Aborted (SIGABRT)"; log << error << " in spring " << SpringVersion::GetFull() << "\nStacktrace:\n"; std::vector<void*> buffer(128); const int numptr = backtrace(&buffer[0], buffer.size()); // stack pointers char ** strings = backtrace_symbols(&buffer[0], numptr); // give them meaningfull names if (strings == NULL) { log << "Unable to create stacktrace\n"; } else { for (int j = 0; j < numptr; j++) { std::string addrline(strings[j]); log << addrline << "\n"; size_t begin = addrline.find_first_of('['); if (begin != std::string::npos) { size_t end = addrline.find_first_of(']'); if (end != std::string::npos) { addresses.push(addrline.substr(begin+1, end-begin-1)); } } } delete strings; } } logOutput.End(); // Stop writing to log. std::ostringstream buf; buf << "addr2line " << "--exe=\"" << Platform::GetBinaryFile() << "\""; while (!addresses.empty()) { buf << " " << addresses.front(); addresses.pop(); } buf << " >> infolog.txt"; // pipe to infolog (which will be in CWD) system(buf.str().c_str()); ErrorMessageBox(error, "Spring crashed", 0); };
int CKMotionIO::SetLatency(UCHAR LatencyTimer) { FT_STATUS ftStatus; unsigned char c; Mutex->Lock(); ftStatus = FT_GetLatencyTimer (ftHandle, &c); ftStatus = FT_SetLatencyTimer(ftHandle,LatencyTimer); if (ftStatus == FT_OK) { ftStatus = FT_GetLatencyTimer (ftHandle, &c); // LatencyTimer set ftStatus = FT_SetChars (ftHandle, '\n', 1, 0,0); if (ftStatus == FT_OK) { // Event set Mutex->Unlock(); return 0; } else { // FT_SetLatencyTimer FAILED! ErrorMessageBox("Unable to set USB Event Character"); Mutex->Unlock(); return 1; } } else { // FT_SetLatencyTimer FAILED! ErrorMessageBox("Unable to set USB Latency timer"); Mutex->Unlock(); return 1; } }
static BOOL LoadHive(HWND hWnd) { OPENFILENAME ofn; WCHAR Caption[128]; LPCWSTR pszKeyPath; WCHAR xPath[LOADHIVE_KEYNAMELENGTH]; HKEY hRootKey; WCHAR Filter[1024]; FILTERPAIR filter; /* get the item key to load the hive in */ pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey); /* initialize the "open file" dialog */ InitOpenFileName(hWnd, &ofn); /* build the "All Files" filter up */ filter.DisplayID = IDS_FLT_ALLFILES; filter.FilterID = IDS_FLT_ALLFILES_FLT; BuildFilterStrings(Filter, &filter, 1); ofn.lpstrFilter = Filter; /* load and set the caption and flags for dialog */ LoadStringW(hInst, IDS_LOAD_HIVE, Caption, COUNT_OF(Caption)); ofn.lpstrTitle = Caption; ofn.Flags |= OFN_ENABLESIZING; /* ofn.lCustData = ;*/ /* now load the hive */ if (GetOpenFileName(&ofn)) { if (DialogBoxParamW(hInst, MAKEINTRESOURCEW(IDD_LOADHIVE), hWnd, &LoadHive_KeyNameInHookProc, (LPARAM)xPath)) { LONG regLoadResult; /* Enable the 'restore' privilege, load the hive, disable the privilege */ EnablePrivilege(SE_RESTORE_NAME, NULL, TRUE); regLoadResult = RegLoadKeyW(hRootKey, xPath, ofn.lpstrFile); EnablePrivilege(SE_RESTORE_NAME, NULL, FALSE); if(regLoadResult == ERROR_SUCCESS) { /* refresh tree and list views */ RefreshTreeView(g_pChildWnd->hTreeWnd); pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey); RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath); } else { ErrorMessageBox(hWnd, Caption, regLoadResult); return FALSE; } } } else { CheckCommDlgError(hWnd); } return TRUE; }
int CKMotionIO::SetLatency(UCHAR LatencyTimer) { int ftStatus; unsigned char c; Mutex->Lock(); ftStatus = ftdi_get_latency_timer(ftdi,&c ); if(c != LatencyTimer){ log_info("ftdi_get_latency_timer old value %d", c); ftStatus = ftdi_set_latency_timer(ftdi,LatencyTimer ); if (ftStatus < FT_OK) { // FT_SetLatencyTimer FAILED! ErrorMessageBox("Unable to set USB Latency timer"); Mutex->Unlock(); return 1; } } // LatencyTimer set ftStatus = ftdi_set_event_char(ftdi,'\n',1); if (ftStatus == FT_OK) { // Event set Mutex->Unlock(); return 0; } else { // FT_SetLatencyTimer FAILED! ErrorMessageBox("Unable to set USB Event Character"); Mutex->Unlock(); return 1; } }
void CMainFrame::OnCmdRefreshStatus(UINT /* wNotifyCode */, int /* wID */, HWND /* hWndCtl */) { BOOL fSuccess; fSuccess = pUpdateDeviceList(); if (!fSuccess) { ErrorMessageBox(IDS_ERROR_UPDATE_DEVICE_LIST); } pUpdateMenuItems(); }