47 #define hex_to_pid hex_to_tid 132 KDDBGPRINT(
"Checking if %p is alive.\n", Tid);
140 KDDBGPRINT(
"Checking if p%p.%p is alive.\n", Pid, Tid);
163 return send_gdb_packet(
"PacketSize=1000;multiprocess+;qXfer:libraries:read+;");
207 if (CurrentProcessEntry ==
NULL)
229 CurrentProcessEntry = CurrentProcessEntry->
Flink)
236 for ( CurrentThreadEntry =
Process->ThreadListHead.Flink;
237 CurrentThreadEntry != &
Process->ThreadListHead;
238 CurrentThreadEntry = CurrentThreadEntry->
Flink)
343 char str_helper[256];
344 char name_helper[64];
350 KDDBGPRINT(
"KDGDB: qXfer:libraries:read !\n");
384 CurrentEntry = CurrentEntry->
Flink)
395 if (name_helper[
i] >=
'A' && name_helper[
i] <=
'Z')
396 name_helper[
i] +=
'a' -
'A';
401 mem_length =
_snprintf(str_helper, 256,
"<library name=\"C:\\%s\"><segment address=\"0x%p\"/></library>", &name_helper, DllBase);
410 if ((
Sent + mem_length) > ToSend)
419 if ((ToSend -
Sent) > 15)
435 handle_gdb_registers(
450 MessageData->Length = 0;
468 KDDBGPRINT(
"Wrong packet type (%lu) received after DbgKdReadVirtualMemoryApi request.\n", PacketType);
474 KDDBGPRINT(
"Wrong API number (%lu) after DbgKdReadVirtualMemoryApi request.\n",
State->ApiNumber);
514 MessageData->Length = 0;
523 if (AttachedThread ==
NULL)
525 KDDBGPRINT(
"The current GDB debug thread is invalid!");
529 AttachedProcess = AttachedThread->
Tcb.
Process;
530 if (AttachedProcess ==
NULL)
532 KDDBGPRINT(
"The current GDB debug thread is invalid!");
541 if (AttachedProcess ==
NULL)
543 KDDBGPRINT(
"The current GDB debug thread is invalid!");
572 KDDBGPRINT(
"Wrong packet type (%lu) received after DbgKdWriteVirtualMemoryApi request.\n", PacketType);
578 KDDBGPRINT(
"Wrong API number (%lu) after DbgKdWriteVirtualMemoryApi request.\n",
State->ApiNumber);
629 if (AttachedThread ==
NULL)
631 KDDBGPRINT(
"The current GDB debug thread is invalid!");
635 AttachedProcess = AttachedThread->
Tcb.
Process;
636 if (AttachedProcess ==
NULL)
638 KDDBGPRINT(
"The current GDB debug thread is invalid!");
647 if (AttachedProcess ==
NULL)
649 KDDBGPRINT(
"The current GDB debug thread is invalid!");
690 *OutPtr++ = *blob_ptr++;
712 KDDBGPRINT(
"Wrong packet type (%lu) received after DbgKdWriteBreakPointApi request.\n", PacketType);
718 KDDBGPRINT(
"Wrong API number (%lu) after DbgKdWriteBreakPointApi request.\n",
State->ApiNumber);
760 MessageData->Length = 0;
782 KDDBGPRINT(
"No breakpoint slot available!\n");
813 KDDBGPRINT(
"Wrong packet type (%lu) received after DbgKdRestoreBreakPointApi request.\n", PacketType);
819 KDDBGPRINT(
"Wrong API number (%lu) after DbgKdRestoreBreakPointApi request.\n",
State->ApiNumber);
854 MessageData->Length = 0;
882 State->u.RestoreBreakPoint.BreakPointHandle =
Handle;
927 #if defined(_M_IX86) || defined(_M_AMD64) void send_gdb_partial_packet(_In_ const CHAR *Buffer)
unsigned __int3264 UINT_PTR
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
#define DbgKdWriteVirtualMemoryApi
FORCEINLINE HANDLE gdb_tid_to_handle(UINT_PTR Tid)
void send_gdb_ntstatus(_In_ NTSTATUS Status)
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
ULONG_PTR DirectoryTableBase
char * strstr(char *String1, char *String2)
#define DbgKdReadVirtualMemoryApi
#define handle_to_gdb_pid
GLint GLint GLint GLint GLint x
union _DBGKD_ANY_WAIT_STATE_CHANGE::@3492 u
KDSTATUS ContinueManipulateStateHandler(_Out_ DBGKD_MANIPULATE_STATE64 *State, _Out_ PSTRING MessageData, _Out_ PULONG MessageLength, _Inout_ PKD_CONTEXT KdContext)
#define DbgKdExceptionStateChange
KDP_MANIPULATESTATE_HANDLER KdpManipulateStateHandler
static const char hex[16]
#define DbgKdRestoreBreakPointApi
KDSTATUS send_gdb_memory(_In_ const VOID *Buffer, _In_ size_t Length)
DBGKD_ANY_WAIT_STATE_CHANGE CurrentStateChange
KDSTATUS send_gdb_packet(_In_ const CHAR *Buffer)
#define KD_BREAKPOINT_VALUE
KDSTATUS gdb_send_exception()
#define sprintf(buf, format,...)
__INTRIN_INLINE void __writecr3(unsigned int Data)
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
#define PsGetCurrentProcess
KDP_SEND_HANDLER KdpSendPacketHandler
#define STATUS_BREAKPOINT
PETHREAD find_thread(_In_ UINT_PTR Pid, _In_ UINT_PTR Tid)
KDSTATUS gdb_send_registers(void)
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
KDSTATUS gdb_send_debug_io(_In_ PSTRING String, _In_ BOOLEAN WithPrefix)
KDSTATUS NTAPI gdb_receive_packet(_Inout_ PKD_CONTEXT KdContext)
struct _LIST_ENTRY * Flink
void start_gdb_packet(void)
#define STATUS_ASSERTION_FAILURE
ULONG send_gdb_partial_binary(_In_ const VOID *Buffer, _In_ size_t Length)
#define NT_SUCCESS(StatCode)
HANDLE NTAPI PsGetThreadProcessId(IN PETHREAD Thread)
#define DbgKdGetContextApi
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
unsigned __int3264 UINT_PTR
#define PACKET_TYPE_KD_STATE_MANIPULATE
EXCEPTION_RECORD64 ExceptionRecord
PEPROCESS find_process(_In_ UINT_PTR Pid)
HANDLE NTAPI PsGetThreadId(IN PETHREAD Thread)
KDSTATUS SetContextManipulateHandler(_Out_ DBGKD_MANIPULATE_STATE64 *State, _Out_ PSTRING MessageData, _Out_ PULONG MessageLength, _Inout_ PKD_CONTEXT KdContext)
#define KD_BREAKPOINT_TYPE
_In_ ULONG _In_ ULONG Offset
LIST_ENTRY * ProcessListHead
#define DbgKdWriteBreakPointApi
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
HANDLE NTAPI PsGetCurrentProcessId(VOID)
DBGKM_EXCEPTION64 Exception
_Must_inspect_result_ typedef _In_ ULONG TableEntry
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
FORCEINLINE UINT_PTR handle_to_gdb_tid(HANDLE Handle)
int strcmp(const char *String1, const char *String2)
#define KD_BREAKPOINT_SIZE
#define gdb_pid_to_handle
LIST_ENTRY * ModuleListHead
KDSTATUS finish_gdb_packet(void)
KDSTATUS gdb_send_register(void)