ReactOS  0.4.12-dev-934-g9a4676f
dblflt.c
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) 1998-2001 Klaus P. Gerlicher
4 
5 Module Name:
6 
7  dblflt.c
8 
9 Abstract:
10 
11  handle double faults on x86
12 
13 Environment:
14 
15  LINUX 2.2.X
16  Kernel mode only
17 
18 Author:
19 
20  Klaus P. Gerlicher
21 
22 Revision History:
23 
24  13-Nov-1999: created
25  15-Nov-2000: general cleanup of source files
26 
27 Copyright notice:
28 
29  This file may be distributed under the terms of the GNU Public License.
30 
31 --*/
32 
34 // INCLUDES
36 #include "remods.h"
37 #include "precomp.h"
38 
40 // GLOBALS
43 
45 // FUNCTIONS
47 
48 //*************************************************************************
49 // HandleDoubleFault()
50 //
51 //*************************************************************************
53 {
54  DPRINT((0,"HandleDoubleFault(): ptr = %x\n",ptr));
55 }
56 
57 
58 //*************************************************************************
59 // NewDblFltHandler()
60 //
61 //*************************************************************************
62 __asm__ (" \
63 NewDblFltHandler:\n\t \
64  pushfl\n\t \
65  cli;\n\t \
66  cld;\n\t \
67  pushal;\n\t \
68  pushl %ds;\n\t \
69 \n\t \
70  // setup default data selectors\n\t \
71  movw %ss,%ax\n\t \
72  movw %ax,%ds\n\t \
73 \n\t \
74  // get frame ptr\n\t \
75  lea 40(%esp),%eax\n\t \
76  pushl %eax\n\t \
77  call _HandleDoubleFault\n\t \
78  addl $4,%esp\n\t \
79 \n\t \
80  popl %ds\n\t \
81  popal\n\t \
82  popfl\n\t \
83  // remove error code from stack and replace with reason code\n\t \
84  movl $" STR(REASON_DOUBLE_FAULT) ",(%esp)\n\t \
85  // call debugger loop\n\t \
86  jmp NewInt31Handler\n\t");
87 
88 
89 //*************************************************************************
90 // InstallDblFltHook()
91 //
92 //*************************************************************************
94 {
95  ULONG LocalDblFltHandler;
96 
97  ENTER_FUNC();
98 
99  MaskIrqs();
100  if(!OldDblFltHandler)
101  {
102  __asm__("mov $NewDblFltHandler,%0"
103  :"=r" (LocalDblFltHandler)
104  :
105  :"eax");
106  OldDblFltHandler=SetGlobalInt(0x08,(ULONG)LocalDblFltHandler);
107  }
108  UnmaskIrqs();
109 
110  LEAVE_FUNC();
111 }
112 
113 //*************************************************************************
114 // DeInstallDblFltHook()
115 //
116 //*************************************************************************
118 {
119  ENTER_FUNC();
120 
121  MaskIrqs();
122  if(OldDblFltHandler)
123  {
127  }
128  UnmaskIrqs();
129 
130  LEAVE_FUNC();
131 }
132 
133 // EOF
#define TRUE
Definition: types.h:120
#define REASON_DOUBLE_FAULT
Definition: shell.h:77
void InstallDblFltHook(void)
Definition: dblflt.c:93
ULONG SetGlobalInt(ULONG dwInt, ULONG NewIntHandler)
Definition: hooks.c:95
#define LEAVE_FUNC()
Definition: debug.h:43
#define STR(x)
Definition: utils.h:34
void HandleDoubleFault(FRAME *ptr)
Definition: dblflt.c:52
static PVOID ptr
Definition: dispmode.c:27
void DPRINT(...)
Definition: polytest.cpp:61
void MaskIrqs(void)
Definition: hooks.c:68
ULONG OldDblFltHandler
Definition: dblflt.c:42
BOOLEAN RemoveAllSWBreakpoints(BOOLEAN bEvenPermanents)
Definition: bp.c:463
void DeInstallDblFltHook(void)
Definition: dblflt.c:117
__asm__(" \ NewDblFltHandler:\n\t \ pushfl\n\t \ cli;\n\t \ cld;\n\t \ pushal;\n\t \ pushl %ds;\n\t \ \n\t \ // setup default data selectors\n\t \ movw %ss,%ax\n\t \ movw %ax,%ds\n\t \ \n\t \ // get frame ptr\n\t \ lea 40(%esp),%eax\n\t \ pushl %eax\n\t \ call _HandleDoubleFault\n\t \ addl $4,%esp\n\t \ \n\t \ popl %ds\n\t \ popal\n\t \ popfl\n\t \ // remove error code from stack and replace with reason code\n\t \ movl $" STR(REASON_DOUBLE_FAULT) ",(%esp)\n\t \ // call debugger loop\n\t \ jmp NewInt31Handler\n\t")
unsigned int ULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42
Definition: i386bug.c:6
void UnmaskIrqs(void)
Definition: hooks.c:82