ReactOS  0.4.15-dev-3173-g40ee59d
kdlock.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: ntoskrnl/kd64/kdlock.c
5  * PURPOSE: KD64 Port Lock and Breakin Support
6  * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 /* PRIVATE FUNCTIONS *********************************************************/
16 
17 VOID
18 NTAPI
20 {
21  /* Acquire the lock */
23 }
24 
25 VOID
26 NTAPI
28 {
29  /* Release the lock */
31 }
32 
33 BOOLEAN
34 NTAPI
36 {
37  BOOLEAN DoBreak = FALSE;
38 
39  /* First make sure that KD is enabled */
41  {
42  /* Check if a CTRL-C is in the queue */
44  {
45  /* Set it and prepare for break */
46  DoBreak = TRUE;
48  }
49  else
50  {
51  /* Now get a packet */
53  NULL,
54  NULL,
55  NULL,
57  {
58  /* Successful breakin */
59  DoBreak = TRUE;
60  }
61  }
62  }
63 
64  /* Tell the caller to do a break */
65  return DoBreak;
66 }
67 
68 /* PUBLIC FUNCTIONS **********************************************************/
69 
70 /*
71  * @implemented
72  */
73 BOOLEAN
74 NTAPI
76 {
77  BOOLEAN DoBreak = FALSE, Enable;
78 
79  /* First make sure that KD is enabled */
81  {
82  /* Disable interrupts */
84 
85  /* Check if a CTRL-C is in the queue */
87  {
88  /* Set it and prepare for break */
90  DoBreak = TRUE;
92  }
93  else
94  {
95  KIRQL OldIrql;
96  /* Try to acquire the lock */
99  {
100  /* Now get a packet */
102  NULL,
103  NULL,
104  NULL,
106  {
107  /* Successful breakin */
108  DoBreak = TRUE;
110  }
111 
112  /* Let go of the port */
113  KdpPortUnlock();
114  }
116  }
117 
118  /* Re-enable interrupts */
120  }
121 
122  /* Tell the caller to do a break */
123  return DoBreak;
124 }
BOOLEAN KdDebuggerEnabled
Definition: kddata.c:83
#define KdPacketReceived
Definition: kddll.h:5
#define TRUE
Definition: types.h:120
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
KDP_STATUS NTAPI KdReceivePacket(IN ULONG PacketType, OUT PSTRING MessageHeader, OUT PSTRING MessageData, OUT PULONG DataLength, IN OUT PKD_CONTEXT KdContext)
Definition: kddll.c:80
KSPIN_LOCK KdpDebuggerLock
Definition: kddata.c:67
VOID NTAPI KdpPortUnlock(VOID)
Definition: kdlock.c:27
UCHAR KIRQL
Definition: env_spec_w32.h:591
BOOLEAN KdpControlCPressed
Definition: kddata.c:68
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
FORCEINLINE BOOLEAN KeDisableInterrupts(VOID)
Definition: ke.h:235
KD_CONTEXT KdpContext
Definition: kddata.c:65
KIRQL OldIrql
Definition: mm.h:1502
VOID NTAPI KdpPortLock(VOID)
Definition: kdlock.c:19
BOOLEAN KdpControlCPending
Definition: windbgkd.h:227
BOOLEAN NTAPI KdPollBreakIn(VOID)
Definition: kdlock.c:75
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
VOID FASTCALL KiReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:298
FORCEINLINE VOID KeRestoreInterrupts(BOOLEAN WereEnabled)
Definition: ke.h:250
#define NULL
Definition: types.h:112
VOID FASTCALL KiAcquireSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:287
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
BOOLEAN NTAPI KdpPollBreakInWithPortLock(VOID)
Definition: kdlock.c:35
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39
BOOLEAN FASTCALL KeTryToAcquireSpinLockAtDpcLevel(IN OUT PKSPIN_LOCK SpinLock)
Definition: spinlock.c:309
#define PACKET_TYPE_KD_POLL_BREAKIN
Definition: windbgkd.h:49