Allows the application to monitor ("hook") various OS file system routines
#include <nwfshook.h>
LONG NWAddFSMonitorHook (
LONG callBackNumber,
void *callBackFunc,
LONG *callBackHandle);
(IN) Specifies which type of OS file system routine you want to hook.
(IN) Points to the function that you want the OS to call (pass control to) when the hooked file system routine is going to be or has been called by a client or any NLM application on the local server.
(OUT) Points to a handle that identifies the file system monitor hook. This handle is passed to NWRemoveFSMonitorHook when removing the hook.
If NWAddFSMonitorHook succeeds, it returns 0 if the OS routine corresponding to callBackNumber was successfully "hooked." Otherwise, it returns errors.
The callBackNumber parameter specifies the OS file system routine that you want to hook, and whether the callBackFunc is called before (a "pre OS call hook") or after (a "post OS call hook") the OS routine executes. The last eight sets of hooks (FSHOOK_PRE/POST_RENAME_NS_ENTRY and all generics) are used for tracking routines called from other than DOS clients (note that non-DOS hooks are available for use only with NetWare versions 3.12 and higher.) Hooks cannot be ORed, so you must call NWAddFSMonitorHook once for each routine you want to be monitored. Values for callBackNumber and the OS routines that they hook are defined in nwfshook.h and listed below:
Table 14-1 File System Hooks
The callBackFunc parameter points to the callback function you have created. The number of parameters you should declare in callBackFunc varies depending on when the OS calls back the function.
The first parameter for both types of callback function is a pointer to the structure returned by the OS for the OS file system routine that is being monitored (for example, if you are monitoring file opens, the OS would return an OpenFileCallBackStruct). These callback structures are defined in nwfshook.h.
If you have specified a pre OS call back hook, this is the only parameter for the callBackFunc. If you have specified a post OS call back hook, the callBackFunc receives a second parameter, a pointer to a LONG value which is the completion code of the OS routine that you have hooked. The following illustrates what these functions would look like if you are monitoring file opens:
int PreCallBackFunc (OpenFileCallBackStruct const *structure);
void PostCallBackFunc (OpenFileCallBackStruct const *structure, LONG ccode);
Definitions of the structures returned by the callback function are described in File System Monitoring Structures.
NOTE:If you specify a post OS call back hook, your callback function must not go to sleep, because the values in the callback structure can change before your thread wakes up again.