ReactOS  0.4.14-dev-1332-g6db3d88
kdb.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for kdb.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

ULONG NTAPI KiEspFromTrapFrame (IN PKTRAP_FRAME TrapFrame)
 
VOID NTAPI KiEspToTrapFrame (IN PKTRAP_FRAME TrapFrame, IN ULONG_PTR Esp)
 
ULONG NTAPI KiSsFromTrapFrame (IN PKTRAP_FRAME TrapFrame)
 
VOID NTAPI KiSsToTrapFrame (IN PKTRAP_FRAME TrapFrame, IN ULONG Ss)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file kdb.c.

Function Documentation

◆ KiEspFromTrapFrame()

ULONG NTAPI KiEspFromTrapFrame ( IN PKTRAP_FRAME  TrapFrame)

Definition at line 18 of file kdb.c.

19 {
20  return TrapFrame->Rsp;
21 }

Referenced by KdbpTrapFrameToKdbTrapFrame(), and KiEspToTrapFrame().

◆ KiEspToTrapFrame()

VOID NTAPI KiEspToTrapFrame ( IN PKTRAP_FRAME  TrapFrame,
IN ULONG_PTR  Esp 
)

Definition at line 25 of file kdb.c.

27 {
28  KIRQL OldIrql;
29  ULONG Previous;
30 
31  /* Raise to APC_LEVEL if needed */
34 
35  /* Get the old ESP */
36  Previous = KiEspFromTrapFrame(TrapFrame);
37 
38  /* Check if this is user-mode */
39  if ((TrapFrame->SegCs & MODE_MASK))
40  {
41  /* Write it directly */
42  TrapFrame->Rsp = Esp;
43  }
44  else
45  {
46  /* Don't allow ESP to be lowered, this is illegal */
47  if (Esp < Previous) KeBugCheckEx(SET_OF_INVALID_CONTEXT,
48  Esp,
49  Previous,
50  (ULONG_PTR)TrapFrame,
51  0);
52 
53  /* Create an edit frame, check if it was alrady */
54  if (!(TrapFrame->SegCs & FRAME_EDITED))
55  {
56  /* Update the value */
57  TrapFrame->Rsp = Esp;
58  }
59  else
60  {
61  /* Check if ESP changed */
62  if (Previous != Esp)
63  {
64  /* Save CS */
65  TrapFrame->SegCs &= ~FRAME_EDITED;
66 
67  /* Save ESP */
68  TrapFrame->Rsp = Esp;
69  }
70  }
71  }
72 
73  /* Restore IRQL */
75 
76 }
ULONG NTAPI KiEspFromTrapFrame(IN PKTRAP_FRAME TrapFrame)
Definition: kdb.c:18
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define MODE_MASK
Definition: orders.h:326
uint32_t ULONG_PTR
Definition: typedefs.h:64
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
unsigned int ULONG
Definition: retypes.h:1
#define FRAME_EDITED
Definition: ke.h:64
#define APC_LEVEL
Definition: env_spec_w32.h:695
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:107

Referenced by KdbpKdbTrapFrameToTrapFrame().

◆ KiSsFromTrapFrame()

ULONG NTAPI KiSsFromTrapFrame ( IN PKTRAP_FRAME  TrapFrame)

Definition at line 80 of file kdb.c.

81 {
82  if (TrapFrame->SegCs & MODE_MASK)
83  {
84  /* User mode, return the User SS */
85  return TrapFrame->SegSs | RPL_MASK;
86  }
87  else
88  {
89  /* Kernel mode */
90  return KGDT64_SYS_TSS;
91  }
92 }
#define MODE_MASK
Definition: orders.h:326
#define RPL_MASK
Definition: ketypes.h:69
#define KGDT64_SYS_TSS
Definition: ketypes.h:77

Referenced by KdbpTrapFrameToKdbTrapFrame().

◆ KiSsToTrapFrame()

VOID NTAPI KiSsToTrapFrame ( IN PKTRAP_FRAME  TrapFrame,
IN ULONG  Ss 
)

Definition at line 96 of file kdb.c.

98 {
99  /* Remove the high-bits */
100  Ss &= 0xFFFF;
101 
102  if (TrapFrame->SegCs & MODE_MASK)
103  {
104  /* Usermode, save the User SS */
105  TrapFrame->SegSs = Ss | RPL_MASK;
106  }
107 
108 }
#define MODE_MASK
Definition: orders.h:326
#define RPL_MASK
Definition: ketypes.h:69

Referenced by KdbpKdbTrapFrameToTrapFrame().