void CCollectorDlg::OnOpenSelectedText() { // TODO: Add your message handler code here and/or call default int nStart, nEnd; m_edit->GetSel(nStart,nEnd); if (nStart>=nEnd) { MSGBOX(IDS_NOT_SELECT_TEXT); return; } if (nStart>=0 && nEnd>=0) { CString strText, strCode; m_edit->GetWindowText(strText); strCode = strText.Mid(nStart,nEnd-nStart); if (strCode.GetLength()) { strCode.TrimLeft();strCode.TrimRight(); if (!IS_URL(strCode)) MSGBOX(IDS_NOT_VALID_URL); else pmf->NewChildWindow(1,2,strCode); } } }
/* ================ Sys_Break same as Error ================ */ void Sys_Break( const char *error, ... ) { va_list argptr; char text[MAX_SYSPATH]; if( host.state == HOST_ERR_FATAL ) return; // don't multiple executes error_on_exit = true; host.state = HOST_ERR_FATAL; va_start( argptr, error ); Q_vsprintf( text, error, argptr ); va_end( argptr ); if( host.type == HOST_NORMAL ) { if( host.hWnd ) ShowWindow( host.hWnd, SW_HIDE ); VID_RestoreGamma(); } if( host.type != HOST_NORMAL || host.developer > 0 ) { Con_ShowConsole( true ); Con_DisableInput(); // disable input line for dedicated server Sys_Print( text ); Sys_WaitForQuit(); } else { Con_ShowConsole( false ); MSGBOX( text ); } Sys_Quit(); }
/* ================ Sys_Error NOTE: we must prepare engine to shutdown before call this ================ */ void Sys_Error( const char *format, ... ) { va_list argptr; char text[MAX_SYSPATH]; DEBUG_BREAK; if( host.state == HOST_ERR_FATAL ) return; // don't execute more than once // make sure that console received last message if( host.change_game ) Sys_Sleep( 200 ); error_on_exit = true; host.state = HOST_ERR_FATAL; va_start( argptr, format ); Q_vsprintf( text, format, argptr ); va_end( argptr ); SV_SysError( text ); if( !Host_IsDedicated() ) { #ifdef XASH_SDL if( host.hWnd ) SDL_HideWindow( host.hWnd ); #endif VID_RestoreGamma(); } if( host.developer > 0 ) { Con_ShowConsole( true ); Con_DisableInput(); // disable input line for dedicated server Sys_Print( text ); // print error message MSGBOX( text ); Sys_WaitForQuit(); } else { Con_ShowConsole( false ); MSGBOX( text ); } Sys_Quit(); }
void CCollectorDlg::OnCollectorClean() { if(MSGBOX(IDS_CLEAN_COLLECTOR, MB_YESNO|MB_ICONQUESTION)==IDYES) { m_edit->SetWindowText(""); if (m_edit==&m_output) { pmf->m_nPopFiltered = 0; //pmf->UpdatePopFiltered(); } } }
void UpdateMyXFireIni(LPVOID dummy) { char request[1024]; char file[1024]; char file2[1024]; char file3[1024]; //ini pfad rausbekommen strcpy(file, XFireGetFoldersPath ("IniFile")); strcpy(file2,file); strcpy(file3,file); strcat(file,"xfire_games.new"); strcat(file2,"xfire_games.ini"); strcat(file3,"xfire_games.old"); mir_snprintf(request,1024,"%s%d",INI_URLREQUEST,getfilesize(file2)); if (CheckWWWContent(request)) { if (db_get_b(NULL,protocolname,"dontaskforupdate",0)==1||DialogBox(hinstance,MAKEINTRESOURCE(IDD_UPDATE),NULL,DlgUpdateDialogProc)==IDOK) { if (GetWWWContent2(request,file,FALSE)) { //altes backup löschen remove(file3); //derzeitige ini und sichern rename(file2,file3); //lösche .old, wenn aktiv if (db_get_b(NULL,protocolname,"nobackupini",0)) remove(file3); //neue aktiv schalten rename(file,file2); if (db_get_b(NULL,protocolname,"dontaskforupdate",0)==0) MSGBOX(Translate("The xfire_games.ini was updated.")); } else MSGBOX(Translate("Error during xfire_games.ini update.")); } } }
/* ================ Sys_Break same as Error ================ */ void Sys_Break( const char *format, ... ) { va_list argptr; char text[MAX_SYSPATH]; DEBUG_BREAK; if( host.state == HOST_ERR_FATAL ) return; // don't multiple executes error_on_exit = true; host.state = HOST_ERR_FATAL; va_start( argptr, format ); Q_vsprintf( text, format, argptr ); va_end( argptr ); if( !Host_IsDedicated() ) { #ifdef XASH_SDL if( host.hWnd ) SDL_HideWindow( host.hWnd ); #endif VID_RestoreGamma(); } if( Host_IsDedicated() || host.developer > 0 ) { Con_ShowConsole( true ); Con_DisableInput(); // disable input line for dedicated server Sys_Print( text ); MSGBOX( text ); Sys_WaitForQuit(); } else { Con_ShowConsole( false ); MSGBOX( text ); } Sys_Quit(); }
void UpdateMyIcons(LPVOID dummy) { char request[1024]; char file[1024]; char file2[1024]; char file3[1024]; //ini pfad rausbekommen strcpy(file,XFireGetFoldersPath ("IconsFile")); strcpy(file2,file); strcpy(file3,file); strcat(file,"icons.new"); strcat(file2,"icons.dll"); strcat(file3,"icons.old"); mir_snprintf(request,1024,"%s%d",ICO_URLREQUEST,getfilesize(file2)); if (CheckWWWContent(request)) { if (db_get_b(NULL,protocolname,"dontaskforupdate",0)==1||MessageBox(NULL,TranslateT("There is a new Icons.dll online, do you want to update now?"),TranslateT(PLUGIN_TITLE),MB_YESNO|MB_ICONQUESTION)==IDYES) { if (GetWWWContent2(request,file,FALSE)) { //altes backup löschen remove(file3); //derzeitige ini und sichern rename(file2,file3); //lösche .old, wenn aktiv if (db_get_b(NULL,protocolname,"nobackupini",0)) remove(file3); //neue aktiv schalten rename(file,file2); if (db_get_b(NULL,protocolname,"dontaskforupdate",0)==0) MSGBOX(Translate("The Icons.dll was updated.")); } else MSGBOX(Translate("Error during Icons.dll Update.")); } } }
/* ================ Sys_Warn Just messagebox ================ */ void Sys_Warn( const char *format, ... ) { va_list argptr; char text[MAX_SYSPATH]; DEBUG_BREAK; va_start( argptr, format ); Q_vsprintf( text, format, argptr ); va_end( argptr ); if( !Host_IsDedicated() ) // dedicated server should not hang on messagebox MSGBOX(text); Msg( "Sys_Warn: %s\n", text ); }
void CCollectorDlg::OnOpenCursorLine() { // TODO: Add your message handler code here and/or call default try{ int nStart, nEnd, nCaret; m_edit->GetSel(nStart,nEnd); int row = m_edit->LineFromChar(nStart); nStart = m_edit->LineIndex(row); nCaret = nEnd - nStart; // char strLine[MAX_LINE_LENGTH+1]; int nLineLength; nLineLength = m_edit->GetLine(row,strLine,MAX_LINE_LENGTH); strLine[nLineLength] = 0; if (strLine[nLineLength-1] == '\r') strLine[nLineLength-1] = 0; else if (strLine[nLineLength-2] == '\r') strLine[nLineLength-2] = 0; // CString strCode; strCode.Empty(); char *p1 = strstr(strLine," => "); char *p2 = strstr(strLine," <= "); if (!p1) strCode = strLine; else if (!p2) strCode = p1 + 4;//move after " => " else { if (strLine + nCaret > p2) strCode = p2 + 4;//move after " <= " else { *p2 = 0; strCode = p1 + 4;//move after " => " } } // strCode.TrimLeft();strCode.TrimRight(); if (!IS_URL(strCode)) MSGBOX(IDS_NOT_VALID_URL); else pmf->NewChildWindow(1,2,strCode); }catch(...){} }
void CCollectorDlg::OnRunScript() { // TODO: Add your message handler code here and/or call default int nStart, nEnd; m_script.GetSel(nStart,nEnd); if (nStart>=nEnd) { MSGBOX(IDS_NOT_SELECT_SCRIPT); return; } if (nStart>=0 && nEnd>=0) { CString strText, strCode; m_script.GetWindowText(strText); strCode = strText.Mid(nStart,nEnd-nStart); if (strCode.GetLength()) pmf->RunScript(strCode); } }
/* ================ Sys_Error NOTE: we must prepare engine to shutdown before call this ================ */ void Sys_Error( const char *error, ... ) { va_list argptr; char text[MAX_SYSPATH]; if( host.state == HOST_ERR_FATAL ) return; // don't multiple executes // make sure what console received last message if( host.change_game ) Sys_Sleep( 200 ); error_on_exit = true; host.state = HOST_ERR_FATAL; va_start( argptr, error ); Q_vsprintf( text, error, argptr ); va_end( argptr ); SV_SysError( text ); if( host.type == HOST_NORMAL ) { if( host.hWnd ) ShowWindow( host.hWnd, SW_HIDE ); VID_RestoreGamma(); } if( host.developer > 0 ) { Con_ShowConsole( true ); Con_DisableInput(); // disable input line for dedicated server Sys_Print( text ); // print error message Sys_WaitForQuit(); } else { Con_ShowConsole( false ); MSGBOX( text ); } Sys_Quit(); }
/* ================= Host_InitCommon ================= */ void Host_InitCommon( const char* moduleName, const char* cmdLine, const char *progname, qboolean bChangeGame ) { char dev_level[4]; char szTemp[MAX_SYSPATH]; string szRootPath; #ifdef _WIN32 MEMORYSTATUS lpBuffer; lpBuffer.dwLength = sizeof( MEMORYSTATUS ); GlobalMemoryStatus( &lpBuffer ); #endif #ifndef __ANDROID__ if( !(SDL_GetBasePath()) ) Sys_Error( "couldn't determine current directory" ); Q_strncpy(host.rootdir, SDL_GetBasePath(), sizeof(host.rootdir)); if( host.rootdir[Q_strlen( host.rootdir ) - 1] == '/' ) host.rootdir[Q_strlen( host.rootdir ) - 1] = 0; #else Q_strncpy(host.rootdir, GAMEPATH, sizeof(host.rootdir)); #endif #ifdef _WIN32 host.oldFilter = SetUnhandledExceptionFilter( Sys_Crash ); host.hInst = GetModuleHandle( NULL ); #endif host.change_game = bChangeGame; host.state = HOST_INIT; // initialzation started host.developer = host.old_developer = 0; CRT_Init(); // init some CRT functions // some commands may turn engine into infinity loop, // e.g. xash.exe +game xash -game xash // so we clearing all cmd_args, but leave dbg states as well if( cmdLine ) Sys_ParseCommandLine( cmdLine ); #ifdef _WIN32 SetErrorMode( SEM_FAILCRITICALERRORS ); // no abort/retry/fail errors #endif host.mempool = Mem_AllocPool( "Zone Engine" ); if( Sys_CheckParm( "-console" )) host.developer = 1; if( Sys_CheckParm( "-dev" )) { if( Sys_GetParmFromCmdLine( "-dev", dev_level )) { if( Q_isdigit( dev_level )) host.developer = abs( Q_atoi( dev_level )); else host.developer++; // -dev == 1, -dev -console == 2 } else host.developer++; // -dev == 1, -dev -console == 2 } host.type = HOST_NORMAL; // predict state host.con_showalways = true; #ifdef PANDORA if( Sys_CheckParm( "-noshouldermb" )) noshouldermb = 1; #endif #ifdef __ANDROID__ if (chdir(host.rootdir) == 0) MsgDev(D_INFO,"%s is working directory now",host.rootdir); else MsgDev(D_ERROR,"%s is not exists",host.rootdir); #else // we can specified custom name, from Sys_NewInstance if( SDL_GetBasePath() && !host.change_game ) { Q_strncpy( szTemp, SDL_GetBasePath(), sizeof(szTemp) ); FS_FileBase( szTemp, SI.ModuleName ); } if(moduleName) Q_strncpy(SI.ModuleName, moduleName, sizeof(SI.ModuleName)); FS_ExtractFilePath( SI.ModuleName, szRootPath ); if( Q_stricmp( host.rootdir, szRootPath )) { Q_strncpy( host.rootdir, szRootPath, sizeof( host.rootdir )); #ifdef _WIN32 SetCurrentDirectory( host.rootdir ); #else chdir( host.rootdir ); #endif } #endif if( SI.ModuleName[0] == '#' ) host.type = HOST_DEDICATED; // determine host type if( progname[0] == '#' ) { Q_strncpy( SI.ModuleName, progname + 1, sizeof( SI.ModuleName )); host.type = HOST_DEDICATED; } else Q_strncpy( SI.ModuleName, progname, sizeof( SI.ModuleName )); if( host.type == HOST_DEDICATED ) { // check for duplicate dedicated server host.hMutex = SDL_CreateMutex( ); if( !host.hMutex ) { MSGBOX( "Dedicated server already running" ); Sys_Quit(); return; } Sys_MergeCommandLine( cmdLine ); SDL_DestroyMutex( host.hMutex ); host.hMutex = SDL_CreateSemaphore( 0 ); if( host.developer < 3 ) host.developer = 3; // otherwise we see empty console } else { // don't show console as default if( host.developer < D_WARN ) host.con_showalways = false; } host.old_developer = host.developer; Con_CreateConsole(); // first text message into console or log MsgDev( D_NOTE, "Sys_LoadLibrary: Loading xash.dll - ok\n" ); // startup cmds and cvars subsystem Cmd_Init(); Cvar_Init(); // share developer level across all dlls Q_snprintf( dev_level, sizeof( dev_level ), "%i", host.developer ); Cvar_Get( "developer", dev_level, CVAR_INIT, "current developer level" ); Cmd_AddCommand( "exec", Host_Exec_f, "execute a script file" ); Cmd_AddCommand( "memlist", Host_MemStats_f, "prints memory pool information" ); FS_Init(); Image_Init(); Sound_Init(); FS_LoadGameInfo( NULL ); Q_strncpy( host.gamefolder, GI->gamefolder, sizeof( host.gamefolder )); if( GI->secure ) { // clear all developer levels when game is protected Cvar_FullSet( "developer", "0", CVAR_INIT ); host.developer = host.old_developer = 0; host.con_showalways = false; } HPAK_Init(); IN_Init(); Key_Init(); }
HRESULT Engine::CGraphicDevice::Initialize(_ulong x, _ulong y, _bool fullsize, HWND hWnd) { _ulong createDeviceFlags = 0; m_iWinSize[0] = x; m_iWinSize[1] = y; m_bFullSize = fullsize; m_hWnd = hWnd; #if defined(DEBUG) || defined(_DEBUG) createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; #endif D3D_FEATURE_LEVEL featureLevel; HRESULT hr = D3D11CreateDevice( 0, //무슨 어뎁터를 사용할 것인가? 0번은 Default D3D_DRIVER_TYPE_HARDWARE, //3D가속을 사용한다. 나머지는 잘 사용 안할듯 0, //소프트웨어 구동기 지정? 무쓸모 createDeviceFlags, //Debug일시, 위 플래그 해주면 디버그 메세지 수신가능. 0, 0, //피쳐레벨 디폴트? D3D11_SDK_VERSION, &m_pDevice, &featureLevel, //지원되는 기능을 넣어주는듯. &m_pContext ); if (FAILED(hr)) { MSGBOX(L"GraphicDevice Create Failed."); return E_FAIL; } if (featureLevel != D3D_FEATURE_LEVEL_11_0) { MSGBOX(L"Feature Level 11 Unsupported."); return E_FAIL; } //Device 생성 _uint iMsaaQuality; hr = m_pDevice->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, 4, &iMsaaQuality); if (FAILED(hr)) { MSGBOX(L"MultiSampling Check Failed."); return E_FAIL; } assert(iMsaaQuality > 0); //멀티 샘플링 지원여부 확인 //A four-component, 32-bit unsigned-normalized-integer //format that supports 8 bits per channel including alpha. DXGI_SWAP_CHAIN_DESC chainDesc; chainDesc.BufferDesc.Width = m_iWinSize[0]; chainDesc.BufferDesc.Height = m_iWinSize[1]; chainDesc.BufferDesc.RefreshRate.Numerator = 60; chainDesc.BufferDesc.RefreshRate.Denominator = 1; chainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; chainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; chainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; if (m_bEnableMsaa == true) { chainDesc.SampleDesc.Count = 4; chainDesc.SampleDesc.Quality = iMsaaQuality - 1; } else { chainDesc.SampleDesc.Count = 1; chainDesc.SampleDesc.Quality = 0; } chainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; chainDesc.BufferCount = 1; chainDesc.OutputWindow = m_hWnd; chainDesc.Windowed = m_bFullSize; chainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; chainDesc.Flags = 0; //스왑체인 구조체 정의 IDXGIDevice* pDxgiDevice = NULL; HR(m_pDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&pDxgiDevice)); IDXGIAdapter* pDxgiAdapter = NULL; HR(pDxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)pDxgiAdapter)); IDXGIFactory* pDxgiFactory = NULL; HR(pDxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&pDxgiFactory)); HR(pDxgiFactory->CreateSwapChain(m_pDevice, &chainDesc, &m_pSwapChain)); ReleaseCOM(pDxgiDevice); ReleaseCOM(pDxgiAdapter); ReleaseCOM(pDxgiFactory); //스왑체인 생성 끝 ID3D11Texture2D* backBuffer; //스왑체인으로부터 받아온 백버퍼 포인터. m_pSwapChain->GetBuffer(0, _uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBuffer)); m_pDevice->CreateRenderTargetView(backBuffer, 0, &m_pRenderTargetView); ReleaseCOM(backBuffer);//GetBuffer시에 Ref가 1 추가되므로 Release. D3D11_TEXTURE2D_DESC depthStencilDesc; depthStencilDesc.Width = m_iWinSize[0]; depthStencilDesc.Height = m_iWinSize[1]; depthStencilDesc.MipLevels = 1; depthStencilDesc.ArraySize = 1; depthStencilDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; if (m_bEnableMsaa == true) { depthStencilDesc.SampleDesc.Count = 4; depthStencilDesc.SampleDesc.Quality = iMsaaQuality - 1; } else { depthStencilDesc.SampleDesc.Count = 1; depthStencilDesc.SampleDesc.Quality = 0; } depthStencilDesc.Usage = D3D11_USAGE_DEFAULT; depthStencilDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL; depthStencilDesc.CPUAccessFlags = 0; depthStencilDesc.MiscFlags = 0; HR(m_pDevice->CreateTexture2D(&depthStencilDesc, 0, &m_pDepthStencilBuffer)); HR(m_pDevice->CreateDepthStencilView(m_pDepthStencilBuffer, 0, &m_pDepthStencilView)); m_pContext->OMSetRenderTargets(1, &m_pRenderTargetView, m_pDepthStencilView); m_tScreenViewport.TopLeftX = 0.f; m_tScreenViewport.TopLeftY = 0.f; m_tScreenViewport.Width = static_cast<float>(m_iWinSize[0]); m_tScreenViewport.Height = static_cast<float>(m_iWinSize[1]); m_tScreenViewport.MinDepth = 0.f; m_tScreenViewport.MaxDepth = 0.f; m_pContext->RSSetViewports(1, &m_tScreenViewport); return S_OK; }
BOOL CTxtDropTarget::OnDrop(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point) { try{ CString strMsg; // HGLOBAL hData=pDataObject->GetGlobalData(CF_TEXT); if (hData) { LPCSTR lpcszData=(LPCSTR)GlobalLock(hData); GlobalUnlock(hData); //if it is a link HGLOBAL hLinkData=pDataObject->GetGlobalData(RegisterClipboardFormat("FileGroupDescriptor")); LPCSTR lpcszLink; if(hLinkData) { lpcszLink=((LPCSTR)GlobalLock(hLinkData)) + 76; strMsg = lpcszLink; strMsg = strMsg.Left(strMsg.GetLength()-4);//cut .url of abc.url strMsg += " => "; strMsg += lpcszData; GlobalUnlock(hLinkData); } else strMsg += lpcszData; strMsg += "\r\n"; SaveText(strMsg, 0); } else { hData=pDataObject->GetGlobalData(CF_HDROP); if (!hData) { TRACE("Fail in getting data\n"); MSGBOX(IDS_NOT_DROP_IMG); return FALSE; } HDROP hdrop =(HDROP)GlobalLock(hData); DragQueryFile(hdrop, 0, g_szFile, 1024); GlobalUnlock(hData); CString filename, rfile; filename = g_szFile; int l = filename.ReverseFind('\\'); filename = filename.Mid(l+1); //fix filename, remove [x] l = filename.ReverseFind('['); int i = filename.ReverseFind(']'); CString ext = filename.Mid(i+1); filename = filename.Left(l); //? CString imgPath = ((CVeryIEApp*)AfxGetApp())->m_strImagePath; if(pmf->m_bImgCateWithSite) { CString site; CChildFrame* tcf = (CChildFrame*)pmf->MDIGetActive(); site = tcf->m_pView->m_lpszUrl; pmf->GetSiteName(site); imgPath = imgPath + site + "\\"; } //create dir _CreateFullDir(imgPath); filename = imgPath + filename; //compare file size DWORD sz1=0, sz2=0; HANDLE hfile = INVALID_HANDLE_VALUE; hfile = CreateFile(g_szFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if(hfile != INVALID_HANDLE_VALUE) sz1 = GetFileSize(hfile, NULL); CloseHandle(hfile); hfile = INVALID_HANDLE_VALUE; hfile = CreateFile(filename+ext, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if(hfile != INVALID_HANDLE_VALUE) sz2 = GetFileSize(hfile, NULL); CloseHandle(hfile); rfile = filename + ext; if (sz1==0)//img not show { MSGBOX(IDS_SAVEIMAGEFAIL); return TRUE; } else if (sz1==sz2)//exist the same file { LOADSTR(strMsg ,IDS_IMG_EXISTED); strMsg += rfile; pmf->SetMessageText(strMsg);//SaveText(strMsg,13); return TRUE; } else if(sz1!=sz2 && sz2!=0) { char tmp[4]; l = 0; HFILE hf; OFSTRUCT of; hf = OpenFile(rfile, &of, OF_EXIST); while(hf!=HFILE_ERROR) { l++; rfile = filename; rfile += '['; itoa(l, tmp, 10); rfile += tmp; rfile += ']'; rfile += ext; hf = OpenFile(rfile, &of, OF_EXIST); } } //copy files if(!CopyFile(g_szFile, rfile, FALSE)) { DWORD dwError = GetLastError(); if(dwError == ERROR_PATH_NOT_FOUND) MSGBOX(IDS_SAVEIMAGEFAIL); } else { LOADSTR(strMsg ,IDS_IMG_SAVE_TO); strMsg += rfile; // CChildFrame* tcf = (CChildFrame*)pmf->MDIGetActive(); strMsg += " <= "; strMsg += tcf->m_pView->m_lpszUrl; // SaveText(strMsg,13); } } }catch(...){} return TRUE; }
void CGroupSelectDlg::OnOK() { // TODO: Add extra validation here int oldCount=0; BOOL r = TRUE; CString filename; m_name.GetWindowText(filename); int pos = filename.FindOneOf(STR_ERR_PATH_CHAR); if (pos>=0) { MSGBOX(IDS_GROUPNAME_ERROR); return; } // char state[10]="state",name[9]="name",url[8]="url",download[13]="download"; // x+5 char num[15]; filename = theApp.m_strGroupPath + filename+".cgp"; //get old count char tmp[INTERNET_MAX_PATH_LENGTH]; while(r) { itoa(oldCount, name+4, 10); itoa(oldCount, url+3, 10); r = ::GetPrivateProfileString("Group", name, NULL, tmp, INTERNET_MAX_PATH_LENGTH, filename); if (!r) break; oldCount++; } // if (oldCount<1) { r = WritePrivateProfileSection("Group", NULL, filename); if (!r) { if (!_FileIsExist(theApp.m_strGroupPath)) MSGBOX(IDS_GROUP_NOT_EXIST); else MSGBOX(IDS_GROUPNAME_ERROR); return; } } //write new item int i,count = m_list.GetItemCount(); int index=0; for (i=0;i<count;i++) { if (m_list.GetCheck(i)) { itoa(index+oldCount, state+5, 10); itoa(index+oldCount, name+4, 10); itoa(index+oldCount, url+3, 10); itoa(index+oldCount, download+8, 10); //::WritePrivateProfileString("Group", state, "1", filename); ::WritePrivateProfileString("Group", name, m_list.GetItemText(i,0), filename); ::WritePrivateProfileString("Group", url, m_list.GetItemText(i,1), filename); if (m_list.GetItemData(i) != DEFAULT_PROPERTY) { ultoa( m_list.GetItemData(i), num, 10); ::WritePrivateProfileString("Group", download, num, filename); } // index++; } } CDialog::OnOK(); }
void Sys_Crash( int signal, siginfo_t *si, void *context) { void *trace[32]; char message[1024], stackframe[256]; int len, stacklen, logfd, i = 0; ucontext_t *ucontext = (ucontext_t*)context; #if __i386__ #ifdef __FreeBSD__ void *pc = (void*)ucontext->uc_mcontext.mc_eip, **bp = (void**)ucontext->uc_mcontext.mc_ebp, **sp = (void**)ucontext->uc_mcontext.mc_esp; #elif __NetBSD__ void *pc = (void*)ucontext->uc_mcontext.__gregs[REG_EIP], **bp = (void**)ucontext->uc_mcontext.__gregs[REG_EBP], **sp = (void**)ucontext->uc_mcontext.__gregs[REG_ESP]; #elif __OpenBSD__ void *pc = (void*)sc_eip, **bp = (void**)sc_ebp, **sp = (void**)sc_esp; #else void *pc = (void*)ucontext->uc_mcontext.gregs[REG_EIP], **bp = (void**)ucontext->uc_mcontext.gregs[REG_EBP], **sp = (void**)ucontext->uc_mcontext.gregs[REG_ESP]; #endif #elif defined (__arm__) // arm not tested void *pc = (void*)ucontext->uc_mcontext.arm_pc, **bp = (void*)ucontext->uc_mcontext.arm_r10, **sp = (void*)ucontext->uc_mcontext.arm_sp; #endif // Safe actions first, stack and memory may be corrupted #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) len = snprintf(message, 1024, "Sys_Crash: signal %d, err %d with code %d at %p\n", signal, si->si_errno, si->si_code, si->si_addr); #else len = snprintf(message, 1024, "Sys_Crash: signal %d, err %d with code %d at %p %p\n", signal, si->si_errno, si->si_code, si->si_addr, si->si_ptr); #endif write(2, message, len); // Flush buffers before writing directly to descriptors fflush( stdout ); fflush( stderr ); // Now get log fd and write trace directly to log logfd = Sys_LogFileNo(); write( logfd, message, len ); write( 2, "Stack backtrace:\n", 17 ); write( logfd, "Stack backtrace:\n", 17 ); strncpy(message + len, "Stack backtrace:\n", 1024 - len); len += 17; long pagesize = sysconf(_SC_PAGESIZE); do { int line = printframe( message + len, 1024 - len, ++i, pc); write( 2, message + len, line ); write( logfd, message + len, line ); len += line; //if( !dladdr(bp,0) ) break; // Only when bp is in module if( mprotect((char *)(((int) bp + pagesize-1) & ~(pagesize-1)), pagesize, PROT_READ) == -1) break; if( mprotect((char *)(((int) bp[0] + pagesize-1) & ~(pagesize-1)), pagesize, PROT_READ) == -1) break; pc = bp[1]; bp = (void**)bp[0]; } while (bp); // Try to print stack write( 2, "Stack dump:\n", 12 ); write( logfd, "Stack dump:\n", 12 ); strncpy(message + len, "Stack dump:\n", 1024 - len); len += 12; if( mprotect((char *)(((int) sp + pagesize-1) & ~(pagesize-1)), pagesize, PROT_READ) != -1) for( i = 0; i < 32; i++ ) { int line = printframe( message + len, 1024 - len, i, sp[i] ); write( 2, message + len, line ); write( logfd, message + len, line ); len += line; } // Put MessageBox as Sys_Error Msg( message ); #ifdef XASH_SDL SDL_SetWindowGrab(host.hWnd, false); //SDL_MouseQuit(); MSGBOX( message ); #endif // Log saved, now we can try to save configs and close log correctly, it may crash if( host.type == HOST_NORMAL ) CL_Crashed(); host.state = HOST_CRASHED; error_on_exit = true; host.crashed = true; Con_DestroyConsole(); Sys_Quit(); }
//type: //0: text collector //11: filter //12: page //13: img void CTxtDropTarget::SaveText(CString str, int type) { CString strTime; if (pmf->m_bOutputSaveTime) { SYSTEMTIME time; ::GetLocalTime(&time); strTime.Format("[%02d/%02d-%02d:%02d:%02d] ",time.wMonth,time.wDay,time.wHour,time.wMinute,time.wSecond); } if (type==0) { if (strTime.GetLength()) str = strTime + "\r\n" + str; } else { str = strTime + str; pmf->SetMessageText(str); } // str += "\r\n"; CEdit *edit; CString strfile; // if (type==0) { edit = &(pmf->m_pCollectDlg->m_txt); strfile = theApp.m_strUser+"CollectorText.txt"; if(pmf->m_pCollectDlg) pmf->m_pCollectDlg->OnCollectorTxt(); } else { if (type==11 && !pmf->m_bOutputSaveFilter) return; else if (type==12 && !pmf->m_bOutputSavePage) return; else if (type==13 && !pmf->m_bOutputSaveImg) return; else if (type==14 && !pmf->m_bOutputSaveText) return; else if (type==15 && !pmf->m_bOutputSaveUrlFilter) return; edit = &(pmf->m_pCollectDlg->m_output); strfile = theApp.m_strUser+"CollectorOutput.txt"; if(pmf->m_pCollectDlg) pmf->m_pCollectDlg->OnCollectorOutput(); } // if(pmf->m_pCollectDlg) { int len = edit->GetWindowTextLength( ); if (len>=MAX_COLLECTOR) { if (type==0) MSGBOX(IDS_MAX_COLLECTOR_TXT); else if (type==1) MSGBOX(IDS_MAX_COLLECTOR_OUTPUT); else MSGBOX(IDS_MAX_COLLECTOR_SCRIPT); return; } else { if (pmf->m_bCollectorAddtoBottom) edit->SetSel(len, len); else edit->SetSel(0,0); edit->ReplaceSel(str); } } else { CFile f; if(f.Open(strfile, CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite|CFile::shareDenyNone)) { f.SeekToBegin(); f.Write((void*)(LPCSTR)str, str.GetLength()); f.Close(); } } }