home *** CD-ROM | disk | FTP | other *** search
- ONSTACK STRUC
- OLDBP DW ?
- RETADDR DD ?
- DRIVEROFS DW ?
- DRIVERSEG DW ?
- ONSTACK ENDS
-
- CODE SEGMENT PARA PUBLIC
- ASSUME CS:CODE
- PUBLIC LoadSoundDriver
- PUBLIC UnloadSoundDriver
-
- ;; Local data area for calling into a loadable sound driver.
- LoadAddress dw 0,0 ; Allocate memory load address.
- LoadSeg dw 0 ; Segment driver was loaded into.
- LABEL InstallDriver DWORD
- InstOff dw 0200h ; Offset of first jump.
- InstSeg dw ? ; Segment of audio driver.
- LABEL DeInstallDriver DWORD
- DeInstOff dw 0203h ; Offset of deinstall jump
- DeInstSeg dw ? ; Segment of audio driver.
-
- ; FUNCTION LoadSoundDriver(Driver : Pointer) : BOOLEAN; // Load a sound driver by filename, 1 success 0 fail.
- LoadSoundDriver PROC FAR
- PUSH BP
- MOV BP,SP
- mov ax,[BP].DRIVEROFS
- and ax,0Fh
- jnz @@FREE ; not paragraph aligned.
-
- mov ax,[BP].DRIVEROFS
- shr ax,1
- shr ax,1
- shr ax,1
- shr ax,1
- add ax,[BP].DRIVERSEG
- mov [cs:LoadSeg],ax ; Save load segment.
-
- mov ax,[cs:LoadSeg] ; Save segment loaded at.
- sub ax,10h ; Less 10 paragraphs for the org 100h
- mov [cs:InstSeg],ax
- mov [cs:DeInstSeg],ax
- call [cs:InstallDriver] ; Install the driver.
- or ax,ax ; Installed ok?
- jz @@OK1
- @@FREE:
- xor ax,ax
- mov [cs:LoadSeg],ax
- jmp short @@EXT ; Exit with error.
- @@OK1: mov al,1 ; Success!
- @@EXT:
- POP BP
- ret 4
- LoadSoundDriver ENDP
-
-
- UnloadSoundDriver PROC FAR
- cmp [cs:LoadSeg],0 ; Ever load a sound driver?
- je @@NOT ; no, leave.
- call [cs:DeInstallDriver] ; Do indirect call to deinstall the driver.
- mov [cs:LoadSeg],0 ; Zero load seg out.
- @@NOT:
- ret
- UnLoadSoundDriver ENDP
-
- CODE ends
- end
-