flat assembler
Message board for the users of flat assembler.

Index > DOS > Trapping hardware ports in Real Mode. Is that possible?

Author
Thread Post new topic Reply to topic
Cas



Joined: 26 Feb 2004
Posts: 82
Location: Argentina
Cas
How can I redirect hardware ports to my own functions? Is it possible to do such thing while the system remains in real mode? Otherwise, if I need to get in V86 mode or something, do I have to set it myself? Will I have any problem with HIMEM, EMM386 and the sort? Can I do it while running in protected mode with a DPMI?
Compatibility: how unstable can it be? How can a redirection like this impact an application performance (if the application thinks it is an actual hardware port)?

Hope you guys can help! Thanks in advance Very Happy

_________________
Ā«Earth is my country; science is my religionĀ» - Christian Huygens
Post 07 Jun 2008, 23:01
View user's profile Send private message Yahoo Messenger MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
You will have to put the CPU into v8086 mode. You will also have to disable all memory managers drivers and make your own VM to handle it.
Post 08 Jun 2008, 02:59
View user's profile Send private message Visit poster's website Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 693
Location: Adelaide
sinsi
If you are talking about standard ports (COM,LPT etc) you can hook the interrupt.
Post 08 Jun 2008, 03:18
View user's profile Send private message Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia
MazeGen
Correct me if I'm wrong, but it could be possible to use hardware breakpoints to monitor port accesses. I remember that hardware breakpoints worked well for me as instruction execution breakpoints in real mode some years ago.

This article discusses debugging features in 64-bit mode, however, it should work also in real mode. See example 4:

http://x86asm.net/articles/debugging-in-amd64-64-bit-mode-in-theory/#Hardware-Breakpoints
Post 08 Jun 2008, 19:24
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
But there are only 4 address points available, that would severely limit the scope of monitoring I/O accesses.
Post 08 Jun 2008, 19:28
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
in some conditions:
these four breakpoints can be changed while they are access.
assuming the I/O ports will be accessed slowly in a predifined order
Code:
BPt for 60h:
  set BPt for 20h
  ret
BPt for 20h
  set BPt for 60h
  ret
    


or simply assume the result of your code.
If the code works, then, you can be sure you access the ports.
Post 09 Jun 2008, 00:51
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
edfed wrote:
in some conditions:
these four breakpoints can be changed while they are access.
assuming the I/O ports will be accessed slowly in a predifined order
Code:
BPt for 60h:
  set BPt for 20h
  ret
BPt for 20h
  set BPt for 60h
  ret
    
I think the situations where this would be useful are rare.
edfed wrote:
or simply assume the result of your code.
If the code works, then, you can be sure you access the ports.
Hehe, there is that word again, ass-u-me.
Post 09 Jun 2008, 05:37
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia
MazeGen
It depends on which ports Cas needs to monitor. One hardware breakpoint can monitor up to 8 successive byte ports.
Post 09 Jun 2008, 08:51
View user's profile Send private message Visit poster's website Reply with quote
Cas



Joined: 26 Feb 2004
Posts: 82
Location: Argentina
Cas
Well guys... what I'm trying to do is in part something that has been tried many times. I know it is possible, but people seem reluctant to do it and in a way, I understand that.
I'm trying to hook the SoundBlaster (220h+x) and MPU401 (330h+x) ports.

One thing that makes me think it must not be that extremely complicated is the fact that I know that AWEUTIL (an application to emulate MIDI by redirecting a fake MPU401 UART mode to the EMU8000) does that or something similar. I really don't know how to directly work on the EMU8000 (soundbank chip in the SoundBlaster AWE series), but I believe it is more important to understand the MPU. However, I'd like to know how AWEUTIL does this, to redirect these ports somewhere else and do the same with the SoundBlaster ones.

I'm not posting AWEUTIL here because I don't know if it's fine to do it.
Post 09 Jun 2008, 22:14
View user's profile Send private message Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.