ReactOS 0.4.16-dev-112-g52265ae
debug.c File Reference
#include "precomp.h"
Include dependency graph for debug.c:

Go to the source code of this file.

Functions

void ProcessPage_OnDebug (void)
 

Function Documentation

◆ ProcessPage_OnDebug()

void ProcessPage_OnDebug ( void  )

Definition at line 11 of file debug.c.

12{
13 DWORD dwProcessId;
14 WCHAR strErrorText[260];
15 HKEY hKey;
16 WCHAR strDebugPath[260];
17 WCHAR strDebugger[260];
18 DWORD dwDebuggerSize;
20 STARTUPINFOW si;
21 HANDLE hDebugEvent;
22 WCHAR szTemp[256];
23 WCHAR szTempA[256];
24
25 dwProcessId = GetSelectedProcessId();
26
27 if (dwProcessId == 0)
28 return;
29
32
33 if (!ConfirmMessageBox(hMainWnd, szTemp, szTempA, MB_YESNO | MB_ICONWARNING))
34 {
35 GetLastErrorText(strErrorText, _countof(strErrorText));
37 MessageBoxW(hMainWnd, strErrorText, szTemp, MB_OK | MB_ICONSTOP);
38 return;
39 }
40
41 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug", 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
42 {
43 GetLastErrorText(strErrorText, _countof(strErrorText));
45 MessageBoxW(hMainWnd, strErrorText, szTemp, MB_OK | MB_ICONSTOP);
46 return;
47 }
48
49 dwDebuggerSize = sizeof(strDebugger);
50 if (RegQueryValueExW(hKey, L"Debugger", NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) != ERROR_SUCCESS)
51 {
52 GetLastErrorText(strErrorText, _countof(strErrorText));
54 MessageBoxW(hMainWnd, strErrorText, szTemp, MB_OK | MB_ICONSTOP);
56 return;
57 }
58
60
61 hDebugEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
62 if (!hDebugEvent)
63 {
64 GetLastErrorText(strErrorText, _countof(strErrorText));
66 MessageBoxW(hMainWnd, strErrorText, szTemp, MB_OK | MB_ICONSTOP);
67 return;
68 }
69
70 wsprintfW(strDebugPath, strDebugger, dwProcessId, hDebugEvent);
71
72 ZeroMemory(&pi, sizeof(pi));
73 ZeroMemory(&si, sizeof(si));
74 si.cb = sizeof(si);
75 if (!CreateProcessW(NULL, strDebugPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
76 {
77 GetLastErrorText(strErrorText, _countof(strErrorText));
79 MessageBoxW(hMainWnd, strErrorText, szTemp, MB_OK | MB_ICONSTOP);
80 }
81 else
82 {
83 CloseHandle(pi.hThread);
84 CloseHandle(pi.hProcess);
85 }
86
87 CloseHandle(hDebugEvent);
88}
#define IDS_MSG_UNABLEDEBUGPROCESS
Definition: resource.h:250
#define IDS_MSG_TASKMGRWARNING
Definition: resource.h:252
#define IDS_MSG_WARNINGDEBUG
Definition: resource.h:251
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4598
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
HWND hMainWnd
Definition: magnifier.c:32
static refpint_t pi[]
Definition: server.c:96
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define L(x)
Definition: ntvdm.h:50
DWORD GetSelectedProcessId(void)
Definition: procpage.c:88
#define _countof(array)
Definition: sndvol32.h:70
DWORD cb
Definition: winbase.h:852
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
BOOL ConfirmMessageBox(HWND hWnd, LPCWSTR Text, LPCWSTR Title, UINT Type)
Definition: taskmgr.c:1059
LPWSTR GetLastErrorText(LPWSTR lpszBuf, DWORD dwSize)
Definition: taskmgr.c:1083
unsigned char * LPBYTE
Definition: typedefs.h:53
#define ZeroMemory
Definition: winbase.h:1712
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define MB_YESNO
Definition: winuser.h:820
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_OK
Definition: winuser.h:793
#define MB_ICONWARNING
Definition: winuser.h:789
#define MB_ICONSTOP
Definition: winuser.h:806
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by TaskManagerWndProc().