ReactOS 0.4.16-dev-959-g2ec3a19
ldrnotify.c File Reference
#include "ntdll_vista.h"
Include dependency graph for ldrnotify.c:

Go to the source code of this file.

Classes

struct  _LDR_DLL_NOTIFICATION_ENTRY
 

Macros

#define LdrpAssertDllNotificationDataMember(x)
 

Typedefs

typedef struct _LDR_DLL_NOTIFICATION_ENTRY LDR_DLL_NOTIFICATION_ENTRY
 
typedef struct _LDR_DLL_NOTIFICATION_ENTRYPLDR_DLL_NOTIFICATION_ENTRY
 

Functions

static RTL_STATIC_LIST_HEAD (LdrpDllNotificationList)
 
NTSTATUS NTAPI LdrRegisterDllNotification (_In_ ULONG Flags, _In_ PLDR_DLL_NOTIFICATION_FUNCTION NotificationFunction, _In_opt_ PVOID Context, _Out_ PVOID *Cookie)
 
NTSTATUS NTAPI LdrUnregisterDllNotification (_In_ PVOID Cookie)
 
VOID NTAPI LdrpSendDllNotifications (_In_ PLDR_DATA_TABLE_ENTRY DllEntry, _In_ ULONG NotificationReason)
 

Variables

static RTL_CRITICAL_SECTION LdrpDllNotificationLock
 
static RTL_CRITICAL_SECTION_DEBUG LdrpDllNotificationLockDebug
 

Macro Definition Documentation

◆ LdrpAssertDllNotificationDataMember

#define LdrpAssertDllNotificationDataMember (   x)
Value:
@ Loaded
Definition: fs_rec.h:187
#define C_ASSERT(e)
Definition: intsafe.h:73
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Typedef Documentation

◆ LDR_DLL_NOTIFICATION_ENTRY

◆ PLDR_DLL_NOTIFICATION_ENTRY

Function Documentation

◆ LdrpSendDllNotifications()

VOID NTAPI LdrpSendDllNotifications ( _In_ PLDR_DATA_TABLE_ENTRY  DllEntry,
_In_ ULONG  NotificationReason 
)

Definition at line 104 of file ldrnotify.c.

107{
111
112 /*
113 * LDR_DLL_LOADED_NOTIFICATION_DATA and LDR_DLL_UNLOADED_NOTIFICATION_DATA
114 * currently are the same. Use C_ASSERT to ensure it, then fill either of them.
115 */
116#define LdrpAssertDllNotificationDataMember(x)\
117 C_ASSERT(FIELD_OFFSET(LDR_DLL_NOTIFICATION_DATA, Loaded.x) ==\
118 FIELD_OFFSET(LDR_DLL_NOTIFICATION_DATA, Unloaded.x))
119
120 C_ASSERT(sizeof(NotificationData.Loaded) == sizeof(NotificationData.Unloaded));
126
127#undef LdrpAssertDllNotificationDataMember
128
129 NotificationData.Loaded.Flags = 0; /* Reserved and always 0, not DllEntry->Flags */
130 NotificationData.Loaded.FullDllName = &DllEntry->FullDllName;
131 NotificationData.Loaded.BaseDllName = &DllEntry->BaseDllName;
132 NotificationData.Loaded.DllBase = DllEntry->DllBase;
133 NotificationData.Loaded.SizeOfImage = DllEntry->SizeOfImage;
134
135 /* Send notification to all registered callbacks */
138 {
139 for (Entry = LdrpDllNotificationList.Flink;
140 Entry != &LdrpDllNotificationList;
141 Entry = Entry->Flink)
142 {
144 NotificationEntry->Callback(NotificationReason,
146 NotificationEntry->Context);
147 }
148 }
150 {
152 }
153 _SEH2_END;
154}
#define LdrpAssertDllNotificationDataMember(x)
static RTL_CRITICAL_SECTION LdrpDllNotificationLock
Definition: ldrnotify.c:22
_In_ PCWSTR FullDllName
Definition: ldrtypes.h:264
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define _SEH2_FINALLY
Definition: pseh2_64.h:130
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
base of all file and directory entries
Definition: entries.h:83
Definition: ldrnotify.c:13
Definition: typedefs.h:120
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_In_ PCWDF_DEVICE_PNP_NOTIFICATION_DATA NotificationData
Definition: wdfdevice.h:782
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ ULONG _In_opt_ PVOID _In_ PDRIVER_OBJECT _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE _Inout_opt_ __drv_aliasesMem PVOID _Outptr_result_nullonfailure_ _At_ * NotificationEntry(return==0, __drv_allocatesMem(Mem))) PVOID *NotificationEntry

