ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

kdb.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:       See COPYING in the top level directory
00003  * PROJECT:         ReactOS kernel
00004  * FILE:            ntoskrnl/kdbg/amd64/kdb.c
00005  * PURPOSE:         Kernel Debugger
00006  * PROGRAMMERS:
00007  */
00008 
00009 
00010 /* INCLUDES ******************************************************************/
00011 
00012 #include <ntoskrnl.h>
00013 #define NDEBUG
00014 #include <debug.h>
00015 
00016 ULONG
00017 NTAPI
00018 KiEspFromTrapFrame(IN PKTRAP_FRAME TrapFrame)
00019 {
00020     return TrapFrame->Rsp;
00021 }
00022 
00023 VOID
00024 NTAPI
00025 KiEspToTrapFrame(IN PKTRAP_FRAME TrapFrame,
00026                  IN ULONG_PTR Esp)
00027 {
00028     KIRQL OldIrql;
00029     ULONG Previous;
00030 
00031     /* Raise to APC_LEVEL if needed */
00032     OldIrql = KeGetCurrentIrql();
00033     if (OldIrql < APC_LEVEL) KeRaiseIrql(APC_LEVEL, &OldIrql);
00034 
00035     /* Get the old ESP */
00036     Previous = KiEspFromTrapFrame(TrapFrame);
00037 
00038     /* Check if this is user-mode  */
00039     if ((TrapFrame->SegCs & MODE_MASK))
00040     {
00041         /* Write it directly */
00042         TrapFrame->Rsp = Esp;
00043     }
00044     else
00045     {
00046         /* Don't allow ESP to be lowered, this is illegal */
00047         if (Esp < Previous) KeBugCheckEx(SET_OF_INVALID_CONTEXT,
00048                                          Esp,
00049                                          Previous,
00050                                          (ULONG_PTR)TrapFrame,
00051                                          0);
00052 
00053         /* Create an edit frame, check if it was alrady */
00054         if (!(TrapFrame->SegCs & FRAME_EDITED))
00055         {
00056             /* Update the value */
00057             TrapFrame->Rsp = Esp;
00058         }
00059         else
00060         {
00061             /* Check if ESP changed */
00062             if (Previous != Esp)
00063             {
00064                 /* Save CS */
00065                 TrapFrame->SegCs &= ~FRAME_EDITED;
00066 
00067                 /* Save ESP */
00068                 TrapFrame->Rsp = Esp;
00069             }
00070         }
00071     }
00072 
00073     /* Restore IRQL */
00074     if (OldIrql < APC_LEVEL) KeLowerIrql(OldIrql);
00075 
00076 }
00077 
00078 ULONG
00079 NTAPI
00080 KiSsFromTrapFrame(IN PKTRAP_FRAME TrapFrame)
00081 {
00082     if (TrapFrame->SegCs & MODE_MASK)
00083     {
00084         /* User mode, return the User SS */
00085         return TrapFrame->SegSs | RPL_MASK;
00086     }
00087     else
00088     {
00089         /* Kernel mode */
00090         return KGDT64_SYS_TSS;
00091     }
00092 }
00093 
00094 VOID
00095 NTAPI
00096 KiSsToTrapFrame(IN PKTRAP_FRAME TrapFrame,
00097                 IN ULONG Ss)
00098 {
00099         /* Remove the high-bits */
00100     Ss &= 0xFFFF;
00101 
00102     if (TrapFrame->SegCs & MODE_MASK)
00103     {
00104         /* Usermode, save the User SS */
00105         TrapFrame->SegSs = Ss | RPL_MASK;
00106     }
00107 
00108 }
00109 
00110 
00111 

Generated on Sat May 26 2012 04:36:16 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.