SAMPLE: MASMWin.exe Uses MASM 6.0 to Write Windows Application (77256)



The information in this article applies to:

  • Microsoft Platform Software Development Kit (SDK) 1.0

This article was previously published under Q77256

SUMMARY

MASMWin.exe is a sample that demonstrates how to write a complete Windows program using MASM 6.0. Using the high-level language features of the Microsoft Macro Assembler (MASM) version 6.0, it is now much simpler to write a complete Windows program in MASM than with previous versions of the program.

MORE INFORMATION

The following file is available for download from the Microsoft Download Center:
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

MASMWIN demonstrates a number of features of MASM 6.0. It demonstrates the use of alternate PROLOGUE and EPILOGUE code generation. It also demonstrates function prototyping and the use of the INVOKE feature.

While MASM provides a complete programming environment with high-level language features, applications written in MASM will be much more difficult to transfer to future versions of Windows that run on non- Intel platforms.

Using the OPTION:PROLOGUE and OPTION:EPILOGUE directives in MASM 6.0, an application can cause MASM 6.0 to generate any type of prologue or epilogue code desired. For this program, it creates the appropriate Windows code. The macros to perform this task are contained in the file WINPRO.INC. The two declarations, ?WINDOWS=1 and ?PMODE=1, affect the generation of the prologue and epilogue code.

The ?WINDOWS=1 declaration will cause Windows prologue and epilogue code to be generated for all FAR functions. All other functions are declared with the normal function stack frame.

The ?PMODE=1 declaration causes the Windows prologue and epilogue code to be generated only for FAR functions declared as EXPORT. This code takes advantage of the fact that in protected mode, Windows does not walk the stack.

The program includes a WINDOWS.INC file that is different from the one included in Windows Software Development Kit (SDK) version 3.0. This WINDOWS.INC file was created by running WINDOWS.H through the H2INC utility provided with MASM 6.0. This provides prototypes for all of the Windows functions and also translates C structures to corresponding MASM structures. This file allows the INVOKE feature of MASM 6.0 to be used to call Windows functions. The INVOKE function handles all the parameter passing and stack clean up. To use this file, it is necessary to include the following line in the source code before the line that includes the new WINDOWS.INC:
   OPTION CASEMAP:NONE
				
This causes the assembler to maintain case sensitivity when dealing with symbols.

Modification Type:MinorLast Reviewed:7/11/2005
Keywords:kbdownload kbdownload kbfile kbSample KB77256 kbAudDeveloper