xref: /reactos/drivers/base/kdvm/kdvm.h (revision b84f2a1c)
1 /*
2  * COPYRIGHT:       GPL, see COPYING in the top level directory
3  * PROJECT:         ReactOS kernel
4  * FILE:            drivers/base/kdvm/kdvm.h
5  * PURPOSE:         Base definitions for the kernel debugger.
6  * PROGRAMMER:      Timo Kreuzer (timo.kreuzer@reactos.org)
7  */
8 
9 #ifndef _KDDLL_H_
10 #define _KDDLL_H_
11 
12 #define NOEXTAPI
13 #include <ntifs.h>
14 #include <windbgkd.h>
15 #include <arc/arc.h>
16 
17 #undef RtlEqualMemory
18 #define RtlEqualMemory(dst, src, len) (RtlCompareMemory((dst), (src), (len)) == (len))
19 
20 //#define KDDEBUG /* uncomment to enable debugging this dll */
21 
22 typedef ULONG (*PFNDBGPRNT)(const char *Format, ...);
23 extern PFNDBGPRNT KdpDbgPrint;
24 
25 #ifndef KDDEBUG
26 #define KDDBGPRINT(...)
27 #else
28 #define KDDBGPRINT KdpDbgPrint
29 #endif
30 
31 #define KDRPC_PROTOCOL_VERSION 0x101
32 #define CONNECTION_TEST_ROUNDS 2 /*100*/
33 #define KDVM_BUFFER_SIZE (131072 + 1024)
34 #define KDRPC_TEST_BUFFER_SIZE 512
35 
36 extern UCHAR KdVmDataBuffer[KDVM_BUFFER_SIZE];
37 extern PHYSICAL_ADDRESS KdVmBufferPhysicalAddress;
38 extern ULONG KdVmBufferPos;
39 
40 typedef enum
41 {
42     KDP_PACKET_RECEIVED = 0,
43     KDP_PACKET_TIMEOUT = 1,
44     KDP_PACKET_RESEND = 2
45 } KDP_STATUS;
46 
47 typedef struct _KDVM_MARSHAL_STRING
48 {
49     USHORT Length;
50     USHORT MaximumLength;
51 } KDVM_MARSHAL_STRING;
52 
53 #pragma pack(push,1)
54 typedef struct
55 {
56     CHAR Magic[8];
57     UCHAR Command;
58 } KDVM_CMD_HEADER;
59 
60 typedef struct
61 {
62     USHORT Id;
63     CHAR Magic[9];
64 } KDVM_RECEIVE_HEADER, *PKDVM_RECEIVE_HEADER;
65 
66 typedef struct _KDVM_CONTEXT
67 {
68     ULONG   RetryCount;
69     BOOLEAN BreakInRequested;
70     UCHAR align;
71 } KDVM_CONTEXT, *PKDVM_CONTEXT;
72 
73 typedef struct
74 {
75     struct
76     {
77         UCHAR KdDebuggerNotPresent : 1;
78         UCHAR RetryKdSendPacket : 1;
79         UCHAR KdDebuggerEnabledAvailable : 1;
80     };
81     BOOLEAN KdDebuggerEnabled;
82     USHORT Unused;
83 } KDVM_SENDPACKET_INFO;
84 
85 typedef struct _KDVM_SEND_PKT_REQUEST
86 {
87     KDVM_MARSHAL_STRING MessageHeader;
88     KDVM_MARSHAL_STRING MessageData;
89     KDVM_CONTEXT KdContext;
90     ULONG PacketType;
91     ULONG HeaderSize;
92     ULONG DataSize;
93     KDVM_SENDPACKET_INFO Info;
94 } KDVM_SEND_PKT_REQUEST, *PKDVM_SEND_PKT_REQUEST;
95 
96 typedef struct _KDVM_SEND_PKT_RESULT
97 {
98     UCHAR CommandType;
99     KDVM_CONTEXT KdContext;
100     KDVM_SENDPACKET_INFO Info;
101 } KDVM_SEND_PKT_RESULT, *PKDVM_SEND_PKT_RESULT;
102 
103 typedef struct
104 {
105     ULONG PacketType;
106     KDVM_SENDPACKET_INFO Info;
107     KDVM_MARSHAL_STRING MessageHeader;
108     KDVM_MARSHAL_STRING MessageData;
109     KDVM_CONTEXT KdContext;
110 } KDVM_RECV_PKT_REQUEST;
111 
112 typedef struct
113 {
114     UCHAR CommandType;
115     KDVM_MARSHAL_STRING MessageHeader;
116     KDVM_MARSHAL_STRING MessageData;
117     KDVM_CONTEXT KdContext;
118     KDP_STATUS KdStatus;
119     ULONG FullSize;
120     ULONG HeaderSize;
121     ULONG DataSize;
122     KDVM_SENDPACKET_INFO Info;
123 } KDVM_RECV_PKT_RESULT, *PKDVM_RECV_PKT_RESULT;
124 #pragma pack(pop)
125 
126 VOID
127 NTAPI
128 KdVmDbgDumpBuffer(
129     _In_ PVOID Buffer,
130     _In_ ULONG Size);
131 
132 VOID
133 FASTCALL
134 KdVmExchange(
135     _In_ ULONG_PTR PhysicalAddress,
136     _In_ SIZE_T BufferSize);
137 
138 VOID
139 NTAPI
140 KdVmPrepareBuffer(
141     VOID);
142 
143 VOID
144 NTAPI
145 KdVmKdVmExchangeData(
146     _Out_ PVOID* ReceiveData,
147     _Out_ PULONG ReceiveDataSize);
148 
149 
150 #endif /* _KDDLL_H_ */
151