;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; RDOS operating system ; Copyright (C) 1988-2000, Leif Ekblad ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. The only exception to this rule ; is for commercial usage in embedded systems. For information on ; usage in commercial embedded systems, contact embedded@rdos.net ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ; ; The author of this program may be contacted at leif@rdos.net ; ; STDDEV.ASM ; Standard device module ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; INCLUDE protseg.def INCLUDE ..\driver.def INCLUDE ..\user.def INCLUDE ..\os.def INCLUDE system.inc INCLUDE ..\user.inc INCLUDE ..\os.inc INCLUDE ..\fs.inc devfe_struc STRUC devfe_base dir_file_entry_data_struc <> devfe_data DW ? devfe_name DB ? devfe_struc ENDS device_struc STRUC device_name DB 16 DUP(?) device_read DD ?,? device_write DD ?,? device_struc ENDS std_device_process_seg STRUC con_buf DB 256 DUP(?) con_buf_start DW ? con_buf_end DW ? std_device_process_seg ENDS data SEGMENT byte public 'DATA' device_last DW ? devices DB 32*16 DUP(?) data ENDS .386p code SEGMENT byte public use16 'CODE' assume cs:code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: InstallDeviceFile ; ; DESCRIPTION: Install device file ; ; PARAMETERS: DS:ESI Device read ; ES:EDI Device write ; FS:EBX Device name ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; install_device_file_name DB 'Install Device File',0 install_device_file PROC far push ds push es push fs pushad ; push fs push ebx ; mov ax,SEG data mov fs,ax mov bx,fs:device_last mov fs:[bx].device_read,esi mov fs:[bx+4].device_read,ds mov fs:[bx].device_write,edi mov fs:[bx+4].device_write,es ; mov ax,SEG data mov es,ax mov di,bx ; pop esi pop ds ; mov cx,16 inst_dev_loop: lods byte ptr ds:[esi] or al,al jz inst_dev_pad ; stosb loop inst_dev_loop ; jmp inst_dev_saved inst_dev_pad: mov al,' ' stosb loop inst_dev_pad inst_dev_saved: add es:device_last,32 ; popad pop fs pop es pop ds retf32 install_device_file ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: FIND_DEVICE ; ; DESCRIPTION: Check if a filename is a device ; ; PARAMETERS: ES:EDI FILE NAME ; DS:BX FOUND DEVICE ; NC SUCCESS ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; char_tab: ct00 DB 0, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ct08 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ct10 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ct18 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ct20 DB ' ', '!', 0FFh, '#', '$', '%', '&', 27h ct28 DB '(', ')', 0FFh, 0FFh, 0FFh, '-', '.', 0 ct30 DB '0', '1', '2', '3', '4', '5', '6', '7' ct38 DB '8', '9', 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ct40 DB '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G' ct48 DB 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O' ct50 DB 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W' ct58 DB 'X', 'Y', 'Z', 0FFh, 0, 0FFh, '^', '_' ct60 DB 60h, 'A', 'B', 'C', 'D', 'E', 'F', 'G' ct68 DB 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O' ct70 DB 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W' ct78 DB 'X', 'Y', 'Z', '{', 0FFh, '}', '~', 0FFh ct80 DB 0FFh, 0FFh, 0FFh, 0FFh, '', 0FFh, '', 0FFh ct88 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, '', '' ct90 DB 0FFh, 0FFh, 0FFh, 0FFh, '', 0FFh, 0FFh, 0FFh ct98 DB 0FFh, '', 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ctA0 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ctA8 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ctB0 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ctB8 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ctC0 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ctC8 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ctD0 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ctD8 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ctE0 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ctE8 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ctF0 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ctF8 DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh find_device PROC far push ax push cx push si ; mov ax,SEG data mov ds,ax mov bx,OFFSET char_tab mov si,OFFSET devices mov cx,ds:device_last sub cx,si shr cx,5 find_next_device: push cx push si push edi mov cx,16 find_device_loop: mov al,es:[edi] xlat byte ptr cs:char_tab cmp al,[si] jne find_device_try_next ; inc si inc edi loop find_device_loop jmp find_device_ok find_device_try_next: mov al,[si] cmp al,' ' jne find_device_not_at_end ; mov al,es:[edi] or al,al clc je find_device_ok find_device_not_at_end: pop edi pop si pop cx add si,32 loop find_next_device find_device_fail: stc jmp find_device_done find_device_ok: pop edi pop si pop cx mov bx,si clc find_device_done: pop si pop cx pop ax ret find_device ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: CHECK_DEVICE ; ; DESCRIPTION: Check if file is a DOS device ; ; PARAMETERS: ES:EDI FILE NAME ; AL DRIVE IN/OUT ; NC SUCCESS ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; check_device_name DB 'Check Device',0 check_device PROC far push ds push bx call find_device jc check_device_not_found ; mov al,80h check_device_not_found: pop bx pop ds clc retf32 check_device ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: AllocateDirSel ; ; DESCRIPTION: Allocate dir selector ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; allocate_dir_sel PROC far push es push eax ; mov eax,SIZE dir_sel_data_struc AllocateSmallGlobalMem mov bx,es ; pop eax pop es retf32 allocate_dir_sel ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: FreeDirSel ; ; DESCRIPTION: Free dir selector ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; free_dir_sel PROC far push es ; mov es,bx FreeMem ; pop es retf32 free_dir_sel ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: Cache_dir ; ; DESCRIPTION: Cache dir ; ; PARAMETERS: EDX Dir entry to cache or 0 ; BX Cached dir selector ; ; RETURNS: ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; cache_dir PROC far push es pushad ; mov ax,SEG data mov ds,ax mov ax,flat_sel mov es,ax ; mov esi,OFFSET devices mov cx,ds:device_last sub cx,si shr cx,5 cache_dir_loop: push cx ; mov eax,SIZE devfe_struc + 8 AllocateSmallLinear mov es:[edx].de_drive,80h mov es:[edx].de_usage,0 push esi push edi lea edi,[edx].devfe_name mov es:[edx].de_name,edi mov cx,8 mov es:[edx].de_name_size,0 cache_name_loop: lods byte ptr [esi] cmp al,' ' je cache_name_done ; inc es:[edx].de_name_size stos byte ptr es:[edi] loop cache_name_loop cache_name_done: xor al,al stos byte ptr es:[edi] pop edi pop esi mov es:[edx].de_sel,bx mov es:[edx].de_attrib,80h mov es:[edx].de_time,0 mov es:[edx+4].de_time,0 mov es:[edx].dfe_data_size,0 mov es:[edx].dfe_file_sel,0 mov es:[edx].devfe_data,si InsertFileEntry ; add esi,32 pop cx sub cx,1 jnz cache_dir_loop ; popad pop es clc retf32 cache_dir ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: OPEN_FILE ; ; DESCRIPTION: Open file ; ; PARAMETERS: ES:EDI FILE NAME ; ; RETURNS: AH FILE ATTRIBUTE ; ECX FILE SIZE ; DX FILE PTR ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; open_file PROC far call find_device jc open_file_done ; mov dx,bx xor ecx,ecx mov ah,80h clc open_file_done: retf32 open_file Endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: CLOSE_FILE ; ; DESCRIPTION: Close file ; ; PARAMETERS: ES:EDI FILE NAME ; CL ACCESS MODE ; ; RETURNS: BX FILE HANDLE ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; close_file PROC far clc retf32 close_file Endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: GET_IOCTL_DATA ; ; DESCRIPTION: Get IOCTL data ; ; PARAMETERS: BX FILE HANDLE ; ; RETURNS: DX IOCTL DATA ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; get_ioctl_data PROC far mov dx,0C0D3h clc retf32 get_ioctl_data Endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: READ_FILE ; ; DESCRIPTION: Read from device ; ; PARAMETERS: BX HANDLE TO DEVICE ; ES:EDI BUFFER ; ECX NUMBER OF BYTES TO READ ; EDX POSITION ; ; RETURNS: EAX NUMBER OF BYTES READ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; read_file PROC far mov ds,bx mov ebx,ds:file_dir_entry mov ax,flat_sel mov ds,ax mov bx,[ebx].devfe_data mov ax,SEG data mov ds,ax call fword ptr ds:[bx].device_read retf32 read_file ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: WRITE_FILE ; ; DESCRIPTION: Write to device ; ; PARAMETERS: BX HANDLE TO DEVICE ; ES:EDI BUFFER ; ECX NUMBER OF BYTES TO READ ; EDX POSITION ; ; RETURNS: EAX NUMBER OF BYTES WRITTEN ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; write_file PROC far mov ds,bx mov ebx,ds:file_dir_entry mov ax,flat_sel mov ds,ax mov bx,[ebx].devfe_data mov ax,SEG data mov ds,ax call fword ptr ds:[bx].device_write retf32 write_file ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: CON_IO ; ; DESCRIPTION: Console IO ; ; PARAMETERS: ES:EDI BUFFER ; ECX MAX NUMBER OF CHARS ; EAX NUMBER OF READ CHARS ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; get_cursor_pos Proc near push cx GetCursorPosition mov dh,dl mov dl,cl pop cx ret get_cursor_pos Endp set_cursor_pos Proc near push cx movzx cx,dl movzx dx,dh SetCursorPosition pop cx ret set_cursor_pos Endp con_io_tab: mov al,' ' jmp con_io_normal con_io_normal PROC near or ecx,ecx jz con_io_full cmp esi,edi jne con_io_insert WriteChar stos byte ptr es:[edi] dec ecx mov esi,edi con_io_full: clc ret con_io_insert: push ecx push esi push dx call get_cursor_pos mov ecx,edi sub ecx,esi con_io_move_loop: WriteChar xchg al,es:[esi] inc esi sub ecx,1 jne con_io_move_loop WriteChar mov es:[esi],al call set_cursor_pos pop dx pop esi pop ecx mov al,es:[esi] WriteChar mov eax,edi sub eax,esi sub eax,ecx jnc con_io_overflow inc esi inc edi dec ecx clc ret con_io_overflow: inc esi dec ecx push ecx push esi push dx call get_cursor_pos con_io_overflow_loop: cmp esi,edi je con_io_overflow_done mov al,es:[esi] WriteChar inc esi dec ecx jmp con_io_overflow_loop con_io_overflow_done: mov al,' ' WriteChar call set_cursor_pos xor al,al WriteChar pop dx pop esi pop ecx clc ret con_io_normal ENDP con_io_del PROC near cmp ecx,edx je con_io_del_empty cmp esi,edi jne con_io_del_move dec edi dec esi inc ecx push dx call get_cursor_pos sub dl,1 jnc con_io_del_do mov dl,79 sub dh,1 jnc con_io_del_do xor dx,dx con_io_del_do: push dx call set_cursor_pos mov al,' ' WriteChar pop dx call set_cursor_pos pop dx con_io_del_empty: clc ret con_io_del_move: dec esi dec edi inc ecx push ecx push esi push dx call get_cursor_pos sub dl,1 jnc con_io_del_do_move mov dl,79 sub dh,1 jnc con_io_del_do_move xor dx,dx con_io_del_do_move: call set_cursor_pos mov ecx,edi sub ecx,esi con_io_del_loop: mov al,es:[esi+1] mov es:[esi],al WriteChar inc esi sub ecx,1 jne con_io_del_loop mov al,' ' WriteChar call set_cursor_pos pop dx pop esi pop ecx clc ret con_io_del ENDP con_io_cr PROC near cmp ecx,2 jc con_io_cr_full mov al,0Dh mov es:[esi],al dec ecx inc esi inc edi WriteChar stc ret con_io_cr_full: clc ret con_io_cr ENDP con_io_clear_buf PROC near con_clear_home_loop: cmp ecx,edx je con_clear_home_done push dx call get_cursor_pos sub dl,1 jnc con_clear_home_do mov dl,79 sub dh,1 jnc con_clear_home_do xor dx,dx con_clear_home_do: call set_cursor_pos pop dx dec esi inc ecx jmp con_clear_home_loop con_clear_home_done: push dx call get_cursor_pos push dx push ecx mov ecx,edi sub ecx,esi mov al,' ' con_clear_loop: WriteChar sub ecx,1 jnz con_clear_loop pop ecx pop dx call set_cursor_pos xor al,al WriteChar pop dx mov edi,esi clc ret con_io_clear_buf ENDP con_io_skip PROC near clc ret con_io_skip ENDP con_left_arrow PROC near cmp edx,ecx je con_left_fail inc ecx dec esi push dx call get_cursor_pos sub dl,1 jnc con_left_arrow_do mov dl,79 sub dh,1 jnc con_left_arrow_do xor dx,dx con_left_arrow_do: call set_cursor_pos pop dx xor al,al WriteChar con_left_fail: clc ret con_left_arrow ENDP con_right_arrow PROC near cmp edi,esi je con_right_fail mov al,es:[esi] cmp edi,esi jne con_right_write mov al,' ' con_right_write: WriteChar dec ecx inc esi con_right_fail: clc ret con_right_arrow ENDP con_home_key PROC near con_home_loop: cmp ecx,edx je con_home_done push dx call get_cursor_pos sub dl,1 jnc con_home_do mov dl,79 sub dh,1 jnc con_home_do xor dx,dx con_home_do: call set_cursor_pos pop dx dec esi inc ecx jmp con_home_loop con_home_done: xor al,al WriteChar clc ret con_home_key ENDP con_end_key PROC near con_end_loop: cmp esi,edi je con_end_done mov al,es:[esi] WriteChar inc esi dec ecx jmp con_end_loop con_end_done: clc ret con_end_key ENDP con_ext_key_buf_tab: dek00 DW OFFSET con_io_skip dek01 DW OFFSET con_io_skip dek02 DW OFFSET con_io_skip dek03 DW OFFSET con_io_skip dek04 DW OFFSET con_io_skip dek05 DW OFFSET con_io_skip dek06 DW OFFSET con_io_skip dek07 DW OFFSET con_io_skip dek08 DW OFFSET con_io_skip dek09 DW OFFSET con_io_skip dek0A DW OFFSET con_io_skip dek0B DW OFFSET con_io_skip dek0C DW OFFSET con_io_skip dek0D DW OFFSET con_io_skip dek0E DW OFFSET con_io_skip dek0F DW OFFSET con_io_skip dek10 DW OFFSET con_io_skip dek11 DW OFFSET con_io_skip dek12 DW OFFSET con_io_skip dek13 DW OFFSET con_io_skip dek14 DW OFFSET con_io_skip dek15 DW OFFSET con_io_skip dek16 DW OFFSET con_io_skip dek17 DW OFFSET con_io_skip dek18 DW OFFSET con_io_skip dek19 DW OFFSET con_io_skip dek1A DW OFFSET con_io_skip dek1B DW OFFSET con_io_skip dek1C DW OFFSET con_io_skip dek1D DW OFFSET con_io_skip dek1E DW OFFSET con_io_skip dek1F DW OFFSET con_io_skip dek20 DW OFFSET con_io_skip dek21 DW OFFSET con_io_skip dek22 DW OFFSET con_io_skip dek23 DW OFFSET con_io_skip dek24 DW OFFSET con_io_skip dek25 DW OFFSET con_io_skip dek26 DW OFFSET con_io_skip dek27 DW OFFSET con_io_skip dek28 DW OFFSET con_io_skip dek29 DW OFFSET con_io_skip dek2A DW OFFSET con_io_skip dek2B DW OFFSET con_io_skip dek2C DW OFFSET con_io_skip dek2D DW OFFSET con_io_skip dek2E DW OFFSET con_io_skip dek2F DW OFFSET con_io_skip dek30 DW OFFSET con_io_skip dek31 DW OFFSET con_io_skip dek32 DW OFFSET con_io_skip dek33 DW OFFSET con_io_skip dek34 DW OFFSET con_io_skip dek35 DW OFFSET con_io_skip dek36 DW OFFSET con_io_skip dek37 DW OFFSET con_io_skip dek38 DW OFFSET con_io_skip dek39 DW OFFSET con_io_skip dek3A DW OFFSET con_io_skip dek3B DW OFFSET con_io_skip dek3C DW OFFSET con_io_skip dek3D DW OFFSET con_io_skip dek3E DW OFFSET con_io_skip dek3F DW OFFSET con_io_skip dek40 DW OFFSET con_io_skip dek41 DW OFFSET con_io_skip dek42 DW OFFSET con_io_skip dek43 DW OFFSET con_io_skip dek44 DW OFFSET con_io_skip dek45 DW OFFSET con_io_skip dek46 DW OFFSET con_io_skip dek47 DW OFFSET con_home_key dek48 DW OFFSET con_io_skip dek49 DW OFFSET con_io_skip dek4A DW OFFSET con_io_skip dek4B DW OFFSET con_left_arrow dek4C DW OFFSET con_io_skip dek4D DW OFFSET con_right_arrow dek4E DW OFFSET con_io_skip dek4F DW OFFSET con_end_key dek50 DW OFFSET con_io_skip dek51 DW OFFSET con_io_skip dek52 DW OFFSET con_io_skip dek53 DW OFFSET con_io_skip dek54 DW OFFSET con_io_skip dek55 DW OFFSET con_io_skip dek56 DW OFFSET con_io_skip dek57 DW OFFSET con_io_skip dek58 DW OFFSET con_io_skip dek59 DW OFFSET con_io_skip dek5A DW OFFSET con_io_skip dek5B DW OFFSET con_io_skip dek5C DW OFFSET con_io_skip dek5D DW OFFSET con_io_skip dek5E DW OFFSET con_io_skip dek5F DW OFFSET con_io_skip dek60 DW OFFSET con_io_skip dek61 DW OFFSET con_io_skip dek62 DW OFFSET con_io_skip dek63 DW OFFSET con_io_skip dek64 DW OFFSET con_io_skip dek65 DW OFFSET con_io_skip dek66 DW OFFSET con_io_skip dek67 DW OFFSET con_io_skip dek68 DW OFFSET con_io_skip dek69 DW OFFSET con_io_skip dek6A DW OFFSET con_io_skip dek6B DW OFFSET con_io_skip dek6C DW OFFSET con_io_skip dek6D DW OFFSET con_io_skip dek6E DW OFFSET con_io_skip dek6F DW OFFSET con_io_skip dek70 DW OFFSET con_io_skip dek71 DW OFFSET con_io_skip dek72 DW OFFSET con_io_skip dek73 DW OFFSET con_io_skip dek74 DW OFFSET con_io_skip dek75 DW OFFSET con_io_skip dek76 DW OFFSET con_io_skip dek77 DW OFFSET con_io_skip dek78 DW OFFSET con_io_skip dek79 DW OFFSET con_io_skip dek7A DW OFFSET con_io_skip dek7B DW OFFSET con_io_skip dek7C DW OFFSET con_io_skip dek7D DW OFFSET con_io_skip dek7E DW OFFSET con_io_skip dek7F DW OFFSET con_io_skip dek80 DW OFFSET con_io_skip dek81 DW OFFSET con_io_skip dek82 DW OFFSET con_io_skip dek83 DW OFFSET con_io_skip dek84 DW OFFSET con_io_skip con_io_extend PROC near mov bl,ah xor bh,bh add bx,bx call cs:word ptr [bx].con_ext_key_buf_tab ret con_io_extend ENDP con_key_buf_tab: ckb0 DW OFFSET con_io_extend ckb1 DW OFFSET con_io_normal ckb2 DW OFFSET con_io_normal ckb3 DW OFFSET con_io_normal ckb4 DW OFFSET con_io_normal ckb5 DW OFFSET con_io_normal ckb6 DW OFFSET con_io_normal ckb7 DW OFFSET con_io_normal ckb8 DW OFFSET con_io_del ckb9 DW OFFSET con_io_tab ckbA DW OFFSET con_io_normal ckbB DW OFFSET con_io_normal ckbC DW OFFSET con_io_normal ckbD DW OFFSET con_io_cr ckbE DW OFFSET con_io_normal ckbF DW OFFSET con_io_normal ckb10 DW OFFSET con_io_normal ckb11 DW OFFSET con_io_normal ckb12 DW OFFSET con_io_normal ckb13 DW OFFSET con_io_normal ckb14 DW OFFSET con_io_normal ckb15 DW OFFSET con_io_normal ckb16 DW OFFSET con_io_normal ckb17 DW OFFSET con_io_normal ckb18 DW OFFSET con_io_normal ckb19 DW OFFSET con_io_normal ckb1A DW OFFSET con_io_normal ckb1B DW OFFSET con_io_clear_buf ckb1C DW OFFSET con_io_normal ckb1D DW OFFSET con_io_normal ckb1E DW OFFSET con_io_normal ckb1F DW OFFSET con_io_normal ckbend DW OFFSET con_io_normal con_io PROC near push ds push ebx push ecx push edx push esi push edi mov edx,ecx mov esi,edi mov ax,std_dev_process_sel mov ds,ax con_io_loop: ReadKeyboard movzx bx,al cmp bx,20h jc con_io_in_tab mov bx,20h con_io_in_tab: add bx,bx call cs:word ptr [bx].con_key_buf_tab jnc con_io_loop pop edi mov eax,esi sub eax,edi clc pop esi pop edx pop ecx pop ebx pop ds ret con_io ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: ReadConsole ; ; DESCRIPTION: Read from console ; ; PARAMETERS: ES:(E)DI BUFFER ; (E)CX MAX NUMBER OF CHARS ; ; RETURNS; (E)AX NUMBER OF READ CHARS ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; read_con_name DB 'Read Console',0 read_con16 PROC far push ecx push eax push edi movzx ecx,cx movzx edi,di call con_io pop edi mov ecx,eax pop eax mov ax,cx pop ecx retf32 read_con16 ENDP read_con32 PROC far call con_io retf32 read_con32 ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: CON_DEVICE ; ; DESCRIPTION: CON device ; ; PARAMETERS: ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; con_read_line PROC near push es push ecx push edi mov ax,std_dev_process_sel mov es,ax mov edi,OFFSET con_buf mov ds:con_buf_start,di mov ecx,256 call con_io add di,ax inc ax mov al,0Ah stosb WriteChar mov ds:con_buf_end,di pop edi pop ecx pop es ret con_read_line ENDP con_read PROC far push ds push esi push ecx push edi mov ax,std_dev_process_sel mov ds,ax movzx esi,ds:con_buf_start movzx eax,ds:con_buf_end sub eax,esi or eax,eax jnz con_read_do call con_read_line movzx esi,ds:con_buf_start movzx eax,ds:con_buf_end sub eax,esi con_read_do: pop edi pop ecx cmp eax,ecx jnc con_read_partial con_read_all: push ecx push edi mov ecx,eax rep movs byte ptr es:[edi],ds:[esi] pop edi pop ecx mov ds:con_buf_start,OFFSET con_buf mov ds:con_buf_end,OFFSET con_buf jmp con_read_done con_read_partial: push ecx push edi mov eax,ecx rep movs byte ptr es:[edi],ds:[esi] mov ds:con_buf_start,si pop edi pop ecx con_read_done: clc pop esi pop ds retf32 con_read ENDP con_write PROC far UserGateForce32 write_size_string_nr mov eax,ecx clc retf32 con_write ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: INIT_DEVICE_PROCESS ; ; DESCRIPTION: Init per-process data ; ; PARAMETERS: ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; con_device DB 'CON',0 init_device_process PROC far push ds pusha ; mov ax,std_dev_process_sel mov ds,ax mov ds:con_buf_start,OFFSET con_buf mov ds:con_buf_end,OFFSET con_buf ; popa pop ds retf32 init_device_process ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; NAME: INIT ; ; DESCRIPTION: Init driver ; ; PARAMETERS: ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; dummy Proc far stc retf32 dummy Endp fs_name DB 'DEVICE',0 fs_ctrl: fs00 DD OFFSET dummy, SEG code fs01 DD OFFSET dummy, SEG code fs02 DD OFFSET dummy, SEG code fs03 DD OFFSET dummy, SEG code fs04 DD OFFSET dummy, SEG code fs05 DD OFFSET allocate_dir_sel, SEG code fs06 DD OFFSET free_dir_sel, SEG code fs07 DD OFFSET cache_dir, SEG code fs08 DD OFFSET dummy, SEG code fs09 DD OFFSET dummy, SEG code fs10 DD OFFSET dummy, SEG code fs11 DD OFFSET dummy, SEG code fs12 DD OFFSET dummy, SEG code fs13 DD OFFSET dummy, SEG code fs14 DD OFFSET dummy, SEG code fs15 DD OFFSET get_ioctl_data, SEG code fs16 DD OFFSET dummy, SEG code fs17 DD OFFSET read_file, SEG code fs18 DD OFFSET write_file, SEG code fs19 DD OFFSET dummy, SEG code fs20 DD OFFSET dummy, SEG code fs21 DD OFFSET dummy, SEG code fs22 DD OFFSET dummy, SEG code public init_stddev init_stddev PROC near mov ax,cs mov ds,ax mov es,ax ; mov edi,OFFSET init_device_process HookCreateProcess ; mov esi,OFFSET install_device_file mov edi,OFFSET install_device_file_name mov ax,install_device_file_nr RegisterOsGate ; mov esi,OFFSET check_device mov edi,OFFSET check_device_name mov ax,check_device_file_nr RegisterOsGate ; mov ebx,OFFSET read_con16 mov esi,OFFSET read_con32 mov edi,OFFSET read_con_name mov dx,virt_es_in mov ax,read_con_nr RegisterUserGate ; mov ax,SIZE std_device_process_seg mov bx,std_dev_process_sel AllocateFixedProcessMem ; mov ax,SEG data mov ds,ax mov ds:device_last,OFFSET devices ; mov ax,cs mov ds,ax mov es,ax mov fs,ax ; mov ebx,OFFSET con_device mov esi,OFFSET con_read mov edi,OFFSET con_write InstallDeviceFile ; mov esi,OFFSET fs_name mov edi,OFFSET fs_ctrl RegisterFileSystem ; mov al,80h mov edi,OFFSET fs_name InstallFileSystem ret init_stddev ENDP code ENDS END