home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
ausvap.exe
/
PRELUDE.ASM
< prev
Wrap
Assembly Source File
|
1991-07-23
|
15KB
|
425 lines
comment !
This software is provided as is and carries no warranty
whatsoever. Novell disclaims and excludes any and all implied
warranties of merchantability, title and fitness for a particular
purpose. Novell does not warrant that the software will satisfy
your requirements or that the software is without defect or error
or that operation of the software will be uninterrupted. You are
using the software at your risk. The software is not a product
of Novell, Inc. or any of subsidiaries.
module: prelude.asm single process vap header.
abstract: start up header and code for a VAP.
environ: SFT NetWare v2.15 Rev C.
-------------------------------------------------------------
09/28/90 1.00 initial release.
!
.model large
name VAPPrelude
.code
if @codesize ; if large model
p equ 6 ; first parm is 6 bytes away
else
p equ 4 ; first parm is 4 bytes away
endif
;Public symbols for Novell NetWare C Interface for DOS libs
public NetWareShellServices, ProcessControlServices
public ConsoleControlServices, IPXSPXServices
;The following makes up the VAP Header. It must be at the start of any VAP
Signature db 'NWProc'
_NetWareShellServices label dword
NetWareShellServices dd ?
ProcessControlServices dd ?
ConsoleControlServices dd ?
IPXSPXServices dd ?
VAPConsoleHandler dd vConsoleHandler ; console handler func
VAPDownHandler dd vDownHandler ; down handler function
VAPConsoleOrDownDataSegment dw DGroup ; con or down dataseg
VAPConnectionRequestFlag dw 0 ; give us default conn
VAPName db 'A Sample NetWare VAP'
db 64-($-VAPName) dup(0)
VAPConsoleKeyWordCount dw 1 ; okay to set to zero
VAPKeyw1 db 'XX VAPKEYWORD' ; if you remove these
db 16-($-VAPKeyw1) dup(0) ; 2 lines!
VAPSignOnMsg db 13,10
db '┌─────────────────────────────┐',13,10
db '│ NetWare Value Added Process │',13,10
db '│ Sample VAP Header Source │',13,10
db '│ Version 0.10 ß Revision A │',13,10
db '└─────────────────────────────┘',13,10,13,10
db 500-($-VAPSignOnMsg) dup(0)
EO2READWRITE equ 1 ; execute/only to read/write
NetWareVAP proc far
;
; All segments containing volatile data MUST be changed
; to R/W!
;
mov ax, DGroup ; our data segment
mov di, EO2READWRITE ; change segment to read/write
call dword ptr cs:ProcessControlServices
if @datasize
mov ax, FAR_DATA ; far data segment
mov di, EO2READWRITE ; change segment to read/write
call dword ptr cs:ProcessControlServices
mov ax, FAR_BSS ; far unitialized data segment
mov di, EO2READWRITE ; change segment to read/write
call dword ptr cs:ProcessControlServices
endif
;
; A 100 byte stack has been established for us by NetWare.
; If you need a larger stack, do setup here.
;
; Establish initial addressability for all segments.
;
cli ; don't interrupt me now!
mov ax, DGROUP ; establish addressability
mov bx, OFFSET DGroup:MainStackEnd
mov ds, ax
mov es, ax
mov ss, ax
mov sp, bx ; setup the stack for process#1
sti ; allow interrupts now
; main( WORD DataSegment, WORD CodeSegment );
push cs ; pass code segment
push ds ; and data segment to process #1
extrn _main:proc
call _main ; call process #1
;
; we should never get here! But just in case...
;
mov ax,offset DGROUP:Oops$Msg
push ax
if @datasize
push ds
endif
extrn _ConsoleDisplay:proc ;NetWare C Interface - DOS Lib
call far ptr _ConsoleDisplay
extrn _SleepProcess:proc ;NetWare C Interface - DOS Lib
DeadLoop: call _SleepProcess
jmp short DeadLoop ; sleep forever
NetwareVAP endp
vConsoleHandler proc far
;
;This procedure is called by NetWare when one of our keywords
;has been typed at the console.
;
;on entry:
; AX - Keyword number typed at console
; DS - Initialized to VAPConsoleOrDownDataSegment field
; BX:SI - Points to command line
;
mov cx,80 ; copy command line (it changes
push es ; when a new command is entered)
push ds
push ds ; point es:di to our buffer
pop es
mov di,offset DGROUP:_CommandLine
mov ds,bx ; ds:si source
cld ; clear direction flag
rep movsb ; xfer command line
pop ds ; restore registers & call handler
pop es
; ConsoleHandler( WORD keyword );
push ax ; pass to C function
extrn _ConsoleHandler:proc
call _ConsoleHandler ; call C console handler
add sp,2 ; clean up the stack
ret ; return to OS
vConsoleHandler endp
vDownHandler proc far
;
;This procedure is called by NetWare when the 'DOWN' console
;command has been entered, before the server shuts down.
;
;on entry:
; DS - Initialized to VAPConsoleOrDownDataSegment field
;
extrn _DownHandler:proc
call _DownHandler ; call C down handler
ret ; return to OS
vDownHandler endp
GETFILESRVNAME equ 14h ; Request code for Get Server Name
NWCIV1_1 = 1
if NWCIV1_1
;
;This function is needed only if you are using the v1.1
;NetWare C Interface functions. v1.2 call is okay.
;
_VAPGetFileServerName proc
public _VAPGetFileServerName
push bp
mov bp,sp
push di ; save registers
push ds
push es
push si
if @datasize
les si,p[bp] ; point es:si to buffer
else
push ds ; point es to data segment
pop es
mov si,p[bp] ; get offset of name buffer
endif
mov di, GETFILESRVNAME ; function number
call dword ptr cs:[ProcessControlServices] ; call OS
pop si
pop es ; restore registers
pop ds
pop di
pop bp
cbw ; return code in AX
ret
_VAPGetFileServerName endp
endif ;NWCIV1_1
; int close(FHANDLE fh)
_close PROC
PUBLIC _close
PUSH BP
mov BP, sp
mov BX, [BP+4]
mov ah,3Eh
call dword ptr cs:[NetWareShellServices] ; call OS
POP BP
RET
_close ENDP
; FindFirst(char *fname);
_FindFirst proc
PUBLIC _FindFirst
push bp
mov bp,sp
push dx
push ds
push cx
push bx
IF @datasize
lds dx,[bp+p]
ELSE
mov dx, [bp+p]
ENDIF
mov cx,0
mov ah,4eh
call dword ptr cs:NetwareShellServices
jc FindBAD
mov ax,0
FindBAD:
pop bx
pop cx
pop ds
pop dx
pop bp
ret
_FindFirst endp
_SetDTA PROC
PUBLIC _SetDTA
push bp
mov bp,sp
PUSH DS
PUSH DX
IF @datasize
LDS DX,[bp+p]
ELSE
mov dx,[bp+p]
ENDIF
mov ah,01ah
call cs:NetWareShellServices
pop dx
pop ds
pop bp
ret
_SetDTA endp
; FHANDLE open(char* pszPath, BYTE access)
_open PROC
PUBLIC _open
push BP
mov BP, sp
push DS
push SI
push DI
if @datasize
lds DX, [BP+p]
mov al , byte ptr [BP+p+4]
else
mov DX, [BP+p]
mov al , byte ptr [BP+p+2]
endif
mov ah, 3Dh
call dword ptr cs:[NetWareShellServices] ; call OS
POP DI
POP SI
POP DS
POP BP
jnc no_erroro
mov AX, 0FFFFh
no_erroro:
RET
_open ENDP
; FHANDLE create(char* pszPath, BYTE access)
_create PROC
PUBLIC _create
push BP
mov BP, sp
push DS
push SI
push DI
push CX
mov CX,0
if @datasize
lds DX, [BP+p]
mov cl , byte ptr [BP+p+4]
else
mov DX, [BP+p]
mov cl , byte ptr [BP+p+2]
endif
mov ah, 3Ch
call dword ptr cs:[NetWareShellServices] ; call OS
POP CX
POP DI
POP SI
POP DS
POP BP
jnc nc_erroro
; mov AX, 0FFFFh
nc_erroro:
RET
_create ENDP
; int read(int handle, char *buff, int len)
_read PROC
PUBLIC _read
push BP
mov BP, sp
push DS
push SI
push DI
if @datasize
mov BX ,[BP+p]
lds DX, [BP+p+2]
mov CX, [BP+P+6]
else
MOV BX, [BP+P]
mov DX, [BP+p+2]
mov CX, [BP+p+4]
endif
mov ah, 3Fh
call dword ptr cs:[NetWareShellServices] ; call OS
POP DI
POP SI
POP DS
POP BP
jnc no_errorr
mov AX, 0FFFFh
no_errorr:
RET
_read ENDP
; int write(int handle, char *buff, int len)
_write PROC
PUBLIC _write
push BP
mov BP, sp
push DS
push SI
push DI
if @datasize
mov BX ,[BP+p]
lds DX, [BP+p+2]
mov CX, [BP+P+6]
else
MOV BX, [BP+P]
mov DX, [BP+p+2]
mov CX, [BP+p+4]
endif
mov ah, 40h
call dword ptr cs:[NetWareShellServices] ; call OS
POP DI
POP SI
POP DS
POP BP
jnc no_errorr
mov AX, 0FFFFh
no_errorw:
RET
_write ENDP
_VAPInterrupt3 proc ; for debugging
;
;This function is useful for debugging VAPs on a Real Mode
;bridge. You can pass data that will be loaded into the
;registers before the break. Passing a pointer to a
;"where am I" string is very useful here...
;
public _VAPInterrupt3
push bp
mov bp,sp
mov ax,[bp+p+0] ; first parm in ax
mov bx,[bp+p+2]
mov cx,[bp+p+4]
mov dx,[bp+p+6]
int 3h ; just pass control to debugger
pop bp
ret ; back to C caller
_VAPInterrupt3 endp
.data
Oops$Msg label byte
db 'Oops! I returned from main()!\n\r',0
public _CommandLine
_CommandLine label byte
db 80 dup ( 0 ) ; buffer for command line
;Process Stacks
db 256 dup ('Stack000') ; 2K stack for process #1
MainStackEnd label word
if @datasize ; for large model, need to get definitions
.fardata ; for FAR_DATA and FAR_BSS, so we can
.fardata? ; make them R/W segments!
endif
end NetWareVAP ; MUST HAVE THIS!!!!