Referenced by LdrpMapDll(), and LdrUnloadDll().

◆ LdrRegisterDllNotification()

NTSTATUS NTAPI LdrRegisterDllNotification ( _In_ ULONG  Flags,
_In_ PLDR_DLL_NOTIFICATION_FUNCTION  NotificationFunction,
_In_opt_ PVOID  Context,
_Out_ PVOID Cookie 
)

Definition at line 39 of file ldrnotify.c.

44{
46
47 /* Check input parameters */
48 if (Flags != 0 || NotificationFunction == NULL || Cookie == NULL)
49 {
51 }
52
53 /* Allocate new entry and assign input values */
54 NewEntry = RtlAllocateHeap(LdrpHeap, 0, sizeof(*NewEntry));
55 if (NewEntry == NULL)
56 {
57 return STATUS_NO_MEMORY;
58 }
59 NewEntry->Callback = NotificationFunction;
60 NewEntry->Context = Context;
61
62 /* Add node to the end of global list */
64 InsertTailList(&LdrpDllNotificationList, &NewEntry->List);
66
67 /* Cookie is address of the new entry */
68 *Cookie = NewEntry;
69 return STATUS_SUCCESS;
70}
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NULL
Definition: types.h:112
#define InsertTailList(ListHead, Entry)
PVOID LdrpHeap
Definition: ldrinit.c:3
#define STATUS_SUCCESS
Definition: shellext.h:65
PVOID Context
Definition: ldrnotify.c:16
LIST_ENTRY List
Definition: ldrnotify.c:14
PLDR_DLL_NOTIFICATION_FUNCTION Callback
Definition: ldrnotify.c:15
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_opt_ PVOID _Out_ PLARGE_INTEGER Cookie
Definition: cmfuncs.h:14

◆ LdrUnregisterDllNotification()

NTSTATUS NTAPI LdrUnregisterDllNotification ( _In_ PVOID  Cookie)

Definition at line 74 of file ldrnotify.c.

76{
79
80 /* Find entry to remove */
82 for (Entry = LdrpDllNotificationList.Flink;
83 Entry != &LdrpDllNotificationList;
84 Entry = Entry->Flink)
85 {
86 if (Entry == Cookie)
87 {
90 break;
91 }
92 }
94
95 if (NT_SUCCESS(Status))
96 {
98 }
99 return Status;
100}
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
Status
Definition: gdiplustypes.h:25
#define STATUS_DLL_NOT_FOUND
Definition: ntstatus.h:545

◆ RTL_STATIC_LIST_HEAD()

static RTL_STATIC_LIST_HEAD ( LdrpDllNotificationList  )
static

Variable Documentation

◆ LdrpDllNotificationLock

static RTL_CRITICAL_SECTION LdrpDllNotificationLock
static
Initial value:
= {
-1,
0,
0,
0,
0
}
static RTL_CRITICAL_SECTION_DEBUG LdrpDllNotificationLockDebug
Definition: ldrnotify.c:23

Definition at line 22 of file ldrnotify.c.

Referenced by LdrpSendDllNotifications(), LdrRegisterDllNotification(), and LdrUnregisterDllNotification().

◆ LdrpDllNotificationLockDebug

RTL_CRITICAL_SECTION_DEBUG LdrpDllNotificationLockDebug
static
Initial value:
= {
.CriticalSection = &LdrpDllNotificationLock
}

Definition at line 23 of file ldrnotify.c.