Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

accessing hardware 1

Status
Not open for further replies.

nicovda

IS-IT--Management
Oct 4, 2004
19
0
0
BE
Hi,

I'm trying to build an interrupt handler that directly accesses hardware, patching into the original interrupt handler (int 9). While reviewing documentation on the subject, it appears that actual windows operating systems, working in protected mode, won't allow me to:

- use the cli and sti functions
- change the interrupt vector table
- use all other nete functions that access hardware and memory

and thus it would be impossible to achieve what I want.

Can someone explain why this is, or give me a solution to that?

Thanks in advance.
 
Hi nico,

To access low level hardware i recommend you to boot your computer from the old plain DOS, you can boot with a diskette or in Windows 95, another options are QNX and of course Linux,

regards,

Rick
 
Thanks rwong,

but actually I am trying to build an application (which would open from windows) that could acces directly the data from the keyboard, as it could have been easy to do with the old processors by writing my own int 9 interrupt handler.

Unfortunately, this seems quite difficult to achieve with today's windows platform.

Any ideas how to bypass the OS?
 
Just to give one simple example why Windows isn't keen on letting you do this: Catching keyboard presses directly at the hardware level is the ideal way to log people's key-strokes, and find out what passwords they use to log on to their machines, their bank-accounts, etc.
I think it's quite understandable that Microsoft don't want to encourage this sort of thing.
 
Hi,

Well actually using assembler code in Windows to access hardware resources is possible, but not in the same way you would do in non-protected mode. You'll have to let Windows know what you are trying to do first, by using special API and this is not an easy task since Microsoft has done it's best to make things difficult. The same thing happens in Linux: you cannot access hardware without letting the kernel know what you are trying do to, otherwise you could bring the whole box down.
The problem with Windows is that it allows direct hardware access only from kernel mode, which is dangerous...
Now, about your question: how to bypass the OS. It is possible, but not easy. I recommend that you write a driver (nothing fancy...) and place your code in it. Unfortunatelly I can not help you very much at this since I REFUSE to read the DDK... it's mind damaging and it's definetly not worthed. Instead I recommend you ask some geek to write it for you and make room for you to place your code (a small call or something). From there you can handle youreself.
My opinion: use GNU/LINUX


Regards,

Mike
 
Thanks Mike,

after further readings, I come to the conclusion that writing a kernel-mode driver is the only way around it.

I found some sources that access to Ring 0 whithout driver, but they seem unfaithfull and surely system damaging. In addition, they usually tend to make the system unstable. This is logical, since the OS doesn't accept to run in parallel whith another routine that has the same privilege level as he does.

I'm actually an electronician, not an informatician, so IO's and assembly is my domain, not C++. Any clues on how I could easily, and rapidly write that small driver?

Nico.
 
Hi nico,


Yes you are right to write a driver is the best solution. I am an electronical engineer too, but sometimes if i don´t need high speed performance, c and c++ are more than efficient enough.
The main problem to develop a driver is to test it :)
if you want to work with keyboard input, remap the keyboard, etc one wise way is to use what is called directx, these are libraries that allow you to access low level hardware without crashing windows, here is a link


Ricardo
 
Hi,

again... :)

Ok, so how does one writes a driver?
a) Read the DDK and follow the steps in there (only if you have one day to live and donno what to do with it :D)
b) Get your hands on Numega Driver Studio, choose an example from there and modify it as you like. This should do the trick. It's not easy though... drivers are tricky.


 
does anyone know which entry of the IDT corresponds to IRQ1 (keyboard interrupt) in W2K/XP?

I'm puzzled. I've seen some doc that states that it corresponds to the 31st entry, but my Interrupt handler is never called. I'm just trying to delete whatever first keystroke has been hit in the first place, and then giving control back to the original ISR. IS it not possible in protected mode? I doubt that.

Thanks for any information.

Nico.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top