6 * Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
7 * 2005 Klemens Friedl <frik85@reactos.at>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 void ProcessPage_OnDebug(void)
31 TCHAR strErrorText
[260];
33 TCHAR strDebugPath
[260];
34 TCHAR strDebugger
[260];
36 PROCESS_INFORMATION pi
;
43 for (Index
=0; Index
<(ULONG
)ListView_GetItemCount(hProcessPageListCtrl
); Index
++)
45 memset(&lvitem
, 0, sizeof(LVITEM
));
47 lvitem
.mask
= LVIF_STATE
;
48 lvitem
.stateMask
= LVIS_SELECTED
;
51 ListView_GetItem(hProcessPageListCtrl
, &lvitem
);
53 if (lvitem
.state
& LVIS_SELECTED
)
57 dwProcessId
= PerfDataGetProcessId(Index
);
59 if ((ListView_GetSelectedCount(hProcessPageListCtrl
) != 1) || (dwProcessId
== 0))
62 LoadString(hInst
, IDS_MSG_WARNINGDEBUG
, szTemp
, 256);
63 LoadString(hInst
, IDS_MSG_TASKMGRWARNING
, szTempA
, 256);
65 if (MessageBox(hMainWnd
, szTemp
, szTempA
, MB_YESNO
|MB_ICONWARNING
) != IDYES
)
67 GetLastErrorText(strErrorText
, 260);
68 LoadString(hInst
, IDS_MSG_UNABLEDEBUGPROCESS
, szTemp
, 256);
69 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
73 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
, _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug"), 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
75 GetLastErrorText(strErrorText
, 260);
76 LoadString(hInst
, IDS_MSG_UNABLEDEBUGPROCESS
, szTemp
, 256);
77 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
82 if (RegQueryValueEx(hKey
, _T("Debugger"), NULL
, NULL
, (LPBYTE
)strDebugger
, &dwDebuggerSize
) != ERROR_SUCCESS
)
84 GetLastErrorText(strErrorText
, 260);
85 LoadString(hInst
, IDS_MSG_UNABLEDEBUGPROCESS
, szTemp
, 256);
86 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
93 hDebugEvent
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
96 GetLastErrorText(strErrorText
, 260);
97 LoadString(hInst
, IDS_MSG_UNABLEDEBUGPROCESS
, szTemp
, 256);
98 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
102 wsprintf(strDebugPath
, strDebugger
, dwProcessId
, hDebugEvent
);
104 memset(&pi
, 0, sizeof(PROCESS_INFORMATION
));
105 memset(&si
, 0, sizeof(STARTUPINFO
));
106 si
.cb
= sizeof(STARTUPINFO
);
107 if (!CreateProcess(NULL
, strDebugPath
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
))
109 GetLastErrorText(strErrorText
, 260);
110 LoadString(hInst
, IDS_MSG_UNABLEDEBUGPROCESS
, szTemp
, 256);
111 MessageBox(hMainWnd
, strErrorText
, szTemp
, MB_OK
|MB_ICONSTOP
);
114 CloseHandle(hDebugEvent
);