51 for (
i = 0;
i < (
Size / 16);
i++)
68 KDDBGPRINT(
"KdVmAddToBuffer: Buffer overflow! Need %lu, remaining: %lu\n",
110 if (*ReceiveDataSize <
sizeof(*ReceiveHeader))
112 KDDBGPRINT(
"KdVmSendReceive: received data too small: 0x%x\n", *ReceiveDataSize);
113 *ReceiveDataSize = 0;
117 if (ReceiveHeader->
Id != 0x2031 )
119 KDDBGPRINT(
"KdVmSendReceive: got invalid Id: 0x%x\n", ReceiveHeader->
Id);
120 *ReceiveDataSize = 0;
126 KDDBGPRINT(
"KdVmSendReceive: got invalid Magic: '%*s'\n",
128 *ReceiveDataSize = 0;
132 *ReceiveDataSize -=
sizeof(*ReceiveHeader);
133 return (
PVOID)(ReceiveHeader + 1);
143 KDDBGPRINT(
"KdVmNegotiateProtocolVersions()\n");
155 if (ReceivedSize !=
sizeof(
ULONG))
157 KDDBGPRINT(
"Invalid size for VersionReport: %lx\n", ReceivedSize);
163 KDDBGPRINT(
"Invalid Version: %lx\n", *ReceivedVersion);
181 for (
i = 0;
i <
sizeof(TestBuffer);
i++)
191 if (ReceivedSize !=
sizeof(TestBuffer))
193 KDDBGPRINT(
"Invalid size for TestConnection: %lx\n", ReceivedSize);
197 for (
i = 0;
i <
sizeof(TestBuffer);
i++)
199 if (ReceivedBuffer[
i] != (
UCHAR)(
i ^ 0x55))
201 KDDBGPRINT(
"Wrong test data @ %lx, expected %x, got %x\n",
202 i, (
UCHAR)(
i ^ 0x55), TestBuffer[
i]);
207 KDDBGPRINT(
"TestConnectionOnChannel: success\n");
218 for (
j = 0;
j < 2;
j++)
280 PCHAR CommandLine, PortString;
284 if (LoaderBlock !=
NULL)
291 CommandLine = LoaderBlock->LoadOptions;
297 PortString =
strstr(CommandLine,
"DEBUGPORT");
301 PortString +=
strlen(
"DEBUGPORT");
304 while (*PortString ==
' ') PortString++;
308 if (
strncmp(PortString,
"VBOX", 4) != 0)
310 KDDBGPRINT(
"Invalid debugport: '%s'\n", CommandLine);
357 KDDBGPRINT(
"KdSendPacket(0x%lx, ...)\n", PacketType);
369 if (MessageHeader !=
NULL)
373 SendPktRequest.
HeaderSize = MessageHeader->Length;
376 if (MessageData !=
NULL)
380 SendPktRequest.
DataSize = MessageData->Length;
383 if (KdContext !=
NULL)
396 KDDBGPRINT(
"KdSendPacket: Failed to add SendPacket command\n");
400 if (MessageHeader !=
NULL)
404 KDDBGPRINT(
"KdSendPacket: Failed to add MessageHeader\n");
409 if (MessageData !=
NULL)
413 KDDBGPRINT(
"KdSendPacket: Failed to add MessageData\n");
419 if (ReceivedSize !=
sizeof(*SendPktResult))
421 KDDBGPRINT(
"KdSendPacket: Invalid size for SendPktResult: %lx\n", ReceivedSize);
425 if (KdContext !=
NULL)
438 KDDBGPRINT(
"KdSendPacket: RetryKdSendPacket!\n");
458 ULONG ReceivedSize, ExpectedSize;
460 KDDBGPRINT(
"KdReceivePacket(0x%lx, ...)\n", PacketType);
472 if (MessageHeader !=
NULL)
478 if (MessageData !=
NULL)
484 if (KdContext !=
NULL)
493 KDDBGPRINT(
"KdReceivePacket: Failed to add SendPacket command\n");
498 if (ReceivedSize <
sizeof(*RecvPktResult))
500 KDDBGPRINT(
"KdReceivePacket: Invalid size for RecvPktResult: %lx\n", ReceivedSize);
504 ExpectedSize =
sizeof(*RecvPktResult) +
507 if (ReceivedSize != ExpectedSize)
509 KDDBGPRINT(
"KdReceivePacket: Invalid size for RecvPktResult: %lu, expected %lu\n",
510 ReceivedSize, ExpectedSize);
514 if (KdContext !=
NULL)
522 if (MessageHeader !=
NULL)
525 if ((MessageHeader->Buffer !=
NULL) &&
526 (MessageHeader->MaximumLength >= RecvPktResult->
HeaderSize))
539 if (MessageData !=
NULL)
542 if ((MessageData->Buffer !=
NULL) &&
543 (MessageData->MaximumLength >= RecvPktResult->
DataSize))
char * strstr(char *String1, char *String2)
ACPI_SIZE strlen(const char *String)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
#define NT_SUCCESS(StatCode)
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
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 GLint GLint j
VOID NTAPI KdVmKdVmExchangeData(_Out_ PVOID *ReceiveData, _Out_ PULONG ReceiveDataSize)
VOID NTAPI KdVmPrepareBuffer(VOID)
static BOOLEAN KdVmAddToBuffer(_In_ PVOID Data, _In_ ULONG DataSize)
NTSTATUS NTAPI KdD0Transition(VOID)
VOID NTAPI KdVmDbgDumpBuffer(_In_ PVOID Buffer, _In_ ULONG Size)
static BOOLEAN KdVmTestConnectionWithHost(VOID)
static const UCHAR KDVM_CMD_VersionReport
NTSTATUS NTAPI KdD3Transition(VOID)
NTSTATUS NTAPI KdDebuggerInitialize0(_In_opt_ PLOADER_PARAMETER_BLOCK LoaderBlock)
VOID NTAPI KdSendPacket(_In_ ULONG PacketType, _In_ PSTRING MessageHeader, _In_ PSTRING MessageData, _Inout_ PKD_CONTEXT KdContext)
NTSTATUS NTAPI KdRestore(_In_ BOOLEAN SleepTransition)
static BOOLEAN KdVmAddCommandToBuffer(_In_ UCHAR Command, _In_ PVOID Buffer, _In_ SIZE_T BufferSize)
static CHAR KdVmReplyMagic[]
UCHAR KdVmDataBuffer[KDVM_BUFFER_SIZE]
static BOOLEAN TestConnectionOnChannel(VOID)
static const UCHAR KDVM_CMD_SendPacket
NTSTATUS NTAPI KdSave(_In_ BOOLEAN SleepTransition)
PHYSICAL_ADDRESS KdVmBufferPhysicalAddress
static const UCHAR KDVM_CMD_TestConnection
NTSTATUS NTAPI KdDebuggerInitialize1(_In_opt_ PLOADER_PARAMETER_BLOCK LoaderBlock)
static const UCHAR KDVM_CMD_ReceivePacket
static CHAR KdVmCmdMagic[]
static PVOID KdVmSendReceive(_Out_ PULONG ReceiveDataSize)
KDP_STATUS NTAPI KdReceivePacket(_In_ ULONG PacketType, _Out_ PSTRING MessageHeader, _Out_ PSTRING MessageData, _Out_ PULONG DataLength, _Inout_opt_ PKD_CONTEXT KdContext)
static NTSTATUS KdVmNegotiateProtocolVersions(VOID)
static VOID KdVmDbgDumpRow(_In_ PUCHAR Buffer, _In_ ULONG Size)
#define RtlEqualMemory(dst, src, len)
#define KDRPC_TEST_BUFFER_SIZE
#define CONNECTION_TEST_ROUNDS
#define KDRPC_PROTOCOL_VERSION
ULONG(* PFNDBGPRNT)(const char *Format,...)
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress(IN PVOID Address)
static ULONG ReceiveData(PINFO pInfo)
#define STATUS_CONNECTION_REFUSED
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
KDVM_SENDPACKET_INFO Info
KDVM_MARSHAL_STRING MessageHeader
KDVM_MARSHAL_STRING MessageData
KDVM_MARSHAL_STRING MessageData
KDVM_MARSHAL_STRING MessageHeader
UCHAR KdDebuggerEnabledAvailable
BOOLEAN KdDebuggerEnabled
UCHAR KdDebuggerNotPresent
KDVM_MARSHAL_STRING MessageData
KDVM_SENDPACKET_INFO Info
KDVM_MARSHAL_STRING MessageHeader
KDVM_SENDPACKET_INFO Info
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_INVALID_PARAMETER
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
#define KD_DEBUGGER_NOT_PRESENT