1.4 Windows Calling Conventions

This manual presents the syntax of most functions in C-language notation. All such functions are assumed to be declared as FAR PASCAL functions, and Windows will call these functions as such. In general, exported functions in a device driver must execute the standard Windows prolog on entry and epilog on exit. For more information about the prolog and epilog, see the Microsoft Windows Programmer's Reference.

The following list highlights the calling conventions:

Set the DS register to the selector of the driver's automatic data segment.

Save and restore the following registers if used: SS, SP, BP, SI, DI, and DS.

Clear the direction flag if it has been set or modified.

Place 16-bit return values in the AX register; 32-bit values in the DX:AX register pair.

Execute a FAR return.

Windows pushes all parameters on the stack in a left to right order (the last parameter shown in the function syntax is closest to the stack pointer). Windows also passes pointers parameters as 32-bit quantities, pushing the selector first then the offset. This allows exported functions to use the lds or les instructions to retrieve pointers from the stack.