📄 cw32.asm
字号:
or ax,ax
jnz @@Exit
mov ax,ErrorLevel
@@Exit:
mov ah,4ch
int 21h
cwClose endp
;-------------------------------------------------------------------------------
Int21hExecPatch proc near
assume ds:nothing
pushf
cmp ax,4b00h
jnz @@Old
inc cs:Int21hExecCount
popf
pushf
call cs:d[OldInt21hExec]
pushf
push bp
push ax
mov bp,sp
mov ax,[bp+2+2]
and ax,1
; and w[bp+2+2+2+2+2],1
and w[bp+2+2+2+2+2],0fffeh ; MED 01/24/96
or w[bp+2+2+2+2+2],ax
pop ax
pop bp
popf
dec cs:Int21hExecCount
iret
@@Old:
popf
jmp cs:d[OldInt21hExec]
OldInt21hExec dd 0
assume ds:_cwMain
Int21hExecCount db 0
Int21hExecPatch endp
.386p
;-------------------------------------------------------------------------------
Bordm proc near
pushm ax,dx
mov ah,al
mov dx,3dah
in al,dx
mov dl,0c0h
mov al,11h
out dx,al
mov al,ah
out dx,al
mov al,20h
out dx,al
popm ax,dx
ret
Bordm endp
;-------------------------------------------------------------------------------
;
;Some global data.
;
RealPSPSegment dw ? ;Real mode PSP segment.
RealENVSegment dw ? ;Real mode environment segment.
ProtectedFlags dw 0 ;Bit significant, 0-DPMI,1-VCPI,2-RAW.
ProtectedType dw 0 ;0-RAW,1-VCPI,2-DPMI.
ProtectedForce db 0
DOSVersion dw 0
SystemFlags dd 0
apiCodeSeg dw 0
apiDataSeg dw 0
;
CodeSegment dw MainCS ;Setup CS selector.
CodeSegmenti dw InitCS
DataSegment dw MainDS ;Setup DS selector.
DataSegmenti dw InitDS
StackSegment dw MainSS
RealSegment dw KernalZero
PSPSegment dw MainPSP
ENVSegment dw MainENV
BasePSP dw 0
BasePSPAddress dd 0
;
TSRSize dw 0
;
ErrorNumber dw 0
ErrorLevel dw 0
ErrorList dw ErrorM00,ErrorM01,ErrorM02,ErrorM03,ErrorM04,ErrorM05,ErrorM06,ErrorM07
dw ErrorM08,ErrorM09,ErrorM10,ErrorM11,ErrorM12,ErrorM13,ErrorM14,ErrorM15
dw ErrorM16
ErrorM00 db 'CauseWay error '
ErrorM00n db '00 : $'
ErrorM01 label byte
if ENGLISH
db 'Unable to re-size program memory block.',13,10,'$'
elseif SPANISH
db "Incapaz de redimensionar el bloque de memoria del programa.",13,10,"$"
endif
ErrorM02 db "$"
ErrorM03 db "$"
ErrorM04 db "$"
ErrorM05 label byte
if ENGLISH
db 'Not enough memory for CauseWay.',13,10,'$'
elseif SPANISH
db "Memoria insuficiente para CauseWay.",13,10,"$"
endif
ErrorM06 db "$"
ErrorM07 db "$"
ErrorM08 db "$"
ErrorM09 label byte
if ENGLISH
db 'Unrecoverable exception. Program terminated.',13,10,'$'
elseif SPANISH
db "Excepcion irrecuperable. Programa terminado.",13,10,"$"
endif
ErrorM10 label byte
if ENGLISH
db 'Unable to find '
ErrorM10_T db 'application to load.',13,10,'$',32 dup (0)
elseif SPANISH
db "Incapaz de encontrar '
ErrorM10_T db 'aplicacion a cargar.",13,10,"$",32 dup (0)
endif
ErrorM11 label byte
if ENGLISH
db 'DOS reported an error or corrupt file found.'
elseif SPANISH
db "DOS informo de un error o de un fichero corrupto."
endif
ErrorM11_0 db 13,10,'$'
db "No:"
ErrorM11_1 db "00000000",13,10,"$"
ErrorM12 label byte
if ENGLISH
db 'Not enough memory to load application.',13,10,'$'
elseif SPANISH
db "Memoria insuficiente para cargar la aplicacion.",13,10,"$"
endif
ErrorM13 db "$"
ErrorM14 label byte
if ENGLISH
db 'Memory structures destroyed. Program terminated.',13,10,'$'
elseif SPANISH
db "Estructuras de memoria destruidas. Programa terminado.",13,10,"$"
endif
ErrorM15 label byte
if ENGLISH
db 'DOS reported an error while accessing swap file. Program terminated.',13,10,'$'
elseif SPANISH
db "DOS informa de un error mientras se accede al fichero de swap. Programa terminado.",13,10,"$"
endif
ErrorM16 label byte
if ENGLISH
db "Unsupported DOS function call, program terminated.",13,10,"$"
elseif SPANISH
db "Llamada a funcion no soportada del DOS, programa terminado.",13,10,"$"
endif
;
ALIGN 4
MainExec db 128 dup (0)
;
DtaBuffer db 128 dup (0)
;
TransferSize dd 8192
TransferReal dw ?
;
MouseETarget dd 0,0
ResourceTracking dw 0
ForcedFind dd 0,0
mcbAllocations dw 0
LinearAddressCheck db 0
;
TerminationHandler dd offset InitError,InitCS
UserTermRoutine DF 0
UserTermDump DF 0 ; dump location for register info
;
DPMIStateAddr df 0
DPMIStateSize dd 0
DPMIStackOff dw ?
DPMIStackSeg dw ?
;
DebugDump db 0
EnableDebugDump DB 1
UserTermFlag DB 0
Pad1Flag DB 0
IFDEF PERMNOEX
NoEXECPatchFlag DB 1
ELSE
NoEXECPatchFlag DB 0
ENDIF
; MED, 11/11/99
; used to flag checking XMS total memory because EMM386 lies and acts as VCPI
; host when NOVCPI set, but provides no memory
VCPIHasNoMem DB 0
NewCWErrName DB 81 DUP (0)
DOS4GFlag db 0
;
;*** MED change for Michael Devore name
CopyCheck label byte
db 'C'-44,'a'-44,'u'-44,'s'-44,'e'-44,'W'-44,'a'-44,'y'-44,' '-44
db 'D'-44,'O'-44,'S'-44,' '-44,'E'-44,'x'-44,'t'-44,'e'-44,'n'-44
db 'd'-44,'e'-44,'r'-44,' '-44,'v'-44,255,255,255,255
db ' '-44,'C'-44,'o'-44,'p'-44,'y'-44,'r'-44,'i'-44,'g'-44
db 'h'-44,'t'-44,' '-44,'1'-44,'9'-44,'9'-44,'2'-44,'-'-44,'9'-44
db '9'-44,' '-44,'M'-44
db 'i'-44,'c'-44,'h'-44,'a'-44,'e'-44,'l'-44,' '-44,'D'-44,'e'-44
db 'v'-44,'o'-44,'r'-44,'e'-44,'.'-44,13-44,10-44,'A'-44,'l'-44,'l'-44
db ' '-44,'r'-44,'i'-44,'g'-44,'h'-44,'t'-44,'s'-44,' '-44,'r'-44
db 'e'-44,'s'-44,'e'-44,'r'-44,'v'-44,'e'-44,'d'-44,'.'-44,13-44,10-44
CopyCount dw 0
;
Int21Buffer db size RealRegsStruc dup (?)
Int10Buffer db size RealRegsStruc dup (?)
Int33Buffer db size RealRegsStruc dup (?)
;
apiExcepPatched db 0
;
ExtensionList label word
dw ExceptionExtension
dw Int21hExtension,Int10hExtension,Int33hExtension
dw -1
;
ExceptionExtension dw _Excep,0
dd offset ExcepEnd-ExcepStart
dd offset ExcepOpen,?
dd offset ExcepClose,?
dd 0
dd 0
dd 0
;
Int21hExtension dw _Int21h,1 ;segment start.
dd offset Int21hEnd-Int21hStart ;segment length.
dd offset Int21hOpen,? ;init code.
dd offset Int21hClose,? ;remove code.
dd 0 ;code selector.
dd 0 ;data selector.
dd 0 ;installed flag.
;
Int10hExtension dw _Int10h,1 ;segment start.
dd offset Int10hEnd-Int10hStart ;segment length.
dd offset Int10hOpen,? ;init code.
dd offset Int10hClose,? ;remove code.
dd 0 ;code selector.
dd 0 ;data selector.
dd 0 ;installed flag.
;
Int33hExtension dw _Int33h,1 ;segment start.
dd offset Int33hEnd-Int33hStart ;segment length.
dd offset Int33hOpen,? ;init code.
dd offset Int33hClose,? ;remove code.
dd 0 ;code selector.
dd 0 ;data selector.
dd 0 ;installed flag.
;
Temp0_ dd ?
Temp1_ dd ?
;
DebugUserOff DD ?
DebugUserSel DW ?
DebugUserCount DW 0 ; must be initialized, nonzero value flags operation
DebugAsciiFlag DB ?
_cwMain ends
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Default stack used during startup and exit.
;
_cwStack segment para stack 'main stack' use16
db 2048 dup (0)
_cwStackEnd label byte
_cwStack ends
include raw_vcpi.asm
include api.asm
include exceptn.asm
include int10h.asm
include int21h.asm
include int33h.asm
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;The initialiseation code seg. Takes care of things like checking for the right
;processor and determining how we're going to get into protected mode.
;
_cwInit segment para public 'init code' use16
assume cs:_cwInit, ds:_cwMain
dpmiSelBuffer db 8 dup (0)
;-------------------------------------------------------------------------------
Startup proc near
;
;Make global data addresable.
;
mov ax,_cwMain
mov ds,ax
; MED, 12/30/99
; works around weird bug in some machines due to Windows/hardware/BIOS??? error
; where a CauseWay application in AUTOEXEC.BAT which uses DOS function 8
; to get a keystroke when no other application in AUTOEXEC.BAT gets a
; keystroke will cause failure in Windows 98 (and 95?) when opening a DOS
; box after Windows startup. Caused by A20 or keyboard port stabilization?
mov cx,127
IFNDEF SUN
kloop:
mov ax,0b00h
int 21h
test al,al
jne done
loop kloop
done:
ELSE
mov ax,3
int 10h
ENDIF
;
;Stow real mode PSP and environment values, we'll need them later.
;
mov RealPSPSegment,es
mov ax,es:w[02ch]
mov RealEnvSegment,ax ;Stow ENV for later.
;
;Re-size memory so we can allocate what we want high.
;
mov cs:IErrorNumber,1
mov ax,es
mov bx,_cwEnd ;Get program end segment.
sub bx,ax ;Size program.
inc bx
mov ah,4ah
int 21h ;Re-size memory block.
; MED 06/16/97
; jc InitError
jnc chk386
toiniterr:
jmp InitError
;
;Check we're on at least a 386 system.
;
chk386:
mov cs:IErrorNumber,2
call CheckProcessor
; jc InitError
jc toiniterr
;
;Check DOS version is high enough.
;
mov cs:IErrorNumber,4
call CheckDOSVersion
jc InitError
;
;Get execution name from environment.
;
call GetEXECName
;
;Retrieve setup info from 3P header.
;
call GetSystemFlags
;
;Check if a suitable method for switching to protected mode exists.
;
call GetProtectedType
mov cs:IErrorNumber,3
cmp ProtectedFlags,0 ;Any types available?
jz InitError
;
;Get CAUSEWAY environment variable settings.
;
call GetENVStuff
;
;Decide which environment to use.
;
call SetProtectedType
;
;Move the DTA to where we can get at it in the future.
;
mov dx,offset DTABuffer
mov ah,1ah
int 21h
;
;now see about type specific initialisations.
;
cmp ProtectedType,2 ;DPMI initialiseation?
jz @@InitDPMI
;
;Useing either RAW or VCPI so do the stuff that's common to both for now.
;
mov ax,_cwRaw
mov ds,ax
assume ds:_cwRaw
;
;Get SDA address so VMM can change BREAK state.
;
.386
push ds
mov ax,5d06h
int 21h
mov ax,ds
pop ds
add si,17h
movzx eax,ax
shl eax,4
movzx esi,si
add eax,esi
mov BreakAddress,eax
;
;Find out if XMS is present.
;
mov ax,4300h ;XMS install check.
int 2fh
cmp al,80h ;XMS present?
jnz @@NoXMS
;
;XMS detected so work out max block size and entry point.
;
mov ax,4310h ;Get XMS API.
int 2fh
mov w[XMSControl],bx
mov w[XMSControl+2],es
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -