We've been approached about this several times, so we have a pretty
good idea about what's involved and it isn't pretty.

You would need to set up a TSS that had an IOPL that caused trapping
for accesses to your I/O ports. Unfortunately, DOS/4G doesn't normally
use a TSS, although it has at various times. What's worse, we're not sure
how you would switch from the 4G TSS (if it existed) to yours. This is
complicated by the fact that DOS/4G programs run in ring 0 under native
DOS or a VCPI host, and at ring 3 under a DPMI host like Windows or Win 95
or NT or OS/2. Also, DPMI doesn't allow for more than one extender, so
you can't even set up something to trap the references before 4G comes
into play.

Seriously, doing what you want is definitely possible, but it is also
definitely not easy. You would need to replace a bit of the extender,
which isn't too hard but makes the packaging issues a bit sticky.