| Customize Help
| Save Settings

MobjHookFunction



Function Map
Synopsis
Hook a function to an object-related event.
Syntax
void MobjHookFunction(
MIL_ID ObjectId, //in
MIL_INT HookType, //in
MIL_OBJ_HOOK_FUNCTION_PTR HookHandlerPtr, //in
void *UserDataPtr //in-out
)
Description

This function allows you to attach or detach a user-defined function to a specified object-related event. Once a hook-handler function is defined and hooked to an event, it is automatically called when the event occurs.

You can hook more than one function to an event by making separate calls to MobjHookFunction() for each function that you want to hook. MIL automatically chains and keeps an internal list of all these hooked functions. When a function is hooked, this new function is added to the end of the list. When the event happens, all user-defined functions in the list will be executed in the same order that they were hooked to the event. You can also remove any function from the list; in this case, MIL preserves the order of the remaining functions in the list.

You can obtain more information about the event from within the hook handler function using MobjGetHookInfo().

Note that this function reference has not been updated for a MIL system added during a MIL update. Refer to the MIL system's release note to see if there is complementary information.
Parameters
This function is not supported on the selected boards.
Parameters
ObjectId

Specifies the identifier of the object on which to hook a function.

HookType

Specifies the object-related event on which to hook the function. This parameter can be set to one of the following values.

For all objects.

function map For specifying the object-related event to hook
Click to summarizeValue Description
Click to summarize M_OBJECT_FREE +

Hooks the function to the event that occurs when an object is freed.

For message mailbox.

function map For specifying the message mailbox event to hook
Click to summarizeValue Description
Click to summarize M_MESSAGE_RECEIVED +

Hooks the function to the event that occurs when a message is received by the message mailbox.

Click to summarize M_READ_TIMEOUT +

Hooks the function to the event that occurs when a read operation times out.

Click to summarize M_WRITE_TIMEOUT +

Hooks the function to the event that occurs when a write operation times out.

Combination value for the values listed in For specifying the object-related event to hook; the values listed in For specifying the message mailbox event to hook.

You can add the following value to the above-mentioned values to specify that the function should be unhooked.

function map For specifying that the function should be unhooked
Click to summarizeCombination value Description
Click to summarize M_UNHOOK

Unhooks a hooked function.

HookHandlerPtr

Specifies the address of the function that should be called when the specified event occurs. The hook-handler function must be declared as follows:

MIL_INT MFTYPE HookHandler(
MIL_INT HookType,
MIL_ID EventId,
void *UserDataPtr
)

Parameters
HookType

Type of event hooked.

EventId

Event identifier to pass to MobjGetHookInfo() when inquiring about the hooked event.

UserDataPtr

Specifies the user data pointer passed to MobjHookFunction().

Upon successful completion, the hook-handler function should return M_NULL. Note, MIL_OBJ_HOOK_FUNCTION_PTR and MFTYPE are reserved MIL predefined types for functions and data pointers.

UserDataPtr

Specifies the address of the user data that you want to make available to the hook-handler function. This address is passed to the hook-handler function, through its UserDataPtr parameter, when the specified event occurs. Set this parameter to M_NULL if not used.

Compilation information
Header Include mil.h.
Library Use mil.lib.
DLL Requires mil.dll.
OBJECT FREE MESSAGE RECEIVED READ TIMEOUT WRITE TIMEOUT UNHOOK