|
|
1.1 ! root 1: name @filename ! 2: ;*--------------------------------------------------------------------* ! 3: ; ! 4: ; DOSAPP ! 5: ; ! 6: ; This DOS application opens a character mode device driver ! 7: ; (DOSDRV00), and issues an IOCTL read to the device. It then ! 8: ; displays the DWORD value it read from the IOCTL. ! 9: ; ! 10: ;*--------------------------------------------------------------------* ! 11: ! 12: include dosapp.inc ! 13: include xio.inc ! 14: include isvbop.inc ! 15: ! 16: ;*--------------------------------------------------------------------* ! 17: ; ! 18: ; DATA ! 19: ; ! 20: ;*--------------------------------------------------------------------* ! 21: ! 22: _DATA segment word public 'DATA' ! 23: ! 24: ! 25: DriverName db "DOSDRV00",0 ! 26: ! 27: hDriver dw ? ! 28: errret dw ? ! 29: DriverInfo dd ? ! 30: ! 31: infmsg db 'IOCTL Read returns: ' ! 32: infmsgx dd 2 dup (?) ! 33: db cr,lf ! 34: infmsgl equ $-infmsg ! 35: ! 36: errmsg db 'Open failed, Error=' ! 37: errmsgx dd ? ! 38: db cr,lf ! 39: errmsgl equ $-errmsg ! 40: ! 41: _DATA ends ! 42: ! 43: ! 44: _TEXT segment word public 'CODE' ! 45: assume cs:_TEXT,ds:_DATA,es:_DATA ! 46: ! 47: ;*--------------------------------------------------------------------* ! 48: ; ! 49: ; MAIN procedure ! 50: ; ! 51: ;*--------------------------------------------------------------------* ! 52: ! 53: @filename proc far ! 54: mov ax, _DATA ;get addressibility ! 55: mov ds, ax ! 56: mov es, ax ! 57: ! 58: mov ah, DOSOPENFILE ! 59: mov al, 00010010b ;r/w, deny all ! 60: mov dx, OFFSET DriverName ! 61: int 21h ;open device ! 62: jc opfail ! 63: mov hDriver, ax ;save handle ! 64: ! 65: mov ah, DOSIOCTL ! 66: mov al, 2 ;IOCTL read ! 67: mov bx, hDriver ! 68: mov cx, 4 ;# of bytes ! 69: mov dx, offset DriverInfo ! 70: int 21h ;issue IOCTL to device ! 71: ! 72: hxtrans DriverInfo, infmsgx, 4 ;make DWORD ASCII ! 73: Writel infmsg ;output to console ! 74: ! 75: mov ah, DOSCLOSEFILE ! 76: mov bx, hDriver ! 77: int 21h ;close the driver ! 78: jmp exit ! 79: ! 80: opfail: ! 81: mov errret, ax ! 82: hxtrans errret, errmsgx, 2 ! 83: Writel errmsg ;write msg if open failed ! 84: ! 85: exit: ! 86: mov ax,4c00h ! 87: int 21h ! 88: ! 89: @filename endp ! 90: ! 91: ! 92: ! 93: ;*--------------------------------------------------------------------* ! 94: ; ! 95: ; hextrans ! 96: ; ! 97: ; This subroutine formats hex values into ASCII ! 98: ; ! 99: ; ENTRY: ! 100: ; CX = size in bytes of operand ! 101: ; DS:SI-> input hex value (in memory) ! 102: ; ES:DI-> output area ! 103: ; ! 104: ; USES: ! 105: ; AX, SI, DI ! 106: ;*--------------------------------------------------------------------* ! 107: ! 108: hextrans proc near ! 109: ! 110: push bx ! 111: push cx ! 112: ! 113: cmp cx, 0 ; must be higher ! 114: jna hextexit ; nope ! 115: add si, cx ; point to end of value ! 116: dec si ; now pointing at last byte ! 117: hext1: ! 118: push cx ! 119: lodsb ; get hex byte ! 120: sub si, 2 ; make this a decrement ! 121: ! 122: mov bx, ax ; save for next nibble ! 123: mov cx, 4 ; isolate next four bits ! 124: shr ax, cl ; get top nibble ! 125: ! 126: cvt_nibble ; make it ascii ! 127: stosb ; save it in destination ! 128: mov ax, bx ; retrieve original byte ! 129: cvt_nibble ; make it ascii ! 130: stosb ; save it in destination ! 131: pop cx ! 132: loop hext1 ! 133: ! 134: hextexit: ! 135: pop cx ! 136: pop bx ! 137: ret ; back to caller ! 138: ! 139: hextrans endp ! 140: ! 141: _TEXT ends ! 142: ! 143: end @filename
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.