ReactOS  0.4.13-dev-650-g34bf247
trace.c
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) 1998-2001 Klaus P. Gerlicher
4 
5 Module Name:
6 
7  trace.c
8 
9 Abstract:
10 
11 Environment:
12 
13  Kernel mode only
14 
15 Author:
16 
17  Klaus P. Gerlicher
18 
19 Revision History:
20 
21  19-Aug-1998: created
22 
23 Copyright notice:
24 
25  This file may be distributed under the terms of the GNU Public License.
26 
27 --*/
28 
30 // INCLUDES
32 #include "remods.h"
33 
34 #include "precomp.h"
35 
36 extern void NewInt31Handler(void);
37 
38 void DeInstallTraceHook(void);
39 
40 volatile ULONG OldInt1Handler=0;
41 
43 {
44  ULONG LocalInt1Handler;
45 
46  DPRINT((0,"InstallTraceHook(OldInt1Handler=%0.8x)...\n",OldInt1Handler));
47 
48  MaskIrqs();
49  if(!OldInt1Handler)
50  {
51  __asm__("mov $NewInt1Handler,%0"
52  :"=r" (LocalInt1Handler)
53  :
54  :"eax");
55  OldInt1Handler=SetGlobalInt(0x01,(ULONG)LocalInt1Handler);
56  }
57  UnmaskIrqs();
58  return TRUE;
59 }
60 
61 //this asm function must be at least second in the file. otherwise gcc does not
62 //generate correct code.
63 __asm__("\n\t \
64 NewInt1Handler:\n\t \
65  pushl %eax\n\t \
66  movl %dr6,%eax\n\t \
67  testl $(1<<14),%eax\n\t \
68  jz exceptionnotsinglestep\n\t \
69 \n\t \
70  popl %eax\n\t \
71  pushl $" STR(REASON_SINGLESTEP) "\n\t \
72  jmp NewInt31Handler\n\t \
73 \n\t \
74 exceptionnotsinglestep:\n\t \
75  popl %eax\n\t \
76  pushl $" STR(REASON_HARDWARE_BP) "\n\t \
77  jmp NewInt31Handler\n\t \
78 ");
79 
81 {
82  DPRINT((0,"DeInstallTraceHook(OldInt1Handler=%0.8x)...\n",OldInt1Handler));
83 
84  MaskIrqs();
85  if(OldInt1Handler)
86  {
88  OldInt1Handler = 0;
89  }
90  UnmaskIrqs();
91 }
#define TRUE
Definition: types.h:120
ULONG SetGlobalInt(ULONG dwInt, ULONG NewIntHandler)
Definition: hooks.c:95
#define STR(x)
Definition: utils.h:34
#define REASON_HARDWARE_BP
Definition: shell.h:76
unsigned char BOOLEAN
BOOLEAN InstallTraceHook(void)
Definition: trace.c:42
void DPRINT(...)
Definition: polytest.cpp:61
void MaskIrqs(void)
Definition: hooks.c:68
__asm__("\n\t \ NewInt1Handler:\n\t \ pushl %eax\n\t \ movl %dr6,%eax\n\t \ testl $(1<<14),%eax\n\t \ jz exceptionnotsinglestep\n\t \ \n\t \ popl %eax\n\t \ pushl $" STR(REASON_SINGLESTEP) "\n\t \ jmp NewInt31Handler\n\t \ \n\t \ exceptionnotsinglestep:\n\t \ popl %eax\n\t \ pushl $" STR(REASON_HARDWARE_BP) "\n\t \ jmp NewInt31Handler\n\t \ ")
void DeInstallTraceHook(void)
Definition: trace.c:80
volatile ULONG OldInt1Handler
Definition: trace.c:40
#define REASON_SINGLESTEP
Definition: shell.h:72
void NewInt31Handler(void)
unsigned int ULONG
Definition: retypes.h:1
void UnmaskIrqs(void)
Definition: hooks.c:82