ReactOS  0.4.14-dev-55-g2da92ac
hooks.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  IdtEntry
 

Typedefs

typedef struct IdtEntry IDTENTRY
 
typedef struct IdtEntryPIDTENTRY
 

Functions

void DeinstallHooks (void)
 
void MaskIrqs (void)
 
void UnmaskIrqs (void)
 
ULONG SetGlobalInt (ULONG dwInt, ULONG NewIntHandler)
 
ULONG GetIRQVector (ULONG dwInt)
 
void TakeIdtSnapshot (void)
 
void RestoreIdt (void)
 

Typedef Documentation

◆ IDTENTRY

◆ PIDTENTRY

Function Documentation

◆ DeinstallHooks()

void DeinstallHooks ( void  )

◆ GetIRQVector()

ULONG GetIRQVector ( ULONG  dwInt)

◆ MaskIrqs()

void MaskIrqs ( void  )

Definition at line 68 of file hooks.c.

69 {
70  ENTER_FUNC();
71 
73  cli();
74 
75  LEAVE_FUNC();
76 }
#define LEAVE_FUNC()
Definition: debug.h:43
#define save_flags(x)
Definition: utils.h:285
RECT cli
Definition: sndrec32.cpp:79
ULONG ulOldFlags
Definition: hooks.c:58
#define ENTER_FUNC()
Definition: debug.h:42

Referenced by CheckLoadAbort(), DeInstallDblFltHook(), DeInstallGlobalKeyboardHook(), DeInstallGPFaultHook(), DeInstallInt3Hook(), DeInstallIntEHook(), DeInstallTraceHook(), InstallDblFltHook(), InstallGlobalKeyboardHook(), InstallGPFaultHook(), InstallInt3Hook(), InstallIntEHook(), and InstallTraceHook().

◆ RestoreIdt()

void RestoreIdt ( void  )

Definition at line 156 of file hooks.c.

157 {
158  ULONG idt[2],i;
159  struct IdtEntry* pidt;
160 
161  __asm__("sidt %0":"=m" (idt));
162 
163  // get pointer to idte for int 3
164  pidt=((struct IdtEntry*)((idt[1]<<16)|((idt[0]>>16)&0x0000FFFF)));
165 
166  for(i=0;i<256;i++)
167  {
168  DPRINT((11,"TakeIdtSnapShot(): restoring vector %u\n",i));
169  if(IsRangeValid((ULONG)pidt,sizeof(*pidt)) )
170  {
171  DPRINT((11,"TakeIdtSnapShot(): vector %u valid\n",i));
172  *pidt++ = idt_snapshot[i];
173  }
174  }
175 }
IDTENTRY idt_snapshot[256]
Definition: hooks.c:55
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
__asm__("\t.globl GetPhys\n" "GetPhys:\t\n" "mflr 0\n\t" "stwu 0,-16(1)\n\t" "mfmsr 5\n\t" "andi. 6,5,0xffef\n\t" "mtmsr 6\n\t" "isync\n\t" "sync\n\t" "lwz 3,0(3)\n\t" "mtmsr 5\n\t" "isync\n\t" "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" "blr")
void DPRINT(...)
Definition: polytest.cpp:61
Definition: hooks.h:42
BOOLEAN IsRangeValid(ULONG Addr, ULONG Length)
Definition: utils.c:735
unsigned int ULONG
Definition: retypes.h:1

Referenced by CleanUpPICE().

◆ SetGlobalInt()

ULONG SetGlobalInt ( ULONG  dwInt,
ULONG  NewIntHandler 
)

Definition at line 95 of file hooks.c.

