3 Copyright (c) 1998-2001 Klaus P. Gerlicher
24 15-Nov-2000: general cleanup of source files
28 This file may be distributed under the terms of the GNU Public License.
32 ////////////////////////////////////////////////////
38 ////////////////////////////////////////////////////
41 void DeinstallHooks(void);
43 ////////////////////////////////////////////////////
47 ////////////////////////////////////////////////////
52 //PIDTENTRY pidt[256];
53 IDTENTRY oldidt
[256]={{0},};
55 IDTENTRY idt_snapshot
[256]={{0},};
57 // processor flag for interrupt suspension
60 ////////////////////////////////////////////////////
64 //*************************************************************************
67 //*************************************************************************
72 save_flags(ulOldFlags
);
78 //*************************************************************************
81 //*************************************************************************
86 restore_flags(ulOldFlags
);
91 //*************************************************************************
94 //*************************************************************************
95 ULONG
SetGlobalInt(ULONG dwInt
,ULONG NewIntHandler
)
99 struct IdtEntry
* pidt
;
100 struct IdtEntry oldidt
;
104 // get linear location of IDT
105 __asm__("sidt %0":"=m" (idt
));
107 // get pointer to idte for int 3
108 pidt
=((struct IdtEntry
*)((idt
[1]<<16)|((idt
[0]>>16)&0x0000FFFF)))+dwInt
;
112 // set new handler address
113 pidt
->HiOffset
=(USHORT
)(((ULONG
)NewIntHandler
)>>16);
114 pidt
->LoOffset
=(USHORT
)(((ULONG
)NewIntHandler
)&0x0000FFFF);
116 DPRINT((0,"new INT(%0.2x) handler = %0.4x:%x\n",dwInt
,pidt
->SegSel
,(pidt
->HiOffset
<<16)|(pidt
->LoOffset
&0x0000FFFF)));
118 OldIntHandler
=(oldidt
.HiOffset
<<16)|(oldidt
.LoOffset
&0x0000FFFF);
120 DPRINT((0,"old INT(%0.2x) handler = %0.4x:%x\n",dwInt
,pidt
->SegSel
,OldIntHandler
));
124 return OldIntHandler
;
127 //*************************************************************************
130 //*************************************************************************
131 void TakeIdtSnapshot(void)
134 struct IdtEntry
* pidt
;
136 __asm__("sidt %0":"=m" (idt
));
138 // get pointer to idte for int 3
139 pidt
=((struct IdtEntry
*)((idt
[1]<<16)|((idt
[0]>>16)&0x0000FFFF)));
143 DPRINT((11,"TakeIdtSnapShot(): saving vector %u\n",i
));
144 if(IsRangeValid((ULONG
)pidt
,sizeof(*pidt
)) )
146 DPRINT((11,"TakeIdtSnapShot(): vector %u valid\n",i
));
147 idt_snapshot
[i
] = *pidt
++;
152 //*************************************************************************
155 //*************************************************************************
156 void RestoreIdt(void)
159 struct IdtEntry
* pidt
;
161 __asm__("sidt %0":"=m" (idt
));
163 // get pointer to idte for int 3
164 pidt
=((struct IdtEntry
*)((idt
[1]<<16)|((idt
[0]>>16)&0x0000FFFF)));
168 DPRINT((11,"TakeIdtSnapShot(): restoring vector %u\n",i
));
169 if(IsRangeValid((ULONG
)pidt
,sizeof(*pidt
)) )
171 DPRINT((11,"TakeIdtSnapShot(): vector %u valid\n",i
));
172 *pidt
++ = idt_snapshot
[i
];