📄 api.asm
字号:
@@3: ;
mov bx,w[ebp+Int_SI]
sys GetSelDet32 ;get selectors details.
jc @@9
mov esi,edx
movzx eax,w[ebp+Int_DI]
add esi,eax ;get memory blocks address.
call mcbRelMemLinear32 ;release the memory.
;
;Check if block had it's own selector.
;
cmp w[ebp+Int_DI],0 ;offset of zero?
jnz @@4
mov bx,w[ebp+Int_SI]
sys RelSel ;release the selector.
;
@@4: clc
;
@@9: cwAPI_C2C
ret
; MED 11/18/96
@@bad:
stc
jmp @@9
cwAPI_RelMemSO endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Allocate a block of memory without a selector.
;
;On Entry:
;
;CX:DX - Size of block required in bytes.
;
;On Exit:
;
;Carry clear if OK &,
;
;SI:DI - Linear address of block allocated.
;
cwAPI_GetMemLinear proc near
mov cx,[ebp+Int_CX]
mov dx,[ebp+Int_DX]
shl ecx,16
mov cx,dx
call mcbGetMemLinear32
jc @@9
mov di,si
shr esi,16
mov [ebp+Int_SI],si
mov [ebp+Int_DI],di
clc
@@9: cwAPI_C2C
ret
cwAPI_GetMemLinear endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Allocate a block of memory without a selector.
;
;On Entry:
;
;ECX - Size of block required in bytes.
;
;On Exit:
;
;Carry clear if OK &,
;
;ESI - Linear address of block allocated.
;
cwAPI_GetMemLinear32 proc near
mov ecx,[ebp+Int_ECX]
call mcbGetMemLinear32
cwAPI_C2C
jc @@9
mov [ebp+Int_ESI],esi
@@9: ret
cwAPI_GetMemLinear32 endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Re-size a previously allocated block of memory without a selector.
;
;On Entry:
;
;SI:DI - Linear address of block to re-size.
;CX:DX - Size of block required in bytes.
;
;On Exit:
;
;Carry clear if OK &,
;
;SI:DI - New linear address of block.
;
cwAPI_ResMemLinear proc near
mov si,[ebp+Int_SI]
mov di,[ebp+Int_DI]
mov cx,[ebp+Int_CX]
mov dx,[ebp+Int_DX]
shl ecx,16
mov cx,dx
shl esi,16
mov si,di
call mcbResMemLinear32
jc @@9
mov di,si
shr esi,16
mov [ebp+Int_SI],si
mov [ebp+Int_DI],di
clc
@@9: cwAPI_C2C
ret
cwAPI_ResMemLinear endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Re-size a previously allocated block of memory without a selector.
;
;On Entry:
;
;ESI - Linear address of block to re-size.
;ECX - Size of block required in bytes.
;
;On Exit:
;
;Carry clear if OK &,
;
;ESI - New linear address of block.
;
cwAPI_ResMemLinear32 proc near
mov esi,[ebp+Int_ESI]
mov ecx,[ebp+Int_ECX]
call mcbResMemLinear32
jc @@9
mov [ebp+Int_ESI],esi
@@9: cwAPI_C2C
ret
cwAPI_ResMemLinear32 endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Release previously allocated block of memory (linear address).
;
;On Entry:
;
;SI:DI - Linear address of block to release.
;
;On Exit:
;
cwAPI_RelMemLinear proc near
mov si,[ebp+Int_SI]
mov di,[ebp+Int_DI]
shl esi,16
mov si,di
call mcbRelMemLinear32
cwAPI_C2C
ret
cwAPI_RelMemLinear endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Release previously allocated block of memory (linear address).
;
;On Entry:
;
;ESI - Linear address of block to release.
;
;On Exit:
;
cwAPI_RelMemLinear32 proc near
mov esi,[ebp+Int_ESI]
call mcbRelMemLinear32
cwAPI_C2C
ret
cwAPI_RelMemLinear32 endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Allocate an application relative block of memory.
;
;On Entry:
;
;EBX - Size of block required in bytes.
;
;On Exit:
;
;Carry clear if OK &,
;
;ESI - Application relative linear address of block allocated.
;
cwAPI_GetMemNear proc near
mov ecx,[ebp+Int_EBX]
call mcbGetMemLinear32
jc @@9
assume ds:nothing
mov ds,cs:apiDSeg
assume ds:_cwMain
mov ds,PSPSegment
sub esi,ds:d[EPSP_NearBase]
assume ds:_apiCode
mov [ebp+Int_ESI],esi
clc
@@9: cwAPI_C2C
ret
cwAPI_GetMemNear endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Re-size a previously allocated application relative block of memory.
;
;On Entry:
;
;EBX - Size of block required in bytes.
;ESI - application relative linear address of block to re-size.
;
;On Exit:
;
;Carry clear if OK &,
;
;ESI - New application relative linear address of block.
;
cwAPI_ResMemNear proc near
mov ecx,[ebp+Int_EBX]
mov esi,[ebp+Int_ESI]
assume ds:nothing
mov ds,cs:apiDSeg
assume ds:_cwMain
mov ds,PSPSegment
add esi,ds:d[EPSP_NearBase]
assume ds:_apiCode
call mcbResMemLinear32
jc @@9
assume ds:nothing
mov ds,cs:apiDSeg
assume ds:_cwMain
mov ds,PSPSegment
sub esi,ds:d[EPSP_NearBase]
assume ds:_apiCode
mov [ebp+Int_ESI],esi
clc
@@9: cwAPI_C2C
ret
cwAPI_ResMemNear endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Release previously allocated application relative block of memory.
;
;On Entry:
;
;ESI - Application relative linear address of block to release.
;
cwAPI_RelMemNear proc near
mov esi,[ebp+Int_ESI]
assume ds:nothing
mov ds,cs:apiDSeg
assume ds:_cwMain
mov ds,PSPSegment
add esi,ds:d[EPSP_NearBase]
assume ds:_apiCode
call mcbRelMemLinear32
cwAPI_C2C
ret
cwAPI_RelMemNear endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Convert linear address to application relative address.
;
;On Entry:
;
;ESI - Linear address to convert.
;
;On Exit:
;
;ESI - Application relative linear address.
;
cwAPI_Linear2Near proc near
mov esi,[ebp+Int_ESI]
assume ds:nothing
mov ds,cs:apiDSeg
assume ds:_cwMain
mov ds,PSPSegment
sub esi,ds:d[EPSP_NearBase]
assume ds:_apiCode
mov [ebp+Int_ESI],esi
ret
cwAPI_Linear2Near endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Convert application relative address to linear address.
;
;On Entry:
;
;ESI - Application relative linear address.
;
;On Exit:
;
;ESI - Linear address to convert.
;
cwAPI_Near2Linear proc near
mov esi,[ebp+Int_ESI]
assume ds:nothing
mov ds,cs:apiDSeg
assume ds:_cwMain
mov ds,PSPSegment
add esi,ds:d[EPSP_NearBase]
assume ds:_apiCode
mov [ebp+Int_ESI],esi
ret
cwAPI_Near2Linear endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Lock a region of memory.
;
;On Entry:
;
;BX:CX - Starting linear address of memory to lock.
;SI:DI - Size of region to lock in bytes.
;
;On Exit:
;
;Carry set on error, none of the memory locked, else memory is locked.
;
cwAPI_LockMem proc near
mov bx,[ebp+Int_BX]
mov cx,[ebp+Int_CX]
mov si,[ebp+Int_SI]
mov di,[ebp+Int_DI]
mov ax,0600h
cwAPI_CallOld
jc @@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
;
@@9: cwAPI_C2C
ret
cwAPI_LockMem endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Lock a region of memory.
;
;On Entry:
;
;ESI - Starting linear address of memory to lock.
;ECX - Size of region to lock in bytes.
;
;On Exit:
;
;Carry set on error, none of the memory locked, else memory is locked.
;
cwAPI_LockMem32 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,0600h
cwAPI_CallOld
jc @@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
@@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 @@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
@@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 @@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
@@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,ds:d[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 @@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
@@9: cwAPI_C2C
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -