From 138d22a254d55724efa9587ce3d53fbed491d04f Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Wed, 20 May 2015 07:08:03 +0200 Subject: Windows: remove crash dump analysis functionality. It didn't always work and it required external debugging tools. --- src/Mount/Mount.c | 510 ------------------------------------------------------ 1 file changed, 510 deletions(-) (limited to 'src/Mount/Mount.c') diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 1288f8df..36204fc9 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -107,8 +107,6 @@ BOOL bDisplayBalloonOnSuccessfulHkDismount = TRUE; BOOL bHibernationPreventionNotified = FALSE; /* TRUE if the user has been notified that hibernation was prevented (system encryption) during the session. */ BOOL bHiddenSysLeakProtNotifiedDuringSession = FALSE; /* TRUE if the user has been notified during the session that unencrypted filesystems and non-hidden TrueCrypt volumes are mounted as read-only under hidden OS. */ BOOL CloseSecurityTokenSessionsAfterMount = FALSE; -BOOL DisableSystemCrashDetection = FALSE; -BOOL SystemCrashDetected = FALSE; BOOL Quit = FALSE; /* Exit after processing command line */ BOOL ComServerMode = FALSE; @@ -691,7 +689,6 @@ void LoadSettings (HWND hwndDlg) mountOptions = defaultMountOptions; CloseSecurityTokenSessionsAfterMount = ConfigReadInt ("CloseSecurityTokenSessionsAfterMount", 0); - DisableSystemCrashDetection = ConfigReadInt ("DisableSystemCrashDetection", FALSE); if (IsHiddenOSRunning()) HiddenSysLeakProtectionNotificationStatus = ConfigReadInt ("HiddenSystemLeakProtNotifStatus", TC_HIDDEN_OS_READ_ONLY_NOTIF_MODE_NONE); @@ -795,7 +792,6 @@ void SaveSettings (HWND hwndDlg) ConfigWriteString ("LastSelectedDrive", szTmp); ConfigWriteInt ("CloseSecurityTokenSessionsAfterMount", CloseSecurityTokenSessionsAfterMount); - ConfigWriteInt ("DisableSystemCrashDetection", DisableSystemCrashDetection); // Hotkeys ConfigWriteInt ("HotkeyModAutoMountDevices", Hotkeys[HK_AUTOMOUNT_DEVICES].vKeyModifiers); @@ -5730,56 +5726,6 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } } - if (!DisableSystemCrashDetection - && IsOSAtLeast (WIN_7)) - { - // Auto-detect a system crash - - const int detectionPeriodInMonthsSinceReleaseDate = 2; - int maxYear = TC_RELEASE_DATE_YEAR; - int maxMonth = TC_RELEASE_DATE_MONTH + detectionPeriodInMonthsSinceReleaseDate; - if (maxMonth > 12) - { - ++maxYear; - maxMonth -= 12; - } - - SYSTEMTIME systemTime; - GetSystemTime (&systemTime); - - if (systemTime.wYear >= TC_RELEASE_DATE_YEAR - && !(systemTime.wYear == TC_RELEASE_DATE_YEAR && systemTime.wMonth < TC_RELEASE_DATE_MONTH) - && systemTime.wYear <= maxYear - && !(systemTime.wYear == maxYear && systemTime.wMonth > maxMonth)) - { - char winDir[MAX_PATH] = { 0 }; - GetWindowsDirectory (winDir, sizeof (winDir)); - - WIN32_FIND_DATA findData; - HANDLE find = FindFirstFile ((string (winDir) + "\\MEMORY.DMP").c_str(), &findData); - - if (find != INVALID_HANDLE_VALUE) - { - SYSTEMTIME systemTime; - FILETIME ft; - GetSystemTime (&systemTime); - SystemTimeToFileTime (&systemTime, &ft); - - ULARGE_INTEGER sysTime, fileTime; - sysTime.HighPart = ft.dwHighDateTime; - sysTime.LowPart = ft.dwLowDateTime; - fileTime.HighPart = findData.ftLastWriteTime.dwHighDateTime; - fileTime.LowPart = findData.ftLastWriteTime.dwLowDateTime; - - // Memory dump must not be older than 10 minutes - if (sysTime.QuadPart - fileTime.QuadPart < 10I64 * 1000 * 1000 * 60 * 10) - SystemCrashDetected = TRUE; - - FindClose (find); - } - } - } - if (TaskBarIconMutex != NULL) RegisterWtsNotification(hwndDlg); DoPostInstallTasks (hwndDlg); @@ -5892,30 +5838,6 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if (TaskBarIconMutex != NULL) { - // Handle system crash - static BOOL systemCrashHandlerLocked = FALSE; - if (SystemCrashDetected && !systemCrashHandlerLocked) - { - systemCrashHandlerLocked = TRUE; - - SetForegroundWindow (hwndDlg); - MainWindowHidden = FALSE; - ShowWindow (hwndDlg, SW_SHOW); - ShowWindow (hwndDlg, SW_RESTORE); - - if (AskYesNoTopmost ("SYSTEM_CRASHED_ASK_REPORT", hwndDlg) == IDYES) - { - if (!IsAdmin() && IsUacSupported()) - UacAnalyzeKernelMiniDump (hwndDlg); - else - AnalyzeKernelMiniDump (hwndDlg); - } - else if (AskYesNoTopmost ("ASK_KEEP_DETECTING_SYSTEM_CRASH", hwndDlg) == IDNO) - { - DisableSystemCrashDetection = TRUE; - SaveSettings (hwndDlg); - } - } // Idle auto-dismount if (MaxVolumeIdleTime > 0) @@ -6971,15 +6893,6 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa Applink ("history", TRUE, ""); return 1; } - else if (lw == IDM_ANALYZE_SYSTEM_CRASH) - { - if (!IsAdmin() && IsUacSupported()) - UacAnalyzeKernelMiniDump (hwndDlg); - else - AnalyzeKernelMiniDump (hwndDlg); - - return 1; - } else if (lw == IDM_CONTACT) { Applink ("contact", FALSE, ""); @@ -9677,429 +9590,6 @@ void MountSelectedVolume (HWND hwndDlg, BOOL mountWithOptions) Warning ("SELECT_FREE_DRIVE", hwndDlg); } - -BOOL GetExecutableImageInformation (const string &path, string &version, string &description, string &companyName, string &productName) -{ - DWORD handle; - DWORD size = GetFileVersionInfoSize (path.c_str(), &handle); - if (size == 0) - return FALSE; - - void *buf = err_malloc (size); - finally_do_arg (void*, buf, { free (finally_arg); }); - - if (!GetFileVersionInfo (path.c_str(), handle, size, buf)) - return FALSE; - - version = description = companyName = productName = ""; - - UINT varSize; - VS_FIXEDFILEINFO *fileInfo; - if (VerQueryValue (buf, "\\", (LPVOID *) &fileInfo, &varSize) && varSize > 0) - { - stringstream s; - s << HIWORD (fileInfo->dwFileVersionMS) << '.' << LOWORD (fileInfo->dwFileVersionMS) << '.' << HIWORD (fileInfo->dwFileVersionLS) << '.' << LOWORD (fileInfo->dwFileVersionLS); - version = s.str(); - } - - DWORD *langCodes; - if (VerQueryValue (buf, "\\VarFileInfo\\Translation", (LPVOID *) &langCodes, &varSize) && varSize >= sizeof (DWORD)) - { - char prefix[128]; - sprintf_s (prefix, sizeof (prefix), "\\StringFileInfo\\%04x%04x\\", LOWORD (langCodes[0]), HIWORD (langCodes[0])); - - char *str; - if (VerQueryValue (buf, (string (prefix) + "FileDescription").c_str(), (LPVOID *) &str, &varSize) && varSize > 0) - description = str; - - if (VerQueryValue (buf, (string (prefix) + "CompanyName").c_str(), (LPVOID *) &str, &varSize) && varSize > 0) - companyName = str; - - if (VerQueryValue (buf, (string (prefix) + "ProductName").c_str(), (LPVOID *) &str, &varSize) && varSize > 0) - productName = str; - } - - return TRUE; -} - - -void AnalyzeKernelMiniDump (HWND hwndDlg) -{ - char winDir[MAX_PATH] = { 0 }; - GetWindowsDirectory (winDir, sizeof (winDir)); - string memDumpPath = string (winDir) + "\\MEMORY.DMP"; - string tmpDumpPath; - - string dumpPath = FindLatestFileOrDirectory (string (winDir) + "\\Minidump", "*.dmp", false, true); - if (dumpPath.empty()) - { - Error ("NO_MINIDUMP_FOUND", hwndDlg); - return; - } - - WIN32_FIND_DATA findData; - HANDLE find = FindFirstFile (memDumpPath.c_str(), &findData); - - if (find != INVALID_HANDLE_VALUE) - { - ULARGE_INTEGER memDumpTime, miniDumpTime; - memDumpTime.HighPart = findData.ftLastWriteTime.dwHighDateTime; - memDumpTime.LowPart = findData.ftLastWriteTime.dwLowDateTime; - - FindClose (find); - - find = FindFirstFile (dumpPath.c_str(), &findData); - if (find != INVALID_HANDLE_VALUE) - { - miniDumpTime.HighPart = findData.ftLastWriteTime.dwHighDateTime; - miniDumpTime.LowPart = findData.ftLastWriteTime.dwLowDateTime; - - if (_abs64 (miniDumpTime.QuadPart - memDumpTime.QuadPart) < 10I64 * 1000 * 1000 * 60 * 5) - { - // Rename MEMORY.DMP file first as it can be deleted by Windows when system crash dialog is closed - tmpDumpPath = memDumpPath + ".hd_crypt.dmp"; // Application name must be mangled to avoid interfering with crash analysis - - if (MoveFile (memDumpPath.c_str(), tmpDumpPath.c_str())) - dumpPath = tmpDumpPath; - else - tmpDumpPath.clear(); - } - - FindClose (find); - } - } - - finally_do_arg2 (string, tmpDumpPath, string, memDumpPath, - { - if (!finally_arg.empty()) - { - if (AskYesNo ("ASK_DELETE_KERNEL_CRASH_DUMP", MainDlg) == IDYES) - DeleteFile (finally_arg.c_str()); - else - MoveFile (finally_arg.c_str(), finally_arg2.c_str()); - } - }); - - STARTUPINFO startupInfo; - PROCESS_INFORMATION procInfo; - - ZeroMemory (&startupInfo, sizeof (startupInfo)); - ZeroMemory (&procInfo, sizeof (procInfo)); - - if (!IsApplicationInstalled (Is64BitOs() ? "Debugging Tools for Windows (x64)" : "Debugging Tools for Windows (x86)")) - { - string sDbgCmd; - if (AskOkCancel ("ASK_DEBUGGER_INSTALL", hwndDlg) != IDOK) - return; - - if (Is64BitOs()) - sDbgCmd = "msiexec.exe /qb /i https://www.idrix.fr/Root/MSDebug/dbg_amd64_6.11.1.404.msi"; - else - sDbgCmd = "msiexec.exe /qb /i https://www.idrix.fr/Root/MSDebug/dbg_x86_6.11.1.404.msi"; - - if (!CreateProcess (NULL, (LPSTR) sDbgCmd.c_str(), - NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &procInfo)) - { - handleWin32Error (hwndDlg); - return; - } - - WaitCursor(); - WaitForSingleObject (procInfo.hProcess, INFINITE); - NormalCursor(); - - DWORD exitCode; - bool bExitCheck = (!GetExitCodeProcess (procInfo.hProcess, &exitCode) || exitCode != 0); - - CloseHandle(procInfo.hProcess); - CloseHandle(procInfo.hThread); - - if (bExitCheck) - return; - } - - if (AskOkCancel ("SYSTEM_CRASH_ANALYSIS_INFO", hwndDlg) == IDCANCEL) - return; - - ZeroMemory (&startupInfo, sizeof (startupInfo)); - ZeroMemory (&procInfo, sizeof (procInfo)); - - SECURITY_ATTRIBUTES securityAttrib; - securityAttrib.bInheritHandle = TRUE; - securityAttrib.nLength = sizeof (securityAttrib); - securityAttrib.lpSecurityDescriptor = NULL; - - HANDLE hChildStdoutWrite = INVALID_HANDLE_VALUE; - HANDLE hChildStdoutRead = INVALID_HANDLE_VALUE; - if (!CreatePipe (&hChildStdoutRead, &hChildStdoutWrite, &securityAttrib, 0)) - { - handleWin32Error (hwndDlg); - return; - } - SetHandleInformation (hChildStdoutRead, HANDLE_FLAG_INHERIT, 0); - - startupInfo.hStdInput = INVALID_HANDLE_VALUE; - startupInfo.hStdOutput = hChildStdoutWrite; - startupInfo.cb = sizeof (startupInfo); - startupInfo.hStdError = hChildStdoutWrite; - startupInfo.dwFlags |= STARTF_USESTDHANDLES; - - list kdPaths; - string kdPath; - char progPath[MAX_PATH]; - if (SHGetSpecialFolderPath (hwndDlg, progPath, CSIDL_PROGRAM_FILES, FALSE)) - { - if (Is64BitOs()) - { - string s = progPath; - size_t p = s.find (" (x86)"); - if (p != string::npos) - { - s = s.substr (0, p); - if (_access (s.c_str(), 0) != -1) - strcpy_s (progPath, sizeof (progPath), s.c_str()); - } - } - - kdPath = string (progPath) + "\\Debugging Tools for Windows (" + (Is64BitOs() ? "x64" : "x86") + ")\\kd.exe"; - kdPaths.push_back (kdPath); - } - - kdPath = FindLatestFileOrDirectory (string (winDir).substr (0, 1) + ":\\WinDDK", "*", true, false); - kdPath += "\\Debuggers\\kd.exe"; - kdPaths.push_back (kdPath); - - kdPaths.push_back ("kd.exe"); - - bool kdRunning = false; - foreach (const string &kdPath, kdPaths) - { - if (CreateProcess (NULL, (LPSTR) ("\"" + kdPath + "\" -z \"" + dumpPath + "\" -y http://msdl.microsoft.com/download/symbols -c \".bugcheck; !analyze -v; q\"").c_str(), - NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &startupInfo, &procInfo)) - { - kdRunning = true; - break; - } - } - - if (!kdRunning) - { - handleWin32Error (hwndDlg); - Error ("DEBUGGER_NOT_FOUND", hwndDlg); - CloseHandle (procInfo.hProcess); - CloseHandle (procInfo.hThread); - CloseHandle (hChildStdoutRead); - CloseHandle (hChildStdoutWrite); - return; - } - - EnableElevatedCursorChange (hwndDlg); - WaitCursor(); - - CloseHandle (procInfo.hProcess); - CloseHandle (procInfo.hThread); - CloseHandle (hChildStdoutWrite); - - string output; - BOOL bIsValidResponse = TRUE; - - while (TRUE) - { - DWORD bytesReceived = 0, i; - char pipeBuffer [4096] = {0}; - - unsigned char uc; - - if (!ReadFile (hChildStdoutRead, pipeBuffer, sizeof (pipeBuffer), &bytesReceived, NULL)) - break; - - /* check if the buffer contains printable characters only*/ - for (i = 0; i < bytesReceived; i++) - { - uc = (unsigned char) pipeBuffer [i]; - if ( uc >= 0x7f || uc < 0x20) // A non-ASCII or non-printable character? - { - bIsValidResponse = FALSE; - break; - } - } - - if (!bIsValidResponse) - break; - - output.insert (output.size(), pipeBuffer, bytesReceived); - } - - CloseHandle (hChildStdoutRead); - - NormalCursor(); - - if (!bIsValidResponse) - { - Error ("ERR_PARAMETER_INCORRECT", hwndDlg); - return; - } - - bool otherDriver = (StringToUpperCase (output).find (StringToUpperCase (TC_APP_NAME)) == string::npos); - - size_t p, p2; - while ((p = output.find ('`')) != string::npos) - output.erase (output.begin() + p); - - p = output.find ("Bugcheck code "); - if (p == string::npos) - { - Error ("ERR_PARAMETER_INCORRECT", hwndDlg); - return; - } - - uint64 bugcheckCode; - int n = sscanf (output.substr (p + 14, 8).c_str(), "%I64uX", &bugcheckCode); - if (n != 1) - { - Error ("ERR_PARAMETER_INCORRECT", hwndDlg); - return; - } - - p = output.find ("Arguments ", p); - - uint64 bugcheckArgs[4]; - n = sscanf (output.substr (p + 10, (Is64BitOs() ? 17 : 9) * 4).c_str(), "%I64uX %I64uX %I64uX %I64uX", &bugcheckArgs[0], &bugcheckArgs[1], &bugcheckArgs[2], &bugcheckArgs[3]); - if (n != 4) - { - Error ("ERR_PARAMETER_INCORRECT", hwndDlg); - return; - } - - // Image name - string imageName, imageVersion; - p = output.find ("IMAGE_NAME:"); - if (p != string::npos) - { - p += 13; - p2 = output.find ('\n', p); - if (p2 != string::npos) - imageName = output.substr (p, p2 - p); - } - - // Stack trace - p = output.find ("STACK_TEXT:"); - if (p == string::npos) - { - Error ("ERR_PARAMETER_INCORRECT", hwndDlg); - return; - } - - p2 = output.find ("FOLLOWUP_IP:", p); - if (p2 == string::npos) - p2 = output.find ("STACK_COMMAND:", p); - if (p2 == string::npos) - p2 = output.size(); - - output = output.substr (p, p2 - p); - - list retAddrs; - p = 0; - while ((p = output.find ("+", p)) != string::npos) - { - size_t p1 = output.rfind (" ", p); - if (p1 == string::npos) - break; - - p = output.find ('\n', p); - if (p == string::npos) - p = output.size() - 1; - - string s = output.substr (p1 + 1, p - p1 - 1); - - if (s.find ('(') == 0) - s = s.substr (1); - if (s.rfind (')') == s.size() - 1) - s = s.substr (0, s.size() - 1); - - retAddrs.push_back (s); - } -/* - char url[MAX_URL_LENGTH]; - sprintf (url, TC_APPLINK_SECURE "&dest=syserr-report&os=%s&osver=%d.%d.%d&arch=%s&err=%I64x&arg1=%I64x&arg2=%I64x&arg3=%I64x&arg4=%I64x&flag=%s&drv=%s", - GetWindowsEdition().c_str(), - CurrentOSMajor, - CurrentOSMinor, - CurrentOSServicePack, - Is64BitOs() ? "x64" : "x86", - bugcheckCode, - bugcheckArgs[0], - bugcheckArgs[1], - bugcheckArgs[2], - bugcheckArgs[3], - otherDriver ? "0" : "1", - imageName.empty() ? "-" : imageName.c_str() - ); -*/ - stringstream stackTraceArgs; - int i = 0; - foreach (const string &retAddr, retAddrs) - { - stackTraceArgs << "&st" << i++ << "=" << retAddr; - } - - wstring msg; - - if (!imageName.empty() && StringToUpperCase (imageName) != StringToUpperCase (TC_APP_NAME) + ".SYS") - { - msg += wstring (GetString ("SYSTEM_CRASH_UPDATE_DRIVER")) + L"\n\n" + SingleStringToWide (imageName); - - string description, company, product; - if (GetExecutableImageInformation (string (winDir) + "\\System32\\drivers\\" + imageName, imageVersion, description, company, product)) - { - string s; - if (!description.empty()) - s += description; - if (!company.empty()) - s += "; " + company; - if (!product.empty()) - s += "; " + product; - - if (s.find ("; ") == 0) - s = s.substr (3); - - if (!s.empty()) - msg += SingleStringToWide (" (" + s + ")"); - } - - msg += L"\n\n"; - } - - if (otherDriver) - { - msg += GetString ("SYSTEM_CRASH_NO_VERACRYPT"); - msg += L"\n\n"; - } - - InfoDirect(msg.c_str(), hwndDlg); -/* - string urlStr = string (url) + "&drvver=" + (imageVersion.empty() ? "-" : imageVersion) + stackTraceArgs.str(); - - for (size_t i = 0; i < urlStr.size(); ++i) - { - if (urlStr[i] == '+') - urlStr[i] = '.'; - } - - msg += GetString ("SYSTEM_CRASH_REPORT"); - msg += L"\n\n"; - - msg += SingleStringToWide (urlStr); - - msg += L"\n\n"; - msg += GetString ("ASK_SEND_ERROR_REPORT"); - - if (AskYesNoString (msg.c_str()) == IDYES) - ShellExecute (NULL, "open", urlStr.c_str(), NULL, NULL, SW_SHOWNORMAL); -*/ -} - - static BOOL HandleDriveListMouseWheelEvent (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL bListMustBePointed) { static BOOL eventHandlerActive = FALSE; -- cgit v1.2.3