1 /*++ NDK Version: 0098 2 3 Copyright (c) Alex Ionescu. All rights reserved. 4 5 Header Name: 6 7 dbgktypes.h 8 9 Abstract: 10 11 Type definitions for the User Mode Debugging Facility. 12 13 Author: 14 15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006 16 17 --*/ 18 19 #ifndef _DBGKTYPES_H 20 #define _DBGKTYPES_H 21 22 // 23 // Dependencies 24 // 25 #include <umtypes.h> 26 #include <lpctypes.h> 27 28 // 29 // Debug Object Access Masks 30 // 31 #define DEBUG_OBJECT_WAIT_STATE_CHANGE 0x0001 32 #define DEBUG_OBJECT_ADD_REMOVE_PROCESS 0x0002 33 #define DEBUG_OBJECT_SET_INFORMATION 0x0004 34 #define DEBUG_OBJECT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x0F) 35 36 // 37 // Debug Event Flags 38 // 39 #define DEBUG_EVENT_READ (0x01) 40 #define DEBUG_EVENT_NOWAIT (0x02) 41 #define DEBUG_EVENT_INACTIVE (0x04) 42 #define DEBUG_EVENT_RELEASE (0x08) 43 #define DEBUG_EVENT_PROTECT_FAILED (0x10) 44 #define DEBUG_EVENT_SUSPEND (0x20) 45 46 // 47 // NtCreateDebugObject Flags 48 // 49 #define DBGK_KILL_PROCESS_ON_EXIT (0x1) 50 #define DBGK_ALL_FLAGS (DBGK_KILL_PROCESS_ON_EXIT) 51 52 // 53 // Debug Object Information Classes for NtQueryDebugObject 54 // 55 typedef enum _DEBUGOBJECTINFOCLASS 56 { 57 DebugObjectUnusedInformation, 58 DebugObjectKillProcessOnExitInformation 59 } DEBUGOBJECTINFOCLASS, *PDEBUGOBJECTINFOCLASS; 60 61 // 62 // Debug Message API Number 63 // 64 typedef enum _DBGKM_APINUMBER 65 { 66 DbgKmExceptionApi = 0, 67 DbgKmCreateThreadApi = 1, 68 DbgKmCreateProcessApi = 2, 69 DbgKmExitThreadApi = 3, 70 DbgKmExitProcessApi = 4, 71 DbgKmLoadDllApi = 5, 72 DbgKmUnloadDllApi = 6, 73 DbgKmErrorReportApi = 7, 74 DbgKmMaxApiNumber = 8, 75 } DBGKM_APINUMBER; 76 77 // 78 // Debug Object Information Structures 79 // 80 typedef struct _DEBUG_OBJECT_KILL_PROCESS_ON_EXIT_INFORMATION 81 { 82 ULONG KillProcessOnExit; 83 } DEBUG_OBJECT_KILL_PROCESS_ON_EXIT_INFORMATION, *PDEBUG_OBJECT_KILL_PROCESS_ON_EXIT_INFORMATION; 84 85 #ifndef NTOS_MODE_USER 86 87 // 88 // Debug Object 89 // 90 typedef struct _DEBUG_OBJECT 91 { 92 KEVENT EventsPresent; 93 FAST_MUTEX Mutex; 94 LIST_ENTRY EventList; 95 union 96 { 97 ULONG Flags; 98 struct 99 { 100 UCHAR DebuggerInactive:1; 101 UCHAR KillProcessOnExit:1; 102 }; 103 }; 104 } DEBUG_OBJECT, *PDEBUG_OBJECT; 105 106 #endif 107 108 // 109 // Debug States 110 // 111 typedef enum _DBG_STATE 112 { 113 DbgIdle, 114 DbgReplyPending, 115 DbgCreateThreadStateChange, 116 DbgCreateProcessStateChange, 117 DbgExitThreadStateChange, 118 DbgExitProcessStateChange, 119 DbgExceptionStateChange, 120 DbgBreakpointStateChange, 121 DbgSingleStepStateChange, 122 DbgLoadDllStateChange, 123 DbgUnloadDllStateChange 124 } DBG_STATE, *PDBG_STATE; 125 126 // 127 // Debug Message Structures 128 // 129 typedef struct _DBGKM_EXCEPTION 130 { 131 EXCEPTION_RECORD ExceptionRecord; 132 ULONG FirstChance; 133 } DBGKM_EXCEPTION, *PDBGKM_EXCEPTION; 134 135 typedef struct _DBGKM_CREATE_THREAD 136 { 137 ULONG SubSystemKey; 138 PVOID StartAddress; 139 } DBGKM_CREATE_THREAD, *PDBGKM_CREATE_THREAD; 140 141 typedef struct _DBGKM_CREATE_PROCESS 142 { 143 ULONG SubSystemKey; 144 HANDLE FileHandle; 145 PVOID BaseOfImage; 146 ULONG DebugInfoFileOffset; 147 ULONG DebugInfoSize; 148 DBGKM_CREATE_THREAD InitialThread; 149 } DBGKM_CREATE_PROCESS, *PDBGKM_CREATE_PROCESS; 150 151 typedef struct _DBGKM_EXIT_THREAD 152 { 153 NTSTATUS ExitStatus; 154 } DBGKM_EXIT_THREAD, *PDBGKM_EXIT_THREAD; 155 156 typedef struct _DBGKM_EXIT_PROCESS 157 { 158 NTSTATUS ExitStatus; 159 } DBGKM_EXIT_PROCESS, *PDBGKM_EXIT_PROCESS; 160 161 typedef struct _DBGKM_LOAD_DLL 162 { 163 HANDLE FileHandle; 164 PVOID BaseOfDll; 165 ULONG DebugInfoFileOffset; 166 ULONG DebugInfoSize; 167 PVOID NamePointer; 168 } DBGKM_LOAD_DLL, *PDBGKM_LOAD_DLL; 169 170 typedef struct _DBGKM_UNLOAD_DLL 171 { 172 PVOID BaseAddress; 173 } DBGKM_UNLOAD_DLL, *PDBGKM_UNLOAD_DLL; 174 175 // 176 // User-Mode Debug State Change Structure 177 // 178 typedef struct _DBGUI_WAIT_STATE_CHANGE 179 { 180 DBG_STATE NewState; 181 CLIENT_ID AppClientId; 182 union 183 { 184 struct 185 { 186 HANDLE HandleToThread; 187 DBGKM_CREATE_THREAD NewThread; 188 } CreateThread; 189 struct 190 { 191 HANDLE HandleToProcess; 192 HANDLE HandleToThread; 193 DBGKM_CREATE_PROCESS NewProcess; 194 } CreateProcessInfo; 195 DBGKM_EXIT_THREAD ExitThread; 196 DBGKM_EXIT_PROCESS ExitProcess; 197 DBGKM_EXCEPTION Exception; 198 DBGKM_LOAD_DLL LoadDll; 199 DBGKM_UNLOAD_DLL UnloadDll; 200 } StateInfo; 201 } DBGUI_WAIT_STATE_CHANGE, *PDBGUI_WAIT_STATE_CHANGE; 202 203 // 204 // LPC Debug Message 205 // 206 typedef struct _DBGKM_MSG 207 { 208 PORT_MESSAGE h; 209 DBGKM_APINUMBER ApiNumber; 210 NTSTATUS ReturnedStatus; 211 union 212 { 213 DBGKM_EXCEPTION Exception; 214 DBGKM_CREATE_THREAD CreateThread; 215 DBGKM_CREATE_PROCESS CreateProcess; 216 DBGKM_EXIT_THREAD ExitThread; 217 DBGKM_EXIT_PROCESS ExitProcess; 218 DBGKM_LOAD_DLL LoadDll; 219 DBGKM_UNLOAD_DLL UnloadDll; 220 }; 221 } DBGKM_MSG, *PDBGKM_MSG; 222 223 #ifndef NTOS_MODE_USER 224 225 // 226 // Debug Event 227 // 228 typedef struct _DEBUG_EVENT 229 { 230 LIST_ENTRY EventList; 231 KEVENT ContinueEvent; 232 CLIENT_ID ClientId; 233 PEPROCESS Process; 234 PETHREAD Thread; 235 NTSTATUS Status; 236 ULONG Flags; 237 PETHREAD BackoutThread; 238 DBGKM_MSG ApiMsg; 239 } DEBUG_EVENT, *PDEBUG_EVENT; 240 241 242 #endif 243 244 #endif 245