MakeProcInstance

Syntax

FARPROC MakeProcInstance(lpProc,hInstance)

This function creates a procedure-instance address. A procedure-instance address points to prolog code that is executed before the function is executed. The prolog binds the data segment of the instance specified by the hInstance parameter to the function pointed to by the lpProc parameter. When the function is executed, it has access to variables and data in that instance's data segment.

The FreeProcInstance function frees the function from the data segment bound to it by the MakeProcInstance function.

Parameter Type/Description  

lpProc FARPROC Is a procedure-instance address.  
hInstance HANDLE Identifies the instance associated with the desired data segment.  

Return Value

The return value points to the function if the function is successful. Otherwise, it is NULL.

Comments

The MakeProcInstance function must only be used to access functions from instances of the current module. The function is not required for library modules.

After MakeProcInstance has been called for a particular function, all calls to that function should be made through the retrieved address.

MakeProcInstance will create more than one procedure instance. An application should not call MakeProcInstance more than once using the same function and instance handle to avoid wasting memory.

To bind a data segment to a function, the function must be exported in the EXPORTS statement of the module-definition file.