Introduction to Virtual Device Drivers



Download 274.5 Kb.
Page76/80
Date19.01.2022
Size274.5 Kb.
#58083
1   ...   72   73   74   75   76   77   78   79   80
VXDS

Processing Messages


You process and prepare static messages for display by using the GET_MESSAGE_PTR macro. The following example shows how to retrieve the addresses of two static messages declared in the file USAMSG.INC:

include usamsg.inc


GET_MESSAGE_PTR MSG_BootErrorMsg eax

; address of MSG_BootErrorMsg message now in eax


GET_MESSAGE_PTR MSG_DiskPlease edx

; address of MSG_DiskPlease message now in edx


You process messages containing parameter placeholders by using the PUSH_SPRINTF macro. Because this macro places a new string on the stack, you must use the POP_SPRINTF macro to remove the string from the stack after displaying it.

Of course, since the message is on the stack, it goes away once you call POP_SPRINTF. A common error is passing the pointer to a pushed string to another procedure (such as SHELL_Message), then popping the string before the called procedure is finished with it. If you need a message to be placed somewhere other than the stack, use the LOCALIZED_SPRINTF macro instead.

The following example shows how to process the MSG_CantOpen message:

include usamsg.inc


PUSH_SPRINTF MSG_CantOpen, eax,

; address of new string now in eax


PUSHED_SPRINTF_LENGTH ebx

; string length now in ebx


; Call output function here
POP_SPRINTF ; Remove the string from stack
In this example, the EAX register contains the address of a null-terminated string specifying a filename and the DriveBuf variable contains a null terminated string specifying the drive letter. The parameter placeholders are assumed to be %0s and %1s. The macro creates a new string by replacing the parameter placeholders in the original message with the filename and driver letter. The macro leaves the new string on the stacks copies its address to the EAX register.

See also GET_MESSAGE_PTR, POP_SPRINTF, PUSH_SPRINTF, PUSHED_SPRINTF_LENGTH



Download 274.5 Kb.

Share with your friends:
1   ...   72   73   74   75   76   77   78   79   80




The database is protected by copyright ©ininet.org 2024
send message

    Main page