I am transfering my DLL from 16 to 32. So far so good.

QUESTION:

My DLL communicates with port 280H.
Is this type of communication in WIN32 different than in WIN16?


Here is an example of my usage:

P2L16 Macro local16,passedptr
mov eax, passedptr
mov ax,
MOV local16, AX
Endm

.data
otbaseadr DW 0280h ;control card base address

;************************************
trchk PROC USES ESI EDI EBX ECX EDX,otbaseadrptr:DWORD,returncodeptr:DWORD
;************************************

P2L16 otbaseadr,otbaseadrptr

mov dx,otbaseadr
in al,dx
mov cl,al ;store what was in counter

mov dx,otbaseadr
mov al,0A5h
out dx,al ;write A5h

in al,dx ;read A5h
cmp al,0A5h
je doublecheck
mov returncode,0
jmp chkend

doublecheck:
mov al,5Ah ;write 5Ah
out dx,al

in al,dx ;read 5Ah
cmp al,5Ah
je otfound
mov returncode,0
jmp chkend

otfound:
mov returncode,1
mov al,cl
out dx,al ;restore counter to pretest value

chkend:
L2P16 returncodeptr,returncode
ret
trchk endp



Thanks for any comments or leads!!! :alright:
Posted on 2001-10-26 12:22:26 by mikef
Hi,

from 386 you can use:

in eax,021h - opcodes E5 21 (same as in ax,021h)
in eax,dx --- opcodes ED (same as in ax,dx)

from win2k Operating System you can not use
'in' / 'out' statements.
I hate that, anyone have a solution ?


TD
Posted on 2001-10-26 13:19:26 by Test Department
test department: WinIO by Yariv Kaplan (www.internals.com) is created for direct port & memory access in both win9x and NT/2k. You can find the asm includes & working lib at my site http://exagone.cjb.net (it's called AsmIO, you'll need WinIO as well as it's only an addition).

Thomas
Posted on 2001-10-26 14:11:09 by Thomas
in protected mode, if CPL > IOPL access to port via IN/OUT is controlled by the IO-bitmap in the TSS. In Win95, port 280h normally is guarded. that means if you execute an in/out 280h, a GPF is launched. The standard handler in ring0 will ignore your IN/OUT then (at least for win32 apps). If you dont want to use such a tool Thomas has mentioned you can do:

- write a vxd (this is the "clean" way)
- switch temporarily to ring0 by your dll and do the in/out
- access the TSS and make port 280h "free".

But all three ways are not for the beginner.

Possibly, if your 16-bit dll has worked ok, you can use "flat thunks". That is, you have to create a 32-bit dll which switches to your 16-bit dll (win95 only of course). To create such a dll you dont need ASM knowledge, there exist C examples.

japheth
Posted on 2001-10-27 04:37:17 by japheth