📄 api.asm
字号:
api46_9: cwAPI_C2C
ret
cwAPI_LockMem32 endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Un-lock a region of memory.
;
;On Entry:
;
;BX:CX - Starting linear address of memory to unlock
;SI:DI - Size of region to unlock in bytes
;
cwAPI_UnLockMem proc near
mov bx,[ebp+Int_BX]
mov cx,[ebp+Int_CX]
mov si,[ebp+Int_SI]
mov di,[ebp+Int_DI]
mov ax,0601h
cwAPI_CallOld
jc api47_9
mov dx,bx
shl edx,16
mov dx,cx
mov cx,si
shl ecx,16
mov cx,di
mov ax,Res_LOCK
call ReleaseResource
clc
api47_9: cwAPI_C2C
ret
cwAPI_UnLockMem endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Un-lock a region of memory.
;
;On Entry:
;
;ESI - Starting linear address of memory to unlock
;ECX - Size of region to unlock in bytes
;
;NOTES:
;
;This will allow the memory to be swapped to disk by the VMM if neccessary.
;Areas below and above the specified memory will also be un-locked if the
;specified region is not page aligned.
;
cwAPI_UnLockMem32 proc near
mov esi,[ebp+Int_ESI]
mov ecx,[ebp+Int_ECX]
xchg esi,ecx
mov ebx,ecx
shr ebx,16
mov di,si
shr esi,16
mov ax,0601h
cwAPI_CallOld
jc api48_9
mov dx,bx
shl edx,16
mov dx,cx
mov cx,si
shl ecx,16
mov cx,di
mov ax,Res_LOCK
call ReleaseResource
clc
api48_9: cwAPI_C2C
ret
cwAPI_UnLockMem32 endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Lock a region of memory using application relative address.
;
;On Entry:
;
;ESI - Starting linear address of memory to lock.
;EBX - Size of region to lock in bytes.
;
;On Exit:
;
;Carry set on error, none of the memory locked, else memory is locked.
;
cwAPI_LockMemNear proc near
mov esi,[ebp+Int_ESI]
mov ebx,[ebp+Int_EBX]
assume ds:nothing
mov ds,cs:apiDSeg
assume ds:_cwMain
mov ds,PSPSegment
add esi,DWORD PTR ds:[EPSP_Struc.EPSP_NearBase]
assume ds:_apiCode
xchg esi,ebx
mov di,si
shr esi,16
mov cx,bx
shr ebx,16
mov ax,0600h
cwAPI_CallOld
jc api49_9
mov dx,bx
shl edx,16
mov dx,cx
mov cx,si
shl ecx,16
mov cx,di
mov ax,Res_LOCK
call RegisterResource
clc
api49_9: cwAPI_C2C
ret
cwAPI_LockMemNear endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Un-lock a region of memory using application relative address.
;
;On Entry:
;
;ESI - Starting linear address of memory to unlock
;EBX - Size of region to unlock in bytes
;
cwAPI_UnLockMemNear proc near
mov esi,[ebp+Int_ESI]
mov ecx,[ebp+Int_ECX]
assume ds:nothing
mov ds,cs:apiDSeg
assume ds:_cwMain
mov ds,PSPSegment
add esi,DWORD PTR ds:[EPSP_Struc.EPSP_NearBase]
assume ds:_apiCode
xchg esi,ebx
mov di,si
shr esi,16
mov cx,bx
shr ebx,16
mov ax,0601h
cwAPI_CallOld
jc api50_9
mov dx,bx
shl edx,16
mov dx,cx
mov cx,si
shl ecx,16
mov cx,di
mov ax,Res_LOCK
call ReleaseResource
clc
api50_9: cwAPI_C2C
ret
cwAPI_UnLockMemNear endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Allocate a region of DOS (conventional) memory.
;
;On Entry:
;
;BX - Number of paragraphs (16 byte blocks) required.
;
;On Exit:
;
;If function was successful:
;Carry flag is clear.
;
;AX - Initial real mode segment of allocated block
;DX - Initial selector for allocated block
;
;If function was not successful:
;Carry flag is set.
;
;AX - DOS error code.
;BX - Size of largest available block in paragraphs.
;
cwAPI_GetMemDOS proc near
mov bx,[ebp+Int_BX]
mov ax,0100h
cwAPI_CallOld
mov [ebp+Int_AX],ax
cwAPI_C2C
jnc api51_0
mov [ebp+Int_BX],bx
jmp api51_9
;
api51_0: mov [ebp+Int_DX],dx
movzx edx,dx
movzx ecx,bx
shl ecx,4
mov ax,Res_DOSMEM
call RegisterResource
;
api51_9: ret
cwAPI_GetMemDOS endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Re-size a block of DOS (conventional) memory previously allocated with
;GetMemDOS.
;
;On Entry:
;
;BX - New block size in paragraphs
;DX - Selector of block to modify
;
;On Exit:
;
;If function was successful:
;Carry flag is clear.
;
;If function was not successful:
;Carry flag is set.
;
;AX - DOS error code:
;BX - Maximum block size possible in paragraphs
;
cwAPI_ResMemDOS proc near
mov bx,[ebp+Int_BX]
mov dx,[ebp+Int_DX]
mov ax,0102h
cwAPI_CallOld
jnc api52_0
mov [ebp+Int_AX],ax
mov [ebp+Int_BX],bx
jmp api52_9
;
api52_0: mov ax,Res_DOSMEM
movzx edx,dx
call ReleaseResource
movzx ecx,bx
shl ecx,4
call RegisterResource
clc
;
api52_9: cwAPI_C2C
ret
cwAPI_ResMemDOS endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Release a block of DOS (conventional) memory previously allocated with
;GetMemDOS.
;
;On Entry:
;
;DX - Selector of block to free.
;
;On Exit:
;
;If function was successful:
;Carry flag is clear.
;
;If function was not successful:
;Carry flag is set.
;
;AX - DOS error code.
;
cwAPI_RelMemDOS proc near
mov ds,w[ebp+INT_DS]
mov es,w[ebp+INT_ES]
mov fs,w[ebp+INT_FS]
mov gs,w[ebp+INT_GS]
mov dx,[ebp+Int_DX]
mov ax,0101h
cwAPI_CallOld
jnc api53_0
mov [ebp+Int_AX],ax
jmp api53_9
;
api53_0: mov ax,Res_DOSMEM
movzx edx,dx
call ReleaseResource
clc
;
api53_9: cwAPI_C2C
mov w[ebp+INT_DS],ds
mov w[ebp+INT_ES],es
mov w[ebp+INT_FS],fs
mov w[ebp+INT_GS],gs
ret
cwAPI_RelMemDOS endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Run another CauseWay program directly.
;
;On Entry:
;
;DS:EDX - File name.
;ES:ESI - Command line. First byte is length, then real data.
;CX - Environment selector, 0 to use existing copy.
;
;On Exit:
;
;Carry set on error and AX = error code else AL=ErrorLevel
;
cwAPI_Exec proc near
mov ds,[ebp+Int_DS]
mov edx,[ebp+Int_EDX]
mov es,[ebp+Int_ES]
mov esi,[ebp+Int_ESI]
mov cx,[ebp+Int_CX]
mov ebx,0
push ebp
call _Exec
pop ebp
jnc api54_0
mov [ebp+Int_AX],ax
jmp api54_9
;
api54_0: mov [ebp+Int_AL],al
;
api54_9: cwAPI_C2C
IFDEF DEBUG2
push eax
push ebx
push ecx
push edx
push ds
push cs
pop ds
mov edx,OFFSET debugagtext1
debugagloop2:
cmp BYTE PTR ds:[edx],0
je debugagb
mov ecx,1
mov bx,1
mov ah,40h
int 21h
inc edx
jmp debugagloop2
debugagb:
mov edx,OFFSET debugagtext2
push cs
pop ds
mov ecx,2
mov bx,1
mov ah,40h
int 21h
pop ds
pop edx
pop ecx
pop ebx
pop eax
jmp debugagout
debugagtext1 DB 'Done with cwAPI_Exec...',0
debugagtext2 DB 13,10
debugagout:
ENDIF
ret
cwAPI_Exec endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Validate and get expanded length of a CWC'd file.
;
;On Entry:
;
;BX - File handle.
;
;On Exit:
;
;Carry set if not a CWC'd file else,
;
;ECX - Expanded data size.
;
cwAPI_cwcInfo proc near
mov bx,[ebp+Int_BX]
call GetCWCInfo
cwAPI_C2C
mov [ebp+Int_ECX],ecx
mov [ebp+Int_EAX],eax
ret
cwAPI_cwcInfo endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Load/Expand a CWC'd data file into memory.
;
;On Entry:
;
;BX - Source file handle.
;ES:EDI - Destination memory.
;
;On Exit:
;
;Carry set on error and EAX is error code else,
;
;ECX - Expanded data length.
;
cwAPI_cwcLoad proc near
mov bx,[ebp+Int_BX]
mov es,[ebp+Int_ES]
mov edi,[ebp+Int_EDI]
call DecodeCWC
mov [ebp+Int_EAX],eax
jc api56_9
mov [ebp+Int_ECX],ecx
api56_9: cwAPI_C2C
ret
cwAPI_cwcLoad endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
cwAPI_LinearCheck proc near
mov esi,[ebp+Int_ESI]
assume ds:nothing
mov ds,cs:apiDSeg
assume ds:_cwMain
;
mov es,RealSegment
xor eax,eax
mov ax,es
lsl eax,eax
cmp eax,esi
jc api57_3
mov LinearAddressCheck,1
mov al,es:[esi]
cmp LinearAddressCheck,0
mov LinearAddressCheck,0
jnz api57_2
api57_3: stc
jmp api57_1
api57_2: clc
api57_1: assume ds:_apiCode
;
cwAPI_C2C
ret
cwAPI_LinearCheck endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
cwAPI_ExecDebug proc near
mov ds,[ebp+Int_DS]
mov edx,[ebp+Int_EDX]
mov es,[ebp+Int_ES]
mov esi,[ebp+Int_ESI]
mov cx,[ebp+Int_CX]
mov ebx,1
push ebp
call _Exec
jnc api58_0
pop ebp
mov [ebp+Int_AX],ax
jmp api58_9
;
api58_0: shl esi,16
mov si,di
mov edi,ebp
pop ebp
mov [ebp+Int_EAX],eax
mov [ebp+Int_BX],bx
mov [ebp+Int_CX],cx
mov [ebp+Int_EDX],edx
mov [ebp+Int_DI],si
shr esi,16
mov [ebp+Int_SI],si
mov [ebp+Int_EBP],edi
clc
;
api58_9: cwAPI_C2C
IFDEF DEBUG2
push eax
push ebx
push ecx
push edx
push ds
push cs
pop ds
mov edx,OFFSET debugaitext1
debugailoop2:
cmp BYTE PTR ds:[edx],0
je
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -