home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Pier Shareware 6
/
The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso
/
046
/
dosq1194.exe
/
POSTMSG.ASM
next >
Wrap
Assembly Source File
|
1994-11-01
|
6KB
|
170 lines
;******************************************************************************
; POSTMSG.386 is a simple VxD that allows an MS-DOS application to send
; messages to a Windows application.
;
; Note: The device ID used by POSTMSG is not registered. Therefore, there
; is no guarantee that it will not conflict with other VxDs, although the
; possibility of a conflict is remote.
;******************************************************************************
.386p
;******************************************************************************
; I N C L U D E S
;******************************************************************************
.XLIST
INCLUDE VMM.INC
.LIST
;******************************************************************************
; E Q U A T E S
;******************************************************************************
POSTMSG_Major_Ver equ 1
POSTMSG_Minor_Ver equ 0
POSTMSG_Device_ID equ 4321h
WM_USER equ 400h
;******************************************************************************
; 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 POSTMSG,\
POSTMSG_Major_Ver,\
POSTMSG_Minor_Ver,\
POSTMSG_Control,\
POSTMSG_Device_ID,\
Undefined_Init_Order,\
POSTMSG_V86_API_Proc,\
POSTMSG_PM_API_Proc
;******************************************************************************
; D A T A
;******************************************************************************
VxD_DATA_SEG
hwnd dw 0 ;Handle of window to receive messages
CallbackOff dw ? ;Offset address of callback function
CallbackSeg dw ? ;Segment address of callback function
wParam dw ? ;wParam
lParamLo dw ? ;Low word of lParam
lParamHi dw ? ;High word of lParam
VxD_DATA_ENDS
;******************************************************************************
; P A G E - L O C K E D C O D E
;******************************************************************************
VxD_LOCKED_CODE_SEG
BeginProc POSTMSG_Control
clc
ret
EndProc POSTMSG_Control
VxD_LOCKED_CODE_ENDS
;******************************************************************************
; C O D E
;******************************************************************************
VxD_CODE_SEG
;
; POSTMSG_V86_API_Proc is the exported API procedure that an MS-DOS app
; calls to post a message to a Windows app. On entry, BX specifies the value
; of the wParam parameter that will be passed to the Windows app, and DX:AX
; specifies the value of lParam. On return, carry set means a Windows app
; has not registered to receive messages.
;
BeginProc POSTMSG_V86_API_Proc
cmp hwnd,0 ;Exit now if no Windows app
je VP_Error ;is registered
mov ax,[ebp.Client_BX] ;Save the message parameters
mov wParam,ax ;passed in the AX, BX, and DX
mov ax,[ebp.Client_AX] ;registers
mov lParamLo,ax
mov ax,[ebp.Client_DX]
mov lParamHi,ax
mov eax,High_Pri_Device_Boost ;Schedule a callback event
VMMcall Get_Sys_VM_Handle ;for the system VM
mov ecx,PEF_Wait_For_STI OR PEF_Wait_Not_Crit
mov esi,OFFSET32 POSTMSG_DoCallback
VMMcall Call_Priority_VM_Event
and [ebp.Client_EFlags], NOT (CF_MASK) ;Exit with carry clear
ret ;indicating success
VP_Error:
or [ebp.Client_EFlags], CF_MASK ;Exit with carry set
ret ;indicating failure
EndProc POSTMSG_V86_API_Proc
;
; POSTMSG_DoCallback posts a message to a Windows app by performing a far
; call to the app's callback function, which in turn calls PostMessage.
;
BeginProc POSTMSG_DoCallback
Push_Client_State ;Save client registers
VMMcall Begin_Nest_Exec ;Start nested execution block
mov ax,hwnd ;Put PostMessage parameters
VMMcall Simulate_Push ;on the stack in preparation
mov ax,WM_USER ;for the call
add ax,100h
VMMcall Simulate_Push
mov ax,wParam
VMMcall Simulate_Push
mov ax,lParamHi
VMMcall Simulate_Push
mov ax,lParamLo
VMMcall Simulate_Push
mov cx,CallbackSeg ;Perfor a far call to the
movzx edx,CallbackOff ;Windows app's callback
VMMcall Simulate_Far_Call ;procedure
VMMcall Resume_Exec ;Resume execution of this VM
VMMcall End_Nest_Exec ;End nested execution
Pop_Client_State ;Restore client registers
ret ;Done
EndProc POSTMSG_DoCallback
;
; POSTMSG_PM_API_Proc is the exported API procedure that a protected mode
; Windows app calls to register itself with POSTMSG. On entry, AX holds the
; handle of the window to which messages will be posted, and CX:BX holds the
; segment:offset address of the app's callback procedure, which should be in
; a fixed, nondiscardable code segment.
;
BeginProc POSTMSG_PM_API_Proc
mov ax,[ebp.Client_AX] ;Save the window handle
mov hwnd,ax
mov ax,[ebp.Client_BX] ;Save the address of the
mov CallbackOff,ax ;callback function
mov ax,[ebp.Client_CX]
mov CallbackSeg,ax
ret
EndProc POSTMSG_PM_API_Proc
VxD_CODE_ENDS
END