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)
325 char str_helper[256];
326 char name_helper[64];
332 KDDBGPRINT(
"KDGDB: qXfer:libraries:read !\n");
366 CurrentEntry = CurrentEntry->
Flink)
377 if (name_helper[
i] >=
'A' && name_helper[
i] <=
'Z')
378 name_helper[
i] +=
'a' -
'A';
383 mem_length =
_snprintf(str_helper, 256,
"<library name=\"C:\\%s\"><segment address=\"0x%p\"/></library>", &name_helper, DllBase);
392 if ((
Sent + mem_length) > ToSend)
401 if ((ToSend -
Sent) > 15)
417 handle_gdb_registers(
432 MessageData->Length = 0;
450 KDDBGPRINT(
"Wrong packet type (%lu) received after DbgKdReadVirtualMemoryApi request.\n", PacketType);
456 KDDBGPRINT(
"Wrong API number (%lu) after DbgKdReadVirtualMemoryApi request.\n",
State->ApiNumber);
493 MessageData->Length = 0;
502 if (AttachedThread ==
NULL)
504 KDDBGPRINT(
"The current GDB debug thread is invalid!");
508 AttachedProcess = AttachedThread->
Tcb.
Process;
509 if (AttachedProcess ==
NULL)
511 KDDBGPRINT(
"The current GDB debug thread is invalid!");
520 if (AttachedProcess ==
NULL)
522 KDDBGPRINT(
"The current GDB debug thread is invalid!");
551 KDDBGPRINT(
"Wrong packet type (%lu) received after DbgKdWriteVirtualMemoryApi request.\n", PacketType);
557 KDDBGPRINT(
"Wrong API number (%lu) after DbgKdWriteVirtualMemoryApi request.\n",
State->ApiNumber);
606 if (AttachedThread ==
NULL)
608 KDDBGPRINT(
"The current GDB debug thread is invalid!");
612 AttachedProcess = AttachedThread->
Tcb.
Process;
613 if (AttachedProcess ==
NULL)
615 KDDBGPRINT(
"The current GDB debug thread is invalid!");
624 if (AttachedProcess ==
NULL)
626 KDDBGPRINT(
"The current GDB debug thread is invalid!");
667 *OutPtr++ = *blob_ptr++;
689 KDDBGPRINT(
"Wrong packet type (%lu) received after DbgKdWriteBreakPointApi request.\n", PacketType);
695 KDDBGPRINT(
"Wrong API number (%lu) after DbgKdWriteBreakPointApi request.\n",
State->ApiNumber);
735 MessageData->Length = 0;
757 KDDBGPRINT(
"No breakpoint slot available!\n");
788 KDDBGPRINT(
"Wrong packet type (%lu) received after DbgKdRestoreBreakPointApi request.\n", PacketType);
794 KDDBGPRINT(
"Wrong API number (%lu) after DbgKdRestoreBreakPointApi request.\n",
State->ApiNumber);
827 MessageData->Length = 0;
855 State->u.RestoreBreakPoint.BreakPointHandle =
Handle;
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)
KDSTATUS gdb_send_registers(void)
#define DbgKdReadVirtualMemoryApi
#define handle_to_gdb_pid
GLint GLint GLint GLint GLint x
KDSTATUS ContinueManipulateStateHandler(_Out_ DBGKD_MANIPULATE_STATE64 *State, _Out_ PSTRING MessageData, _Out_ PULONG MessageLength, _Inout_ PKD_CONTEXT KdContext)
KDSTATUS gdb_send_register(void)
#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)
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)
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)
#define DbgKdContinueApi2
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
union _DBGKD_ANY_WAIT_STATE_CHANGE::@3499 u
LIST_ENTRY * ModuleListHead
KDSTATUS finish_gdb_packet(void)