Dear all,
In Windows 95/98, in a Win32 user mode application, we can use “in”, “out”
instruction
to access io port, is it right? My test tell me that we can.
As we all know, in user mode, the memory address is linear (or virtual)
address compared
with physical address. Then are IO port address virtual address too?
In my Win32 App, I write
_asm in al, 0x30;
Is 0x30 physical address of IO port, or virtual address?
Do IO port have the concept of virtual address?
Someone tell me that, In Ring0, “in” and “out” instruction can access all
port successfully,
But in user mode, only port that permitted by process’s permission map can
be accessed
successfully, otherwise an GP error will occur, is it right?
How can I access arbitrary IO port in 95/98?
And NT and Win2K?
Thansk.
BR
Volition2k
In Windows NT ANY in or out instruction that is performed in User mode will
generate an exception causing the offending process to be terminated. In
Windows 9x in and out are allowed in User mode but not all port addresses
are directly accessable - many of them have traps set on them by device
drivers.
Jim
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of xxxxx@acersoftech.com.cn
Sent: Wednesday, April 05, 2000 8:56 PM
To: NT Developers Interest List
Subject: [ntdev] Question about IO port space.
Dear all,
In Windows 95/98, in a Win32 user mode application, we can use “in”, “out”
instruction
to access io port, is it right? My test tell me that we can.
As we all know, in user mode, the memory address is linear (or virtual)
address compared
with physical address. Then are IO port address virtual address too?
In my Win32 App, I write
_asm in al, 0x30;
Is 0x30 physical address of IO port, or virtual address?
Do IO port have the concept of virtual address?
Someone tell me that, In Ring0, “in” and “out” instruction can access all
port successfully,
But in user mode, only port that permitted by process’s permission map can
be accessed
successfully, otherwise an GP error will occur, is it right?
How can I access arbitrary IO port in 95/98?
And NT and Win2K?
Thansk.
BR
Volition2k
You are currently subscribed to ntdev as: xxxxx@youngendeavors.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)
In case of Win 9x, OS doesn’t strictly use IOPL’s, since to provide
applications with faster access to i/o space. Hence only the ports that are
hooked by Drivers will result in trapping. Once it’s trapped, it’s in the
hands of the driver to permit or reject ur applications access to that port.
But NT strictly follows IOPL’s. Only the processes that have lower IOPL than
the CPL will be allowed to access i/o space. And hence user mode
applications in NT always don’t have access to i/o space, directly.
HTH,
Sajeev.
-----Original Message-----
From: xxxxx@acersoftech.com.cn [SMTP:xxxxx@acersoftech.com.cn]
Sent: Thursday, April 06, 2000 9:26 AM
To: NT Developers Interest List
Subject: [ntdev] Question about IO port space.Dear all,
In Windows 95/98, in a Win32 user mode application, we can use “in”,
“out”
instruction
to access io port, is it right? My test tell me that we can.
As we all know, in user mode, the memory address is linear (or virtual)
address compared
with physical address. Then are IO port address virtual address too?
In my Win32 App, I write
_asm in al, 0x30;
Is 0x30 physical address of IO port, or virtual address?
Do IO port have the concept of virtual address?
Someone tell me that, In Ring0, “in” and “out” instruction can access all
port successfully,
But in user mode, only port that permitted by process’s permission map
can
be accessed
successfully, otherwise an GP error will occur, is it right?
How can I access arbitrary IO port in 95/98?
And NT and Win2K?
Thansk.
BR
Volition2k
You are currently subscribed to ntdev as: xxxxx@amiindia.co.in
To unsubscribe send a blank email to $subst(‘Email.Unsub’)
Hello,
hence user mode
applications in NT always don’t have access to i/o
space, directly.
It is not *strictly* the case in Windows NT. Under
Windows NT it is possible to change to IOPL of the
process using NtSetInformationProcess native API call
with information class ‘ProcessUserModeIOPL’ (16).
Changing the IOPL to 3 allows user mode programs to do
direct port I/O.
One needs to have ‘Act as part of operating system’
(SE_TCB_PRIVILEGE) granted and enabled in order to
make use of this native API.
Here is the pseudo code to do so…
Enable SE_TCB_PRIVILEGE…
ULONG Iopl=3;
NTSTATUS rc;
rc=NtSetInformationProcess(NtCurrentProcess(), 16,
&Iopl, sizeof(Iopl));
if (rc==STATUS_SUCCESS) {
//Direct port I/O allowed.
…
}
It is not the best method to do direct Port I/O.
Alternate apporoaches could be to write your own
driver or use some third party drivers which allow
such capability.
There is one sample in NT 4.0 DDK named portio which
demonstrates how to write a driver which will provide
the IOCTLs to do direct port I/O to user mode
programs.
-Prasad
=====
Prasad S. Dabak
Director of Engineering, Windows NT/2000 Division
Cybermedia Software Private Limited
http://www.cybermedia.co.in
Co-author of the book “Undocumented Windows NT”
ISBN 0764545698
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com