ReactOS 0.4.16-dev-319-g6cf4263
kdvm.c File Reference
#include "kdvm.h"
Include dependency graph for kdvm.c:

Go to the source code of this file.

Functions

static VOID KdVmDbgDumpRow (_In_ PUCHAR Buffer, _In_ ULONG Size)
 
VOID NTAPI KdVmDbgDumpBuffer (_In_ PVOID Buffer, _In_ ULONG Size)
 
static BOOLEAN KdVmAddToBuffer (_In_ PVOID Data, _In_ ULONG DataSize)
 
static BOOLEAN KdVmAddCommandToBuffer (_In_ UCHAR Command, _In_ PVOID Buffer, _In_ SIZE_T BufferSize)
 
static PVOID KdVmSendReceive (_Out_ PULONG ReceiveDataSize)
 
static NTSTATUS KdVmNegotiateProtocolVersions (VOID)
 
static BOOLEAN TestConnectionOnChannel (VOID)
 
static BOOLEAN KdVmTestConnectionWithHost (VOID)
 
NTSTATUS NTAPI KdD0Transition (VOID)
 
NTSTATUS NTAPI KdD3Transition (VOID)
 
NTSTATUS NTAPI KdSave (_In_ BOOLEAN SleepTransition)
 
NTSTATUS NTAPI KdRestore (_In_ BOOLEAN SleepTransition)
 
NTSTATUS NTAPI KdDebuggerInitialize0 (_In_opt_ PLOADER_PARAMETER_BLOCK LoaderBlock)
 