96 {
97  ULONG idt[2];
99  struct IdtEntry* pidt;
100  struct IdtEntry oldidt;
101 
102  ENTER_FUNC();
103 
104  // get linear location of IDT
105  __asm__("sidt %0":"=m" (idt));
106 
107  // get pointer to idte for int 3
108  pidt=((struct IdtEntry*)((idt[1]<<16)|((idt[0]>>16)&0x0000FFFF)))+dwInt;
109 
110  oldidt=*pidt;
111 
112  // set new handler address
113  pidt->HiOffset=(USHORT)(((ULONG)NewIntHandler)>>16);
114  pidt->LoOffset=(USHORT)(((ULONG)NewIntHandler)&0x0000FFFF);
115 
116  DPRINT((0,"new INT(%0.2x) handler = %0.4x:%x\n",dwInt,pidt->SegSel,(pidt->HiOffset<<16)|(pidt->LoOffset&0x0000FFFF)));
117 
118  OldIntHandler=(oldidt.HiOffset<<16)|(oldidt.LoOffset&0x0000FFFF);
119 
120  DPRINT((0,"old INT(%0.2x) handler = %0.4x:%x\n",dwInt,pidt->SegSel,OldIntHandler));
121 
122  LEAVE_FUNC();
123 
124  return OldIntHandler;
125 }
#define LEAVE_FUNC()
Definition: debug.h:43
USHORT SegSel
Definition: hooks.h:45
__asm__("\t.globl GetPhys\n" "GetPhys:\t\n" "mflr 0\n\t" "stwu 0,-16(1)\n\t" "mfmsr 5\n\t" "andi. 6,5,0xffef\n\t" "mtmsr 6\n\t" "isync\n\t" "sync\n\t" "lwz 3,0(3)\n\t" "mtmsr 5\n\t" "isync\n\t" "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" "blr")
void DPRINT(...)
Definition: polytest.cpp:61
Definition: hooks.h:42
USHORT HiOffset
Definition: hooks.h:47
static DWORD OldIntHandler
Definition: mouse32.c:71
unsigned short USHORT
Definition: pedump.c:61
USHORT LoOffset
Definition: hooks.h:44
IDTENTRY oldidt[256]
Definition: hooks.c:53
unsigned int ULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42

Referenced by DeInstallDblFltHook(), DeInstallGlobalKeyboardHook(), DeInstallGPFaultHook(), DeInstallInt3Hook(), DeInstallIntEHook(), DeInstallTraceHook(), InstallDblFltHook(), InstallGlobalKeyboardHook(), InstallGPFaultHook(), InstallInt3Hook(), InstallIntEHook(), and InstallTraceHook().

◆ TakeIdtSnapshot()

void TakeIdtSnapshot ( void  )

Definition at line 131 of file hooks.c.

132 {
133  ULONG idt[2],i;
134  struct IdtEntry* pidt;
135 
136  __asm__("sidt %0":"=m" (idt));
137 
138  // get pointer to idte for int 3
139  pidt=((struct IdtEntry*)((idt[1]<<16)|((idt[0]>>16)&0x0000FFFF)));
140 
141  for(i=0;i<256;i++)
142  {
143  DPRINT((11,"TakeIdtSnapShot(): saving vector %u\n",i));
144  if(IsRangeValid((ULONG)pidt,sizeof(*pidt)) )
145  {
146  DPRINT((11,"TakeIdtSnapShot(): vector %u valid\n",i));
147  idt_snapshot[i] = *pidt++;
148  }
149  }
150 }
IDTENTRY idt_snapshot[256]
Definition: hooks.c:55
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
__asm__("\t.globl GetPhys\n" "GetPhys:\t\n" "mflr 0\n\t" "stwu 0,-16(1)\n\t" "mfmsr 5\n\t" "andi. 6,5,0xffef\n\t" "mtmsr 6\n\t" "isync\n\t" "sync\n\t" "lwz 3,0(3)\n\t" "mtmsr 5\n\t" "isync\n\t" "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" "blr")
void DPRINT(...)
Definition: polytest.cpp:61
Definition: hooks.h:42
BOOLEAN IsRangeValid(ULONG Addr, ULONG Length)
Definition: utils.c:735
unsigned int ULONG
Definition: retypes.h:1

Referenced by InitPICE().

◆ UnmaskIrqs()

void UnmaskIrqs ( void  )