flat assembler
Message board for the users of flat assembler.

Index > Windows > Access I/O Ports Under WindowsXP/NT

Author
Thread Post new topic Reply to topic
kidscracker



Joined: 29 Oct 2004
Posts: 46
kidscracker 05 May 2005, 22:49
I want to access directly to I/O ports, specially Lpt, under WindowsXP, but when i execute
Code:
mov dx,03bch
in al,dx
    

it generate a GPF, now the question is HOW CAN I ACCESS PORT DIRECTLY???!!! Pleaseeee Sad
Post 05 May 2005, 22:49
View user's profile Send private message Reply with quote
Torrey



Joined: 12 Oct 2003
Posts: 78
Torrey 17 Jun 2005, 07:17
It might be possible by using CreateFile and obtaining the handle for "\\\\.\\LPT1" then if successful using communications api to handle the calls to that device.

[edit]

To be exact, this will return a handle.

Code:
invoke CreateFile,lpDevice,GENERIC_READ,0,0,OPEN_EXISTING,0,0
mov [hDevice],eax

lpDevice db '\\\\.\\LPT1',0
hDevice dd ?    


After you get that handle use the communications api to work with the device.
Post 17 Jun 2005, 07:17
View user's profile Send private message Visit poster's website Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 509
Location: Czech republic, Slovak republic
Feryno 17 Jun 2005, 11:12
1.
A public known method for access every port, e.g. when you must access CMOS (ports 70h,71h), or when you need make own hardware monitor (CPU temperature, FAN RPMS, voltages...)
The solution:
Copy giveio.sys to c:\windows\system32\drivers
run install_giveio.exe c:\windows\system32\drivers\giveio.sys
run start_giveio.exe
Your program:
opening device giveio.sys set access permission to ports
put this in your code:
push 0
push FILE_ATTRIBUTE_NORMAL
push OPEN_EXISTING
push 0
push 0 ;FILE_SHARE_WRITE
push GENERIC_READ
push devicename
call [CreateFile]
cmp eax,INVALID_HANDLE_VALUE
jz exit ; can't open device giveio
push eax
call [CloseHandle]
put here code with port operations...

data
devicename db '\\.\giveio',0

2.
French hackers coded masm direct switch to ring0 - hard to recode to fasm
see ring0.mas


Description: giveio.sys install_giveio.exe start_giveio.exe
a00.asm a00.exe don't run it, example only, need MB Asus A8N !
masm ring0.mas from french hackers !!

Download
Filename: ports.zip
Filesize: 26.68 KB
Downloaded: 873 Time(s)

Post 17 Jun 2005, 11:12
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Torrey



Joined: 12 Oct 2003
Posts: 78
Torrey 17 Jun 2005, 12:18
What's the story about promoting French hackers? If I was a Caucasian one, would that make me cool too? Cool
Post 17 Jun 2005, 12:18
View user's profile Send private message Visit poster's website Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier 17 Jun 2005, 12:32
kidscracker,

You can use CreateFile, ReadFile, and Writefile to read/write to/from both parallel and serial ports without using any tricks. This will work if you are only transferring data, if you want to control the bits in the control registers of the hardware, you will have to try something else.

Code:
hPrinter        dd      ?
nobw            dd      ?

PPort           db      "LPT1", 0
emph_p          db      27, 69
sizeof.emph_p   =       $ - emph_p


        invoke  CreateFile, PPort, GENERIC_READ or GENERIC_WRITE, \
                NULL, NULL, OPEN_EXISTING, NULL, NULL
        .if     eax, e, INVALID_HANDLE_VALUE
                jmp     .error_handler
        .endif
        mov     [hPrinter], eax
        invoke  WriteFile, [hPrinter], emph_p, sizeof.emph_p, nobw, NULL
        invoke  CloseHandle, [hPrinter]    


hth,

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 17 Jun 2005, 12:32
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 19 Jun 2005, 12:19
Quote:

French hackers coded masm direct switch to ring0 - hard to recode to fasm

You shouldn't use this if you want your application to work smoothly on future windows versions... besides, it requires administrative privileges, so you can't use it from a restricted user account.
Post 19 Jun 2005, 12:19
View user's profile Send private message Visit poster's website Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: US
coconut 19 Jun 2005, 16:07
what about this from internals.com