NTSTATUS NTAPI KdDebuggerInitialize1 (_In_opt_ PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI KdSendPacket (_In_ ULONG PacketType, _In_ PSTRING MessageHeader, _In_ PSTRING MessageData, _Inout_ PKD_CONTEXT KdContext)
 
KDP_STATUS NTAPI KdReceivePacket (_In_ ULONG PacketType, _Out_ PSTRING MessageHeader, _Out_ PSTRING MessageData, _Out_ PULONG DataLength, _Inout_opt_ PKD_CONTEXT KdContext)
 

Variables

static CHAR KdVmCmdMagic [] = "~kdVMvA "
 
static CHAR KdVmReplyMagic [] = "++kdVMvA "
 
static const UCHAR KDVM_CMD_TestConnection = 't'
 
static const UCHAR KDVM_CMD_ReceivePacket = 'r'
 
static const UCHAR KDVM_CMD_SendPacket = 's'
 
static const UCHAR KDVM_CMD_VersionReport = 'v'
 
UCHAR KdVmDataBuffer [KDVM_BUFFER_SIZE]
 
PHYSICAL_ADDRESS KdVmBufferPhysicalAddress
 
ULONG KdVmBufferPos
 
PFNDBGPRNT KdpDbgPrint
 

Function Documentation

◆ KdD0Transition()

NTSTATUS NTAPI KdD0Transition ( VOID  )

Definition at line 237 of file kdvm.c.

238{
239 /* Nothing to do */
240 return STATUS_SUCCESS;
241}
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ KdD3Transition()

NTSTATUS NTAPI KdD3Transition ( VOID  )

Definition at line 245 of file kdvm.c.

246{
247 /* Nothing to do */
248 return STATUS_SUCCESS;
249}

◆ KdDebuggerInitialize0()

NTSTATUS NTAPI KdDebuggerInitialize0 ( _In_opt_ PLOADER_PARAMETER_BLOCK LoaderBlock  LoaderBlock)

Definition at line 277 of file kdvm.c.

279{
280 PCHAR CommandLine, PortString;
282
283 /* Check if we have a LoaderBlock */
284 if (LoaderBlock != NULL)
285 {
286 /* HACK */
287 KdpDbgPrint = LoaderBlock->u.I386.CommonDataArea;
288 KDDBGPRINT("KdDebuggerInitialize0\n");
289
290 /* Get the Command Line */
291 CommandLine = LoaderBlock->LoadOptions;
292
293 /* Upcase it */
294 _strupr(CommandLine);
295
296 /* Check if we got the /DEBUGPORT parameter */
297 PortString = strstr(CommandLine, "DEBUGPORT");
298 if (PortString)
299 {
300 /* Move past the actual string, to reach the port*/
301 PortString += strlen("DEBUGPORT");
302
303 /* Now get past any spaces and skip the equal sign */
304 while (*PortString == ' ') PortString++;
305 PortString++;
306
307 /* Do we have a serial port? */
308 if (strncmp(PortString, "VBOX", 4) != 0)
309 {
310 KDDBGPRINT("Invalid debugport: '%s'\n", CommandLine);
312 }
313 }
314 }
315
316 /* Get the physical address of the data buffer */
318 KDDBGPRINT("KdVmBufferPhysicalAddress = %llx\n", KdVmBufferPhysicalAddress.QuadPart);
319
321 if (!NT_SUCCESS(Status))
322 return Status;
323
326
327 return STATUS_SUCCESS;
328}
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define KDDBGPRINT(...)
Definition: kddll.h:19
Status
Definition: gdiplustypes.h:25
static BOOLEAN KdVmTestConnectionWithHost(VOID)
Definition: kdvm.c:213
UCHAR KdVmDataBuffer[KDVM_BUFFER_SIZE]
Definition: kdvm.c:18
PHYSICAL_ADDRESS KdVmBufferPhysicalAddress
Definition: kdvm.c:19
PFNDBGPRNT KdpDbgPrint
Definition: kdvm.c:22
static NTSTATUS KdVmNegotiateProtocolVersions(VOID)
Definition: kdvm.c:138
PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress(IN PVOID Address)
Definition: stubs.c:685
#define STATUS_CONNECTION_REFUSED
Definition: ntstatus.h:698
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
char * PCHAR
Definition: typedefs.h:51
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONGLONG QuadPart
Definition: typedefs.h:114

◆ KdDebuggerInitialize1()

NTSTATUS NTAPI KdDebuggerInitialize1 ( _In_opt_ PLOADER_PARAMETER_BLOCK LoaderBlock  LoaderBlock)

Definition at line 338 of file kdvm.c.

340{
341 /* Nothing to do */
342 KDDBGPRINT("KdDebuggerInitialize1()\n");
343 return STATUS_SUCCESS;
344}

◆ KdReceivePacket()

KDP_STATUS NTAPI KdReceivePacket ( _In_ ULONG  PacketType,
_Out_ PSTRING  MessageHeader,
_Out_ PSTRING  MessageData,
_Out_ PULONG  DataLength,
_Inout_opt_ PKD_CONTEXT  KdContext 
)

Definition at line 449 of file kdvm.c.

455{
456 KDVM_RECV_PKT_REQUEST RecvPktRequest;
457 PKDVM_RECV_PKT_RESULT RecvPktResult;
458 ULONG ReceivedSize, ExpectedSize;
460 KDDBGPRINT("KdReceivePacket(0x%lx, ...)\n", PacketType);
461
462 /* Prepare the buffer */
464
465 RtlZeroMemory(&RecvPktRequest, sizeof(RecvPktRequest));
466
467 RecvPktRequest.PacketType = PacketType;
469 RecvPktRequest.Info.KdDebuggerEnabledAvailable = 1;
470 RecvPktRequest.Info.KdDebuggerEnabled = SharedUserData->KdDebuggerEnabled;
471
472 if (MessageHeader != NULL)
473 {
474 RecvPktRequest.MessageHeader.Length = MessageHeader->Length;
475 RecvPktRequest.MessageHeader.MaximumLength = MessageHeader->MaximumLength;
476 }
477
478 if (MessageData != NULL)
479 {
480 RecvPktRequest.MessageData.Length = MessageData->Length;
481 RecvPktRequest.MessageData.MaximumLength = MessageData->MaximumLength;
482 }
483
484 if (KdContext != NULL)
485 {
486 RtlCopyMemory(&RecvPktRequest.KdContext,
487 KdContext,
488 sizeof(RecvPktRequest.KdContext));
489 }
490
491 if (!KdVmAddCommandToBuffer(KDVM_CMD_ReceivePacket, &RecvPktRequest, sizeof(RecvPktRequest)))
492 {
493 KDDBGPRINT("KdReceivePacket: Failed to add SendPacket command\n");
494 return KDP_PACKET_RESEND;
495 }
496
497 RecvPktResult = KdVmSendReceive(&ReceivedSize);
498 if (ReceivedSize < sizeof(*RecvPktResult))
499 {
500 KDDBGPRINT("KdReceivePacket: Invalid size for RecvPktResult: %lx\n", ReceivedSize);
501 return KDP_PACKET_RESEND;
502 }
503
504 ExpectedSize = sizeof(*RecvPktResult) +
505 RecvPktResult->HeaderSize +
506 RecvPktResult->DataSize;
507 if (ReceivedSize != ExpectedSize)
508 {
509 KDDBGPRINT("KdReceivePacket: Invalid size for RecvPktResult: %lu, expected %lu\n",
510 ReceivedSize, ExpectedSize);
511 return KDP_PACKET_RESEND;
512 }
513
514 if (KdContext != NULL)
515 {
516 RtlCopyMemory(KdContext,
517 &RecvPktResult->KdContext,
518 sizeof(RecvPktResult->KdContext));
519 }
520
521 Buffer = (PUCHAR)(RecvPktResult + 1);
522 if (MessageHeader != NULL)
523 {
524 MessageHeader->Length = RecvPktResult->MessageHeader.Length;
525 if ((MessageHeader->Buffer != NULL) &&
526 (MessageHeader->MaximumLength >= RecvPktResult->HeaderSize))
527 {
528 RtlCopyMemory(MessageHeader->Buffer,
529 Buffer,
530 RecvPktResult->HeaderSize);
531 }
532 else
533 {
534 KDDBGPRINT("MessageHeader not good\n");
535 }
536 }
537
538 Buffer += RecvPktResult->HeaderSize;
539 if (MessageData != NULL)
540 {
541 MessageData->Length = RecvPktResult->MessageData.Length;
542 if ((MessageData->Buffer != NULL) &&
543 (MessageData->MaximumLength >= RecvPktResult->DataSize))
544 {
545 RtlCopyMemory(MessageData->Buffer,
546 Buffer,
547 RecvPktResult->DataSize);
548 }
549 else
550 {
551 KDDBGPRINT("MessageData not good\n");
552 }
553 }
554
555 if (DataLength != NULL)
556 *DataLength = RecvPktResult->FullSize;
557
558 KDDBGPRINT("KdReceivePacket: returning status %u\n", RecvPktResult->KdStatus);
559 return RecvPktResult->KdStatus;
560}
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
Definition: bufpool.h:45
@ KDP_PACKET_RESEND
Definition: kddll.h:29
VOID NTAPI KdVmPrepareBuffer(VOID)
Definition: kdvbox.c:24
static BOOLEAN KdVmAddCommandToBuffer(_In_ UCHAR Command, _In_ PVOID Buffer, _In_ SIZE_T BufferSize)
Definition: kdvm.c:80
static const UCHAR KDVM_CMD_ReceivePacket
Definition: kdvm.c:14
static PVOID KdVmSendReceive(_Out_ PULONG ReceiveDataSize)
Definition: kdvm.c:101
#define SharedUserData
KDVM_CONTEXT KdContext
Definition: kdvm.h:109
KDVM_SENDPACKET_INFO Info
Definition: kdvm.h:106
KDVM_MARSHAL_STRING MessageHeader
Definition: kdvm.h:107
KDVM_MARSHAL_STRING MessageData
Definition: kdvm.h:108
KDVM_MARSHAL_STRING MessageData
Definition: kdvm.h:116
KDP_STATUS KdStatus
Definition: kdvm.h:118
KDVM_CONTEXT KdContext
Definition: kdvm.h:117
KDVM_MARSHAL_STRING MessageHeader
Definition: kdvm.h:115
ULONG HeaderSize
Definition: kdvm.h:120
UCHAR KdDebuggerEnabledAvailable
Definition: kdvm.h:79
BOOLEAN KdDebuggerEnabled
Definition: kdvm.h:81
UCHAR KdDebuggerNotPresent
Definition: kdvm.h:77
USHORT MaximumLength
Definition: kdvm.h:50
USHORT Length
Definition: kdvm.h:49
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define KD_DEBUGGER_NOT_PRESENT
Definition: kdfuncs.h:133

◆ KdRestore()

NTSTATUS NTAPI KdRestore ( _In_ BOOLEAN  SleepTransition)

Definition at line 262 of file kdvm.c.

264{
265 /* Nothing to do */
266 return STATUS_SUCCESS;
267}

◆ KdSave()

NTSTATUS NTAPI KdSave ( _In_ BOOLEAN  SleepTransition)

Definition at line 253 of file kdvm.c.

255{
256 /* Nothing to do */
257 return STATUS_SUCCESS;
258}

◆ KdSendPacket()

VOID NTAPI KdSendPacket ( _In_ ULONG  PacketType,
_In_ PSTRING  MessageHeader,
_In_ PSTRING  MessageData,
_Inout_ PKD_CONTEXT  KdContext 
)

Definition at line 348 of file kdvm.c.

353{
354 KDVM_SEND_PKT_REQUEST SendPktRequest;
355 PKDVM_SEND_PKT_RESULT SendPktResult;
356 ULONG ReceivedSize;
357 KDDBGPRINT("KdSendPacket(0x%lx, ...)\n", PacketType);
358
359 do
360 {
361
362 RtlZeroMemory(&SendPktRequest, sizeof(SendPktRequest));
363
364 SendPktRequest.PacketType = PacketType;
366 SendPktRequest.Info.KdDebuggerEnabledAvailable = 1;
367 SendPktRequest.Info.KdDebuggerEnabled = SharedUserData->KdDebuggerEnabled;
368
369 if (MessageHeader != NULL)
370 {
371 SendPktRequest.MessageHeader.Length = MessageHeader->Length;
372 SendPktRequest.MessageHeader.MaximumLength = MessageHeader->MaximumLength;
373 SendPktRequest.HeaderSize = MessageHeader->Length;
374 }
375
376 if (MessageData != NULL)
377 {
378 SendPktRequest.MessageData.Length = MessageData->Length;
379 SendPktRequest.MessageData.MaximumLength = MessageData->MaximumLength;
380 SendPktRequest.DataSize = MessageData->Length;
381 }
382
383 if (KdContext != NULL)
384 {
385 RtlCopyMemory(&SendPktRequest.KdContext,
386 KdContext,
387 sizeof(SendPktRequest.KdContext));
388 }
389
390
391 /* Prepare the buffer */
393
394 if (!KdVmAddCommandToBuffer(KDVM_CMD_SendPacket, &SendPktRequest, sizeof(SendPktRequest)))
395 {
396 KDDBGPRINT("KdSendPacket: Failed to add SendPacket command\n");
397 return;
398 }
399
400 if (MessageHeader != NULL)
401 {
402 if (!KdVmAddToBuffer(MessageHeader->Buffer, MessageHeader->Length))
403 {
404 KDDBGPRINT("KdSendPacket: Failed to add MessageHeader\n");
405 return;
406 }
407 }
408
409 if (MessageData != NULL)
410 {
411 if (!KdVmAddToBuffer(MessageData->Buffer, MessageData->Length))
412 {
413 KDDBGPRINT("KdSendPacket: Failed to add MessageData\n");
414 return;
415 }
416 }
417
418 SendPktResult = KdVmSendReceive(&ReceivedSize);
419 if (ReceivedSize != sizeof(*SendPktResult))
420 {
421 KDDBGPRINT("KdSendPacket: Invalid size for SendPktResult: %lx\n", ReceivedSize);
422 return;
423 }
424
425 if (KdContext != NULL)
426 {
427 RtlCopyMemory(KdContext,
428 &SendPktResult->KdContext,
429 sizeof(SendPktResult->KdContext));
430 }
431
433 if (SendPktResult->Info.KdDebuggerEnabledAvailable)
434 SharedUserData->KdDebuggerEnabled = SendPktResult->Info.KdDebuggerEnabled != 0;
435
436 if (SendPktResult->Info.RetryKdSendPacket)
437 {
438 KDDBGPRINT("KdSendPacket: RetryKdSendPacket!\n");
439 }
440
441 } while (SendPktResult->Info.RetryKdSendPacket);
442
443 KDDBGPRINT("KdSendPacket: Success!\n");
444}
static BOOLEAN KdVmAddToBuffer(_In_ PVOID Data, _In_ ULONG DataSize)
Definition: kdvm.c:61
static const UCHAR KDVM_CMD_SendPacket
Definition: kdvm.c:15
UCHAR RetryKdSendPacket
Definition: kdvm.h:78
KDVM_MARSHAL_STRING MessageData
Definition: kdvm.h:88
KDVM_CONTEXT KdContext
Definition: kdvm.h:89
KDVM_SENDPACKET_INFO Info
Definition: kdvm.h:93
KDVM_MARSHAL_STRING MessageHeader
Definition: kdvm.h:87
KDVM_CONTEXT KdContext
Definition: kdvm.h:99
KDVM_SENDPACKET_INFO Info
Definition: kdvm.h:100

◆ KdVmAddCommandToBuffer()

static BOOLEAN KdVmAddCommandToBuffer ( _In_ UCHAR  Command,
_In_ PVOID  Buffer,
_In_ SIZE_T  BufferSize 
)
static

Definition at line 80 of file kdvm.c.

84{
86
87 RtlCopyMemory(&Header.Magic, KdVmCmdMagic, sizeof(Header.Magic));
88 Header.Command = Command;
89
90 if (!KdVmAddToBuffer(&Header, sizeof(Header)))
91 return FALSE;
92
94 return FALSE;
95
96 return TRUE;
97}
Definition: Header.h:9
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static CHAR KdVmCmdMagic[]
Definition: kdvm.c:11
Definition: shell.h:41
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by KdReceivePacket(), KdSendPacket(), KdVmNegotiateProtocolVersions(), and TestConnectionOnChannel().

◆ KdVmAddToBuffer()

static BOOLEAN KdVmAddToBuffer ( _In_ PVOID  Data,
_In_ ULONG  DataSize 
)
static

Definition at line 61 of file kdvm.c.

64{
67 {
68 KDDBGPRINT("KdVmAddToBuffer: Buffer overflow! Need %lu, remaining: %lu\n",
70 return FALSE;
71 }
72
75 return TRUE;
76}
ULONG KdVmBufferPos
Definition: kdvm.c:20
#define KDVM_BUFFER_SIZE
Definition: kdvm.h:33
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755

Referenced by KdSendPacket(), and KdVmAddCommandToBuffer().

◆ KdVmDbgDumpBuffer()

VOID NTAPI KdVmDbgDumpBuffer ( _In_ PVOID  Buffer,
_In_ ULONG  Size 
)

Definition at line 43 of file kdvm.c.

46{
47 PUCHAR CurrentRow;
48 ULONG i;
49
50 CurrentRow = Buffer;
51 for (i = 0; i < (Size / 16); i++)
52 {
53 KdVmDbgDumpRow(CurrentRow, 16);
54 CurrentRow += 16;
55 }
56 KdVmDbgDumpRow(CurrentRow, (Size % 16));
57}
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
Definition: glfuncs.h:248
static VOID KdVmDbgDumpRow(_In_ PUCHAR Buffer, _In_ ULONG Size)
Definition: kdvm.c:29
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

◆ KdVmDbgDumpRow()

static VOID KdVmDbgDumpRow ( _In_ PUCHAR  Buffer,
_In_ ULONG  Size 
)
static

Definition at line 29 of file kdvm.c.

32{
33 ULONG i;
34 for (i = 0;i < Size; i++)
35 {
36 KdpDbgPrint("%02x ", Buffer[i]);
37 }
38 KdpDbgPrint("\n");
39}

Referenced by KdVmDbgDumpBuffer().

◆ KdVmNegotiateProtocolVersions()

static NTSTATUS KdVmNegotiateProtocolVersions ( VOID  )
static

Definition at line 138 of file kdvm.c.

139{
141 ULONG ReceivedSize;
142 PULONG ReceivedVersion;
143 KDDBGPRINT("KdVmNegotiateProtocolVersions()\n");
144
145 /* Prepare the buffer */
147
149 {
150 KDDBGPRINT("Failed to do VersionReport\n");
152 }
153
154 ReceivedVersion = KdVmSendReceive(&ReceivedSize);
155 if (ReceivedSize != sizeof(ULONG))
156 {
157 KDDBGPRINT("Invalid size for VersionReport: %lx\n", ReceivedSize);
159 }
160
161 if (*ReceivedVersion != KDRPC_PROTOCOL_VERSION)
162 {
163 KDDBGPRINT("Invalid Version: %lx\n", *ReceivedVersion);
164 return STATUS_CONNECTION_REFUSED; //STATUS_PROTOCOL_NOT_SUPPORTED;
165 }
166
167 return STATUS_SUCCESS;
168}
static const UCHAR KDVM_CMD_VersionReport
Definition: kdvm.c:16
#define KDRPC_PROTOCOL_VERSION
Definition: kdvm.h:31
uint32_t * PULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469

Referenced by KdDebuggerInitialize0().

◆ KdVmSendReceive()

static PVOID KdVmSendReceive ( _Out_ PULONG  ReceiveDataSize)
static

Definition at line 101 of file kdvm.c.

103{
105 PKDVM_RECEIVE_HEADER ReceiveHeader;
106
107 KdVmKdVmExchangeData(&ReceiveData, ReceiveDataSize);
108 ReceiveHeader = ReceiveData;
109
110 if (*ReceiveDataSize < sizeof(*ReceiveHeader))
111 {
112 KDDBGPRINT("KdVmSendReceive: received data too small: 0x%x\n", *ReceiveDataSize);
113 *ReceiveDataSize = 0;
114 return NULL;
115 }
116
117 if (ReceiveHeader->Id != 0x2031 /* '01' */)
118 {
119 KDDBGPRINT("KdVmSendReceive: got invalid Id: 0x%x\n", ReceiveHeader->Id);
120 *ReceiveDataSize = 0;
121 return NULL;
122 }
123
124 if (!RtlEqualMemory(ReceiveHeader->Magic, KdVmReplyMagic, 9))
125 {
126 KDDBGPRINT("KdVmSendReceive: got invalid Magic: '%*s'\n",
127 sizeof(KdVmReplyMagic), ReceiveHeader->Magic);
128 *ReceiveDataSize = 0;
129 return NULL;
130 }
131
132 *ReceiveDataSize -= sizeof(*ReceiveHeader);
133 return (PVOID)(ReceiveHeader + 1);
134}
VOID NTAPI KdVmKdVmExchangeData(_Out_ PVOID *ReceiveData, _Out_ PULONG ReceiveDataSize)
Definition: kdvbox.c:31
static CHAR KdVmReplyMagic[]
Definition: kdvm.c:12
#define RtlEqualMemory(dst, src, len)
Definition: kdvm.h:18
static ULONG ReceiveData(PINFO pInfo)
Definition: ntpclient.c:102
CHAR Magic[9]
Definition: kdvm.h:63

Referenced by KdReceivePacket(), KdSendPacket(), KdVmNegotiateProtocolVersions(), and TestConnectionOnChannel().

◆ KdVmTestConnectionWithHost()

static BOOLEAN KdVmTestConnectionWithHost ( VOID  )
static

Definition at line 213 of file kdvm.c.

214{
215 ULONG i, j;
216 KDDBGPRINT("KdVmTestConnectionWithHost()\n");
217
218 for (j = 0; j < 2; j++)
219 {
220 //VMWareRPC::OpenChannel
221 for (i = 0; i < CONNECTION_TEST_ROUNDS / 2; i++)
222 {
224 {
225 return FALSE;
226 }
227 }
228 }
229
230 return TRUE;
231}
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
Definition: glfuncs.h:250
static BOOLEAN TestConnectionOnChannel(VOID)
Definition: kdvm.c:172
#define CONNECTION_TEST_ROUNDS
Definition: kdvm.h:32

Referenced by KdDebuggerInitialize0().

◆ TestConnectionOnChannel()

static BOOLEAN TestConnectionOnChannel ( VOID  )
static

Definition at line 172 of file kdvm.c.

173{
174 UCHAR TestBuffer[KDRPC_TEST_BUFFER_SIZE];
175 PUCHAR ReceivedBuffer;
176 ULONG i, ReceivedSize;
177
178 /* Prepare the buffer */
180
181 for (i = 0; i < sizeof(TestBuffer); i++)
182 TestBuffer[i] = (UCHAR)i;
183
184 if (!KdVmAddCommandToBuffer(KDVM_CMD_TestConnection, TestBuffer, sizeof(TestBuffer)))
185 {
186 KDDBGPRINT("Failed to do TestConnection\n");
187 return FALSE;
188 }
189
190 ReceivedBuffer = KdVmSendReceive(&ReceivedSize);
191 if (ReceivedSize != sizeof(TestBuffer))
192 {
193 KDDBGPRINT("Invalid size for TestConnection: %lx\n", ReceivedSize);
194 return FALSE;
195 }
196
197 for (i = 0; i < sizeof(TestBuffer); i++)
198 {
199 if (ReceivedBuffer[i] != (UCHAR)(i ^ 0x55))
200 {
201 KDDBGPRINT("Wrong test data @ %lx, expected %x, got %x\n",
202 i, (UCHAR)(i ^ 0x55), TestBuffer[i]);
203 return FALSE;
204 }
205 }
206
207 KDDBGPRINT("TestConnectionOnChannel: success\n");
208 return TRUE;
209}
static const UCHAR KDVM_CMD_TestConnection
Definition: kdvm.c:13
#define KDRPC_TEST_BUFFER_SIZE
Definition: kdvm.h:34
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by KdVmTestConnectionWithHost().

Variable Documentation

◆ KdpDbgPrint

PFNDBGPRNT KdpDbgPrint

Definition at line 22 of file kdvm.c.

Referenced by KdDebuggerInitialize0(), and KdVmDbgDumpRow().

◆ KDVM_CMD_ReceivePacket

const UCHAR KDVM_CMD_ReceivePacket = 'r'
static

Definition at line 14 of file kdvm.c.

Referenced by KdReceivePacket().

◆ KDVM_CMD_SendPacket

const UCHAR KDVM_CMD_SendPacket = 's'
static

Definition at line 15 of file kdvm.c.

Referenced by KdSendPacket().

◆ KDVM_CMD_TestConnection

const UCHAR KDVM_CMD_TestConnection = 't'
static

Definition at line 13 of file kdvm.c.

Referenced by TestConnectionOnChannel().

◆ KDVM_CMD_VersionReport

const UCHAR KDVM_CMD_VersionReport = 'v'
static

Definition at line 16 of file kdvm.c.

Referenced by KdVmNegotiateProtocolVersions().

◆ KdVmBufferPhysicalAddress

PHYSICAL_ADDRESS KdVmBufferPhysicalAddress

Definition at line 19 of file kdvm.c.

Referenced by KdDebuggerInitialize0(), and KdVmKdVmExchangeData().

◆ KdVmBufferPos

ULONG KdVmBufferPos

Definition at line 20 of file kdvm.c.

Referenced by KdVmAddToBuffer(), KdVmKdVmExchangeData(), and KdVmPrepareBuffer().

◆ KdVmCmdMagic

CHAR KdVmCmdMagic[] = "~kdVMvA "
static

Definition at line 11 of file kdvm.c.

Referenced by KdVmAddCommandToBuffer().

◆ KdVmDataBuffer

UCHAR KdVmDataBuffer[KDVM_BUFFER_SIZE]

Definition at line 18 of file kdvm.c.

Referenced by KdDebuggerInitialize0(), KdVmAddToBuffer(), and KdVmKdVmExchangeData().

◆ KdVmReplyMagic

CHAR KdVmReplyMagic[] = "++kdVMvA "
static

Definition at line 12 of file kdvm.c.

Referenced by KdVmSendReceive().