LdrDllNotification 回调函数

[此函数可能会从 Windows 中更改或删除,而无需进一步通知。]

使用 LdrRegisterDllNotification 函数指定的通知回调函数。 首次加载 DLL 时,加载程序将调用此函数。

警告

通知回调调用除自身以外的任何其他模块中的函数是不安全的。

语法

VOID CALLBACK LdrDllNotification(
  _In_     ULONG                       NotificationReason,
  _In_     PCLDR_DLL_NOTIFICATION_DATA NotificationData,
  _In_opt_ PVOID                       Context
);

参数

NotificationReason [in]

调用通知回调函数的原因。 此参数可以是下列值之一。

价值 意义
LDR_DLL_NOTIFICATION_REASON_LOADED
1
DLL 已加载。 NotificationData 参数指向 LDR_DLL_LOADED_NOTIFICATION_DATA 结构。
LDR_DLL_NOTIFICATION_REASON_UNLOADED
2
DLL 已卸载。 NotificationData 参数指向 LDR_DLL_UNLOADED_NOTIFICATION_DATA 结构。

 

NotificationData [in]

指向包含通知数据的常量 LDR_DLL_NOTIFICATION 联合的指针。 此联合具有以下定义:

typedef union _LDR_DLL_NOTIFICATION_DATA {
    LDR_DLL_LOADED_NOTIFICATION_DATA Loaded;
    LDR_DLL_UNLOADED_NOTIFICATION_DATA Unloaded;
} LDR_DLL_NOTIFICATION_DATA, *PLDR_DLL_NOTIFICATION_DATA;

LDR_DLL_LOADED_NOTIFICATION_DATA 结构具有以下定义:

typedef struct _LDR_DLL_LOADED_NOTIFICATION_DATA {
    ULONG Flags;                    //Reserved.
    PCUNICODE_STRING FullDllName;   //The full path name of the DLL module.
    PCUNICODE_STRING BaseDllName;   //The base file name of the DLL module.
    PVOID DllBase;                  //A pointer to the base address for the DLL in memory.
    ULONG SizeOfImage;              //The size of the DLL image, in bytes.
} LDR_DLL_LOADED_NOTIFICATION_DATA, *PLDR_DLL_LOADED_NOTIFICATION_DATA;

LDR_DLL_UNLOADED_NOTIFICATION_DATA 结构具有以下定义:

typedef struct _LDR_DLL_UNLOADED_NOTIFICATION_DATA {
    ULONG Flags;                    //Reserved.
    PCUNICODE_STRING FullDllName;   //The full path name of the DLL module.
    PCUNICODE_STRING BaseDllName;   //The base file name of the DLL module.
    PVOID DllBase;                  //A pointer to the base address for the DLL in memory.
    ULONG SizeOfImage;              //The size of the DLL image, in bytes.
} LDR_DLL_UNLOADED_NOTIFICATION_DATA, *PLDR_DLL_UNLOADED_NOTIFICATION_DATA;

上下文 [in, 可选]

指向回调函数的上下文数据的指针。

返回值

此回调函数不返回值。

言论

在动态链接发生之前调用通知回调函数。

要求

要求 价值
支持的最低客户端
Windows Vista [仅限桌面应用]
支持的最低服务器
Windows Server 2008 [仅限桌面应用]

另请参阅

LdrRegisterDllNotification

LdrUnregisterDllNotification