http://www.internals.com/utilities/winio.zip
Post 19 Jun 2005, 16:07
View user's profile Send private message Reply with quote
@L.chemist



Joined: 08 Oct 2004
Posts: 14
Location: Russia, Vladimir, Suzdal
@L.chemist 27 Jun 2005, 15:29
You can also try this.

it's my own simple driver (r0pc.sys) written in FASM
& a couple of very simple examples.

with a little help of r0pc.sys you can
.1 execute user-mode code in ring-0
.2 read/write ports under winnt

to compile driver you must have KMD.inc
http://board.flatassembler.net/viewtopic.php?t=648

!!! tested under win2k only

YOU'LL FIND THE SOURCE IN MY LAST POST


Last edited by @L.chemist on 12 Aug 2005, 08:34; edited 3 times in total
Post 27 Jun 2005, 15:29
View user's profile Send private message Visit poster's website Reply with quote
@L.chemist



Joined: 08 Oct 2004
Posts: 14
Location: Russia, Vladimir, Suzdal
@L.chemist 28 Jun 2005, 07:27
bug fix in fasm test program

YOU'LL FIND THE SOURCE IN MY LAST POST


Last edited by @L.chemist on 12 Aug 2005, 12:21; edited 1 time in total
Post 28 Jun 2005, 07:27
View user's profile Send private message Visit poster's website Reply with quote
Sem



Joined: 05 Mar 2005
Posts: 8
Sem 29 Jun 2005, 08:16
No driver:
Call NtSetInformationProcess and set ProcessInformationClass.ProcessUserModeIOPL = 3. But you must enable&create SE_TCB_PRIVILEGE for you process.

Sources,


Description:
Download
Filename: 1556445909__DirectIOAccess.rar
Filesize: 9.11 KB
Downloaded: 800 Time(s)

Post 29 Jun 2005, 08:16
View user's profile Send private message Reply with quote
@L.chemist



Joined: 08 Oct 2004
Posts: 14
Location: Russia, Vladimir, Suzdal
@L.chemist 12 Aug 2005, 08:13
fix collision of new irp FASM directive & IRP structure in KMD.inc


Description: driver
Download
Filename: r0pc010105.zip
Filesize: 28.65 KB
Downloaded: 725 Time(s)

Post 12 Aug 2005, 08:13
View user's profile Send private message Visit poster's website Reply with quote
@L.chemist



Joined: 08 Oct 2004
Posts: 14
Location: Russia, Vladimir, Suzdal
@L.chemist 16 Aug 2005, 11:56
New import macros.
Now IDA doesn't scream about damaged import section.
Thanks to Feryno for remarks.


Description: driver
Download
Filename: r0pc010107.zip
Filesize: 28.74 KB
Downloaded: 857 Time(s)

Post 16 Aug 2005, 11:56
View user's profile Send private message Visit poster's website Reply with quote
12345



Joined: 18 Dec 2011
Posts: 1
12345 19 Dec 2011, 02:22
My code doesn't work in xp with giveio installed and started!

Code:
ORG 100h
USE16


;push    ds
;push    cs
;pop     ds
;mov     ax, 3d00h    ;open file
;mov     dx, devicename
;int     21h

MOV DX,filename;Start mem loc of giveio.sys
 MOV AL,00H ;Normal Read/Write file attribute
 MOV AH,3DH ;Open File function
 INT 21H ;Open File ;File handle is in AX







 mov al,0EDh           ;ED command - Send LED bits. The next byte written to port 60h updates the LEDs on the keyboard.
out 60h,al            ;out on port 60h
mov al,00000111b      ;led status - all leds on. bits 3-7 = reserved(zero)
out 60h,al            ;out on port 60h









mov ah,01
int 21h

mov ah,4ch
int 21h

filename:db '\\.\giveio',0
;devicename: db '\\.\giveio',0    
edit by revolution: added code tags
Post 19 Dec 2011, 02:22
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20355
Location: In your JS exploiting you and your system
revolution 19 Dec 2011, 02:26
12345: giveio is a 32-bit driver for Windows. You won't be able to use it from the 16-bit DOS VDM.
Post 19 Dec 2011, 02:26
View user's profile Send private message Visit poster's website 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.