How to Implement a Function Pointer in MASM (34377)
The information in this article applies to:
- Microsoft Macro Assembler (MASM) 5.0
- Microsoft Macro Assembler (MASM) 5.1
- Microsoft Macro Assembler (MASM) 5.1a
- Microsoft Macro Assembler (MASM) 6.0
- Microsoft Macro Assembler (MASM) 6.0a
- Microsoft Macro Assembler (MASM) 6.0b
This article was previously published under Q34377 SUMMARY
The following sample program illustrates how to implement a function
pointer using the Microsoft Macro Assembler. It takes the address of
the function (in this example, the address is loaded into ES:DX) and
moves it into a 4-byte variable; it then does a far call through the
pointer.
In this example, it may seem odd to call a function in this manner
because the function is defined locally and its name is known;
however, what if the name of the function was not known? What if you
were programming a device driver and all that was know was the entry
point of the function? Using the following technique, a name could be
given to the address of the function and the function could be called
like any other function.
Modification Type: | Minor | Last Reviewed: | 11/19/2003 |
---|
Keywords: | KB34377 |
---|
|