Jump to content

LoaderHook

From EDM2
Revision as of 17:21, 13 April 2025 by Martini (talk | contribs) (Created page with "This hook allows the library and procedure loading and deleting calls to be intercepted. ==Syntax== rc = LoaderHook(hab, idContext, pszLibname, hlib, pszProcname, wndProc, pfSuccess); ==Parameters== ;''hab'' (HAB) - input: Anchor-block handle. ;''idContext'' (LONG) - input: Origin of call to hook. :LHK_DELETEPROC WinDeleteProcedure :LHK_DELETELIB WinDeleteLibrary :LHK_LOADPROC WinLoadProcedure :LHK_LOADLIB WinLoadLibrary ;''pszLibname'' (PSZ) - input: L...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This hook allows the library and procedure loading and deleting calls to be intercepted.

Syntax

rc = LoaderHook(hab, idContext, pszLibname, hlib, pszProcname, wndProc, pfSuccess);

Parameters

hab (HAB) - input
Anchor-block handle.
idContext (LONG) - input
Origin of call to hook.
LHK_DELETEPROC WinDeleteProcedure
LHK_DELETELIB WinDeleteLibrary
LHK_LOADPROC WinLoadProcedure
LHK_LOADLIB WinLoadLibrary
pszLibname (PSZ) - input
Library name.
This is the same as the library name in the pszLibname parameter of the WinLoadLibrary function.
hlib (PHLIB) - in/out
Pointer to a library handle.
This is the same as the library handle in the hlibLibhandle parameter of the WinLoadProcedure function or the hlibLibhandle parameter of the WinDeleteLibrary function.
If the idContext parameter is set to LHK_LOADLIB, then this hook must set the value of this parameter to the handle of the loaded library or to NULLHANDLE if the load fails.
pszProcname (PSZ) - input
Procedure name.
This is the same as the procedure name in the pszProcname parameter of the WinLoadProcedure function.
wndProc (PFNWP) - input
Window procedure identifier.
This is the same as the library name in the pwndproc parameter of the WinDeleteProcedure function.
If the idContext parameter is set to LHK_LOADPROC, then this hook must set the value of this parameter to the handle of the loaded procedure or to NULL if the load fails.
pfSuccess (PBOOL) - in/out
Success indicator.
TRUE: Library or procedure loaded or deleted successfully.
FALSE: Library or procedure not loaded or deleted successfully.
rc (BOOL) - returns
Processing indicator.
TRUE: Do not call next hook in chain.
FALSE: Call next hook in chain.

Returns

rc (BOOL) - returns
Processing indicator.
TRUE: Do not call next hook in chain.
FALSE: Call next hook in chain.

Remarks

If the hook attempts a load or deletion which is unsuccessful, then the hook must establish the relevant error information.

Example Code

#define INCL_WINHOOKS /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>

HAB   hab;       /* Anchor-block handle. */
LONG  idContext; /* Origin of call to hook. */
PSZ   pszLibname;/* Library name. */
PHLIB hlib;      /* Pointer to a library handle. */
PSZ   pszProcname;/* Procedure name. */
PFNWP wndProc;   /* Window procedure identifier. */
PBOOL pfSuccess; /* Success indicator. */
BOOL  rc;        /* Processing indicator. */

rc = LoaderHook(hab, idContext, pszLibname,
       hlib, pszProcname, wndProc, pfSuccess);