home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
APR94_2.ZIP
/
LISTDVCB
/
LISTDVCB.ASM
< prev
next >
Wrap
Assembly Source File
|
1994-03-01
|
6KB
|
221 lines
;ListDVCB.ASM
;from Dr. Dobbs Journal, April 1994
;Copyright (c) 1994 Klaus Mueller. All rights reserved.
OPTION M510
.386p
INCLUDE VMM.INC
INCLUDE ListDVCB.inc
;*****************************************************************************
; V I R T U A L D E V I C E D E C L A R A T I O N
;*****************************************************************************
Declare_Virtual_Device ListDVCB, 1, 0, ListDVCB_VxD_Control, \
ListDVCB_Device_ID,ListDVCB_Init_Order, \
ListDVCB_V86_API
;*****************************************************************************
; R E A L M O D E I N I T I A L I Z A T I O N
;*****************************************************************************
VXD_REAL_INIT_SEG
real_init proc near
mov ah, 9
mov dx, offset copyright
int 21h
xor ax, ax
xor bx, bx
xor si, si
xor edx, edx
ret
real_init endp
copyright db 'ListDVCB.386 -- provides a map of VxD areas in the '
db 'Virtual Machine Control Block' ,0dh
db 'Copyright (c) 1994 Klaus Mueller. All Rights Reserved.'
db 0dh,0ah,'$'
VXD_REAL_INIT_ENDS
VxD_ICODE_SEG
;** ListDVCB_Sys_Crit_Init
BeginProc ListDVCB_Sys_Critical_Init
mov Data_Buf_Size,1000h
VMMcall _PageAllocate <1, PG_SYS, 0, 0, 0, 0, 0, PAGEFIXED+PAGEZEROINIT>
cmp eax,0
je allocerr
mov Data_Buf,edx
mov eax,_Allocate_Device_CB_Area
mov esi,offset32 cbhook
VMMcall Hook_Device_Service
mov [oldservice],esi
;int 3
clc ; no error
ret
allocerr:
stc
ret
EndProc ListDVCB_Sys_Critical_Init
VxD_ICODE_ENDS
;*****************************************************************************
; L O C K E D C O D E S E G M E N T
;*****************************************************************************
VxD_LOCKED_CODE_SEG
BeginProc ListDVCB_VxD_Control
Control_Dispatch Sys_Critical_Init, ListDVCB_Sys_Critical_Init
clc
ret
EndProc ListDVCB_VxD_Control
VxD_LOCKED_CODE_ENDS
;*****************************************************************************
; O N L Y D A T A S E G M E N T
;*****************************************************************************
VxD_DATA_SEG
oldservice dd 0 ;original handler for _Allocate_Device_CB_Area
hook_count dd 0 ;# of intercepted calls
string_buf dd 0 ;buffer for VMCB_Hook_Strucs
privcblen dd 0
calladr dd 0
Data_Buf dd 0 ;buffer for Hook_Strucs
Data_Buf_Size dd 0
VxD_DATA_ENDS
VxD_CODE_SEG
BeginProc Hooked_Allocate_Device_CB_Area
cbhook: ;int 3 ;uncomment this for debug
push ebp
mov ebp,esp
push [ebp+0ch] ;Flags
push [ebp+8] ;nbytes
push [ebp+8]
pop privcblen
push [ebp+4] ;Callers returnaddress
pop calladr
call [oldservice]
add esp,8
pop ebp
cmp eax,0 ;error in Allocate_Device_CB_Area ?
je short exit
push edi
push ecx
push eax
mov edi,Data_Buf
mov ecx,hook_count
imul ecx,sizeof Hook_Struc
add edi,ecx
mov eax,calladr
stosd ;store data in our Hook_Struc
pop eax ;offset in VM_CB_Area
push eax
stosd
mov eax,privcblen
stosd ;Because of the few calls to _Allocate_CB_Area
inc hook_count ;a test of Data_Buf overflow is not nessesary
pop eax
pop ecx
pop edi
exit: ;int 3
ret
EndProc Hooked_Allocate_Device_CB_Area
BeginProc ListDVCB_V86_API
cmp [ebp.Client_AX],Hook_Buf_Size
je bufsz
cmp [ebp.Client_AX],Copy_Hook_Data
jne v86err
cmp string_buf,0
je buildcb
jmp cbcpy
v86err: or [ebp.Client_Flags],1
ret
bufsz: mov eax,hook_count
imul eax,sizeof VMCB_Hook_Struc
Client_Ptr_Flat edi,DS,BX ;get offset of long int
stosd
ret
buildcb:mov eax,hook_count ;allocate space for VMCB_Hook_Struc buffer
imul eax,sizeof VMCB_Hook_Struc
cmp eax,1000h
ja cb1
mov eax,1
jmp cb2
cb1: add eax,1000h
and eax,0fffh
shr eax,0ch
cb2: VMMcall _PageAllocate <eax, PG_SYS, 0, 0, 0, 0, 0, PAGEFIXED+PAGEZEROINIT>
cmp eax,0
je cberr1
mov string_buf,edx
mov ecx,hook_count
mov esi,Data_Buf ;buffer of Hook_Strucs
mov edi,string_buf
cbloop: push ecx
push esi
push edi
mov edi,[esi.Hook_Struc.VMCB_Caller_Address]
VxDcall VxDQuery_Address_to_VxDName
jc vmcberr
mov esi,edi ;pointer to VxDName
pop edi ;current VMCB_Hook_Struc
mov ecx,string_len/4
rep movsd ;save VxDName in string_buf
pop esi ;current Hook_Struc
mov ecx,(sizeof Hook_Struc)/4
rep movsd ;copy Hook_Struc to VMCB_Hook_Struc
pop ecx
loop cbloop
cbcpy: Client_Ptr_Flat edi,DS,DX ;address of callers ptr to buffer
mov edi,[edi] ;get buffer address
call v862lin
mov esi,string_buf
mov ecx,hook_count ;# of VMCB_Hook_Strucs
imul ecx,(sizeof VMCB_Hook_Struc)/4
rep movsd ;copy data into callers V86 buffer
ret
vmcberr:add esp,8
cberr1: or [ebp.Client_Flags],1
ret
;v862lin - converts v86 address to linear address
;INPUT edi = Seg:Offs V86
;OUTPUT edi = linadr
v862lin:push edx
movzx edx,di
shr edi,10h
shl edi,4
add edi,edx
pop edx
ret
EndProc ListDVCB_V86_API
VxD_CODE_ENDS
END