2004-01-10 02:14:13 +00:00
|
|
|
/*
|
|
|
|
* ReactOS Task Manager
|
|
|
|
*
|
2010-08-08 03:41:33 +00:00
|
|
|
* debug.c
|
2004-01-10 02:14:13 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
2005-03-27 20:01:18 +00:00
|
|
|
* 2005 Klemens Friedl <frik85@reactos.at>
|
2004-01-10 02:14:13 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2009-10-27 10:34:16 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2004-01-10 02:14:13 +00:00
|
|
|
*/
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include "precomp.h"
|
2004-01-10 02:14:13 +00:00
|
|
|
|
|
|
|
void ProcessPage_OnDebug(void)
|
|
|
|
{
|
|
|
|
DWORD dwProcessId;
|
2007-10-31 23:26:27 +00:00
|
|
|
WCHAR strErrorText[260];
|
2005-03-27 20:01:18 +00:00
|
|
|
HKEY hKey;
|
2007-10-31 23:26:27 +00:00
|
|
|
WCHAR strDebugPath[260];
|
|
|
|
WCHAR strDebugger[260];
|
2004-01-10 02:14:13 +00:00
|
|
|
DWORD dwDebuggerSize;
|
2005-03-27 20:01:18 +00:00
|
|
|
PROCESS_INFORMATION pi;
|
2007-11-09 15:26:02 +00:00
|
|
|
STARTUPINFOW si;
|
2005-03-27 20:01:18 +00:00
|
|
|
HANDLE hDebugEvent;
|
2007-10-31 23:26:27 +00:00
|
|
|
WCHAR szTemp[256];
|
|
|
|
WCHAR szTempA[256];
|
2005-03-27 20:01:18 +00:00
|
|
|
|
2009-06-28 14:22:09 +00:00
|
|
|
dwProcessId = GetSelectedProcessId();
|
2004-01-10 02:14:13 +00:00
|
|
|
|
2009-06-28 14:22:09 +00:00
|
|
|
if (dwProcessId == 0)
|
2004-01-10 02:14:13 +00:00
|
|
|
return;
|
|
|
|
|
2016-07-01 21:23:47 +00:00
|
|
|
LoadStringW(hInst, IDS_MSG_WARNINGDEBUG, szTemp, ARRAYSIZE(szTemp));
|
|
|
|
LoadStringW(hInst, IDS_MSG_TASKMGRWARNING, szTempA, ARRAYSIZE(szTempA));
|
2005-03-27 20:01:18 +00:00
|
|
|
|
2016-07-01 21:23:47 +00:00
|
|
|
if (MessageBoxW(hMainWnd, szTemp, szTempA, MB_YESNO | MB_ICONWARNING) != IDYES)
|
2004-01-10 02:14:13 +00:00
|
|
|
{
|
2016-07-01 21:23:47 +00:00
|
|
|
GetLastErrorText(strErrorText, ARRAYSIZE(strErrorText));
|
|
|
|
LoadStringW(hInst, IDS_MSG_UNABLEDEBUGPROCESS, szTemp, ARRAYSIZE(szTemp));
|
|
|
|
MessageBoxW(hMainWnd, strErrorText, szTemp, MB_OK | MB_ICONSTOP);
|
2004-01-10 02:14:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-01 21:23:47 +00:00
|
|
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug", 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
|
2004-01-10 02:14:13 +00:00
|
|
|
{
|
2016-07-01 21:23:47 +00:00
|
|
|
GetLastErrorText(strErrorText, ARRAYSIZE(strErrorText));
|
|
|
|
LoadStringW(hInst, IDS_MSG_UNABLEDEBUGPROCESS, szTemp, ARRAYSIZE(szTemp));
|
|
|
|
MessageBoxW(hMainWnd, strErrorText, szTemp, MB_OK | MB_ICONSTOP);
|
2004-01-10 02:14:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-01 21:23:47 +00:00
|
|
|
dwDebuggerSize = sizeof(strDebugger);
|
2007-11-09 15:26:02 +00:00
|
|
|
if (RegQueryValueExW(hKey, L"Debugger", NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) != ERROR_SUCCESS)
|
2004-01-10 02:14:13 +00:00
|
|
|
{
|
2016-07-01 21:23:47 +00:00
|
|
|
GetLastErrorText(strErrorText, ARRAYSIZE(strErrorText));
|
|
|
|
LoadStringW(hInst, IDS_MSG_UNABLEDEBUGPROCESS, szTemp, ARRAYSIZE(szTemp));
|
|
|
|
MessageBoxW(hMainWnd, strErrorText, szTemp, MB_OK | MB_ICONSTOP);
|
2004-01-10 02:14:13 +00:00
|
|
|
RegCloseKey(hKey);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
2007-11-09 15:26:02 +00:00
|
|
|
hDebugEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
|
2004-01-10 02:14:13 +00:00
|
|
|
if (!hDebugEvent)
|
|
|
|
{
|
2016-07-01 21:23:47 +00:00
|
|
|
GetLastErrorText(strErrorText, ARRAYSIZE(strErrorText));
|
|
|
|
LoadStringW(hInst, IDS_MSG_UNABLEDEBUGPROCESS, szTemp, ARRAYSIZE(szTemp));
|
|
|
|
MessageBoxW(hMainWnd, strErrorText, szTemp, MB_OK | MB_ICONSTOP);
|
2004-01-10 02:14:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-09 15:26:02 +00:00
|
|
|
wsprintfW(strDebugPath, strDebugger, dwProcessId, hDebugEvent);
|
2004-01-10 02:14:13 +00:00
|
|
|
|
2016-07-01 21:23:47 +00:00
|
|
|
ZeroMemory(&pi, sizeof(pi));
|
|
|
|
ZeroMemory(&si, sizeof(si));
|
|
|
|
si.cb = sizeof(si);
|
2007-11-09 15:26:02 +00:00
|
|
|
if (!CreateProcessW(NULL, strDebugPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
2004-01-10 02:14:13 +00:00
|
|
|
{
|
2016-07-01 21:23:47 +00:00
|
|
|
GetLastErrorText(strErrorText, ARRAYSIZE(strErrorText));
|
|
|
|
LoadStringW(hInst, IDS_MSG_UNABLEDEBUGPROCESS, szTemp, ARRAYSIZE(szTemp));
|
|
|
|
MessageBoxW(hMainWnd, strErrorText, szTemp, MB_OK | MB_ICONSTOP);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CloseHandle(pi.hThread);
|
|
|
|
CloseHandle(pi.hProcess);
|
2004-01-10 02:14:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(hDebugEvent);
|
|
|
|
}
|