ReactOS 0.4.16-dev-1946-g52006dd
wdfloader.h File Reference
#include <fxldr.h>
#include <aux_klib.h>
#include <ntintsafe.h>
#include <ntstrsafe.h>
Include dependency graph for wdfloader.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _WDF_LDR_GLOBALS
 
struct  _WDFLDR_DIAGS
 
struct  _LIBRARY_MODULE
 
struct  _WDF_LOADER_INTERFACE_DIAGNOSTIC
 
struct  _WDF_LOADER_INTERFACE_CLASS_BIND
 
struct  _CLIENT_MODULE
 
struct  _CLASS_MODULE
 
struct  _CLASS_CLIENT_MODULE
 

Macros

#define WDFLDR_TAG   'LfdW'
 
#define __PrintUnfiltered(...)    DbgPrintEx(DPFLTR_DEFAULT_ID, DPFLTR_ERROR_LEVEL, __VA_ARGS__)
 
#define DPRINT(_x_)
 
#define DPRINT_VERBOSE(_x_)
 
#define DPRINT_ERROR(_x_)
 
#define DPRINT_TRACE_ENTRY()
 
#define DPRINT_TRACE_EXIT()
 
#define __DBGPRINT(_x_)
 
#define DIAGFLAG_ENABLED   0x00000001
 
#define DIAGFLAG_VERBOSE_LOGGING   0x00000002
 
#define DIAGFLAG_TRACE_FUNCTION_ENTRY   0x00000004
 
#define DIAGFLAG_TRACE_FUNCTION_EXIT   0x00000008
 
#define DIAGFLAG_LOG_ERRORS   0x00000010
 
#define DIAGFLAG_LOG_WARNINGS   0x00000020
 

Typedefs

typedef struct _WDF_LDR_GLOBALS WDF_LDR_GLOBALS
 
typedef struct _WDF_LDR_GLOBALSPWDF_LDR_GLOBALS
 
typedef struct _WDFLDR_DIAGS WDFLDR_DIAGS
 
typedef struct _WDFLDR_DIAGSPWDFLDR_DIAGS
 
typedef struct _LIBRARY_MODULE LIBRARY_MODULE
 
typedef struct _LIBRARY_MODULEPLIBRARY_MODULE
 
typedef NTSTATUS(NTAPIPWDF_CLASS_BIND) (PWDF_BIND_INFO BindInfo, PWDF_COMPONENT_GLOBALS *Globals, PWDF_CLASS_BIND_INFO ClassBindInfo)
 
typedef VOID(NTAPIPWDF_CLASS_UNBIND) (PWDF_BIND_INFO BindInfo, PWDF_COMPONENT_GLOBALS Globals, PWDF_CLASS_BIND_INFO ClassBindInfo)
 
typedef struct _WDF_LOADER_INTERFACE_DIAGNOSTIC WDF_LOADER_INTERFACE_DIAGNOSTIC
 
typedef struct _WDF_LOADER_INTERFACE_DIAGNOSTICPWDF_LOADER_INTERFACE_DIAGNOSTIC
 
typedef struct _WDF_LOADER_INTERFACE_CLASS_BIND WDF_LOADER_INTERFACE_CLASS_BIND
 
typedef struct _WDF_LOADER_INTERFACE_CLASS_BINDPWDF_LOADER_INTERFACE_CLASS_BIND
 
typedef struct _CLIENT_MODULE CLIENT_MODULE
 
typedef struct _CLIENT_MODULEPCLIENT_MODULE
 
typedef struct _CLASS_MODULE CLASS_MODULE
 
typedef struct _CLASS_MODULEPCLASS_MODULE
 
typedef struct _CLASS_CLIENT_MODULE CLASS_CLIENT_MODULE
 
typedef struct _CLASS_CLIENT_MODULEPCLASS_CLIENT_MODULE
 

Functions

PCLASS_MODULE ClassCreate (_In_ PWDF_CLASS_LIBRARY_INFO ClassLibInfo, _In_ PLIBRARY_MODULE LibModule, _In_ PUNICODE_STRING ServiceName)
 
NTSTATUS ClassOpen (_Inout_ PCLASS_MODULE ClassModule, _In_ PUNICODE_STRING ObjectName)
 
PLIST_ENTRY LibraryAddToClassListLocked (_In_ PLIBRARY_MODULE LibModule, _In_ PCLASS_MODULE ClassModule)
 
VOID ClassRemoveFromLibraryList (_In_ PCLASS_MODULE ClassModule)
 
PLIST_ENTRY LibraryUnloadClasses (_In_ PLIBRARY_MODULE LibModule)
 
PCLASS_CLIENT_MODULE ClassClientCreate ()
 
NTSTATUS ReferenceClassVersion (_In_ PWDF_CLASS_BIND_INFO ClassBindInfo, _In_ PWDF_BIND_INFO BindInfo, _Out_ PCLASS_MODULE *ClassModule)
 
VOID DereferenceClassVersion (_In_ PWDF_CLASS_BIND_INFO ClassBindInfo, _In_ PWDF_BIND_INFO BindInfo, _In_ PWDF_COMPONENT_GLOBALS Globals)
 
NTSTATUS ClassLinkInClient (_In_ PCLASS_MODULE ClassModule, _In_ PWDF_CLASS_BIND_INFO ClassBindInfo, _In_ PWDF_BIND_INFO BindInfo, _Out_ PCLASS_CLIENT_MODULE ClassClientModule)
 
PCLASS_MODULE FindClassByServiceNameLocked (_In_ PUNICODE_STRING Path, _Out_ PLIBRARY_MODULE *LibModule)
 
VOID NTAPI ClassAddReference (_In_ PCLASS_MODULE ClassModule)
 
VOID ClassClose (_In_ PCLASS_MODULE ClassModule)
 
VOID ClassReleaseClientReference (_In_ PCLASS_MODULE ClassModule)
 
VOID FxLdrAcquireLoadedModuleLock (VOID)
 
VOID FxLdrReleaseLoadedModuleLock (VOID)
 
NTSTATUS GetImageInfo (_In_ PCUNICODE_STRING ImageName, _Out_ PVOID *ImageBase, _Out_ PULONG ImageSize)
 
NTSTATUS GetImageName (_In_ PCUNICODE_STRING ServicePath, _In_ PUNICODE_STRING ImageName)
 
VOID GetNameFromPath (_In_ PCUNICODE_STRING Path, _Out_ PUNICODE_STRING Name)
 
NTSTATUS LibraryCreate (_In_opt_ PWDF_LIBRARY_INFO LibraryInfo, _In_ PCUNICODE_STRING ServicePath, _Out_ PLIBRARY_MODULE *OutLibraryModule)
 
NTSTATUS LibraryOpen (_Inout_ PLIBRARY_MODULE LibModule, _In_ PCUNICODE_STRING ObjectName)
 Opens KMDF library's driver object by its name and fills some library structure data.
 
VOID LibraryClose (_Inout_ PLIBRARY_MODULE LibModule)
 Dereferences KMDF library's device object.
 
NTSTATUS LibraryFindOrLoad (_In_ PCUNICODE_STRING ServicePath, _Out_ PLIBRARY_MODULE *LibModule)
 
VOID LibraryReference (_In_ PLIBRARY_MODULE LibModule)
 
VOID LibraryDereference (_In_ PLIBRARY_MODULE LibModule)
 
VOID LibraryUnload (_In_ PLIBRARY_MODULE LibModule)
 
VOID LibraryFree (_In_ PLIBRARY_MODULE LibModule)
 
BOOLEAN LibraryAcquireClientLock (_In_ PLIBRARY_MODULE LibModule)
 
VOID LibraryReleaseClientLock (_In_ PLIBRARY_MODULE LibModule)
 
NTSTATUS LibraryLinkInClient (_In_ PLIBRARY_MODULE LibModule, _In_ PUNICODE_STRING ServicePath, _In_ PWDF_BIND_INFO BindInfo, _In_ PVOID Context, _Out_ PCLIENT_MODULE *OutClientModule)
 Create client module and add it to library client list.
 
BOOLEAN LibraryUnlinkClient (_In_ PLIBRARY_MODULE LibModule, _In_ PWDF_BIND_INFO BindInfo)
 
PLIBRARY_MODULE FindLibraryByServicePathLocked (_In_ PCUNICODE_STRING ServicePath)
 
VOID NTAPI LibraryReleaseReference (_In_ PLIBRARY_MODULE LibModule)
 Release a reference to a library module.
 
NTSTATUS NTAPI FindModuleByClientService (_In_ PUNICODE_STRING RegistryPath, _Out_ PLIBRARY_MODULE *Library)
 
NTSTATUS NTAPI ReferenceVersion (_In_ PWDF_BIND_INFO Info, _Out_ PLIBRARY_MODULE *Module)
 Reference a WDF library version.
 
NTSTATUS NTAPI DereferenceVersion (_In_ PWDF_BIND_INFO Info, _In_opt_ PWDF_COMPONENT_GLOBALS Globals)
 Dereference a WDF library version.
 
NTSTATUS BuildServicePath (_In_ PKEY_VALUE_PARTIAL_INFORMATION KeyValueInformation, _In_ PUNICODE_STRING ServicePath)
 
NTSTATUS GetVersionServicePath (_In_ PWDF_BIND_INFO BindInfo, _Out_ PUNICODE_STRING ServicePath)
 Get service path from bind info and registry.
 
BOOLEAN ServiceCheckBootStart (_In_ PUNICODE_STRING Service)
 
NTSTATUS FxLdrQueryUlong (_In_ HANDLE KeyHandle, _In_ PUNICODE_STRING ValueName, _Out_ PULONG Value)
 
NTSTATUS FxLdrQueryData (_In_ HANDLE KeyHandle, _In_ PUNICODE_STRING ValueName, _In_ ULONG Tag, _Out_ PKEY_VALUE_PARTIAL_INFORMATION *KeyValPartialInfo)
 

Variables

WDFLDR_DIAGS WdfLdrDiags
 
WDF_LDR_GLOBALS WdfLdrGlobals
 

Macro Definition Documentation

◆ __DBGPRINT

#define __DBGPRINT (   _x_)
Value:
do { \
DbgPrint("Wdfldr: %s - ", __FUNCTION__); \
} \
} while (0)
#define __FUNCTION__
Definition: types.h:116
UINT32 DiagFlags
Definition: wdfloader.h:91
#define __PrintUnfiltered(...)
Definition: wdfloader.h:20
#define DIAGFLAG_ENABLED
Definition: wdfloader.h:79
WDFLDR_DIAGS WdfLdrDiags
Definition: wdfldr.c:27

Definition at line 62 of file wdfloader.h.

◆ __PrintUnfiltered

#define __PrintUnfiltered (   ...)     DbgPrintEx(DPFLTR_DEFAULT_ID, DPFLTR_ERROR_LEVEL, __VA_ARGS__)

Definition at line 20 of file wdfloader.h.

◆ DIAGFLAG_ENABLED

#define DIAGFLAG_ENABLED   0x00000001

Definition at line 79 of file wdfloader.h.

◆ DIAGFLAG_LOG_ERRORS

#define DIAGFLAG_LOG_ERRORS   0x00000010

Definition at line 83 of file wdfloader.h.

◆ DIAGFLAG_LOG_WARNINGS

#define DIAGFLAG_LOG_WARNINGS   0x00000020

Definition at line 84 of file wdfloader.h.

◆ DIAGFLAG_TRACE_FUNCTION_ENTRY

#define DIAGFLAG_TRACE_FUNCTION_ENTRY   0x00000004

Definition at line 81 of file wdfloader.h.

◆ DIAGFLAG_TRACE_FUNCTION_EXIT

#define DIAGFLAG_TRACE_FUNCTION_EXIT   0x00000008

Definition at line 82 of file wdfloader.h.

◆ DIAGFLAG_VERBOSE_LOGGING

#define DIAGFLAG_VERBOSE_LOGGING   0x00000002

Definition at line 80 of file wdfloader.h.

◆ DPRINT

#define DPRINT (   _x_)
Value:
do { \
DbgPrint("WdfLdr: %s - ", __FUNCTION__); \
} \
} while (0)

Definition at line 23 of file wdfloader.h.

◆ DPRINT_ERROR

#define DPRINT_ERROR (   _x_)
Value:
do { \
DbgPrint("WdfLdr: ERROR: %s - ", __FUNCTION__); \
} \
} while (0)
#define DIAGFLAG_LOG_ERRORS
Definition: wdfloader.h:83

Definition at line 39 of file wdfloader.h.

◆ DPRINT_TRACE_ENTRY

DPRINT_TRACE_ENTRY ( )
Value:
do { \
DbgPrint("WdfLdr: ENTER: %s\n", __FUNCTION__); \
} \
} while (0)
#define DIAGFLAG_TRACE_FUNCTION_ENTRY
Definition: wdfloader.h:81

Definition at line 47 of file wdfloader.h.

Referenced by DereferenceVersion(), DllUnload(), ReferenceVersion(), WdfLdrQueryInterface(), WdfVersionBind(), WdfVersionBindClass(), and WdfVersionUnbind().

◆ DPRINT_TRACE_EXIT

DPRINT_TRACE_EXIT ( )
Value:
do { \
DbgPrint("WdfLdr: EXIT: %s\n", __FUNCTION__); \
} \
} while (0)
#define DIAGFLAG_TRACE_FUNCTION_EXIT
Definition: wdfloader.h:82

Definition at line 54 of file wdfloader.h.

Referenced by DereferenceVersion(), DllUnload(), ReferenceVersion(), WdfLdrQueryInterface(), WdfVersionBind(), WdfVersionBindClass(), and WdfVersionUnbind().

◆ DPRINT_VERBOSE

#define DPRINT_VERBOSE (   _x_)
Value:
do { \
DbgPrint("WdfLdr: %s - ", __FUNCTION__); \
} \
} while (0)
#define DIAGFLAG_VERBOSE_LOGGING
Definition: wdfloader.h:80

Definition at line 31 of file wdfloader.h.

◆ WDFLDR_TAG

#define WDFLDR_TAG   'LfdW'

Definition at line 17 of file wdfloader.h.

Typedef Documentation

◆ CLASS_CLIENT_MODULE

◆ CLASS_MODULE

◆ CLIENT_MODULE

◆ LIBRARY_MODULE

◆ PCLASS_CLIENT_MODULE

◆ PCLASS_MODULE

◆ PCLIENT_MODULE

◆ PLIBRARY_MODULE

◆ PWDF_CLASS_BIND

Definition at line 130 of file wdfloader.h.

◆ PWDF_CLASS_UNBIND

typedef VOID(NTAPI * PWDF_CLASS_UNBIND) (PWDF_BIND_INFO BindInfo, PWDF_COMPONENT_GLOBALS Globals, PWDF_CLASS_BIND_INFO ClassBindInfo)

Definition at line 137 of file wdfloader.h.

◆ PWDF_LDR_GLOBALS

◆ PWDF_LOADER_INTERFACE_CLASS_BIND

◆ PWDF_LOADER_INTERFACE_DIAGNOSTIC

◆ PWDFLDR_DIAGS

◆ WDF_LDR_GLOBALS

◆ WDF_LOADER_INTERFACE_CLASS_BIND

◆ WDF_LOADER_INTERFACE_DIAGNOSTIC

◆ WDFLDR_DIAGS

Function Documentation

◆ BuildServicePath()

NTSTATUS BuildServicePath ( _In_ PKEY_VALUE_PARTIAL_INFORMATION  KeyValueInformation,
_In_ PUNICODE_STRING  ServicePath 
)

Definition at line 338 of file registry.c.

341{
344 PWCHAR lastChar;
346 CONST WCHAR regPath[] = L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\%wZ";
347
348 if (KeyValueInformation->Type != REG_SZ &&
349 KeyValueInformation->Type != REG_EXPAND_SZ)
350 {
352 __DBGPRINT(("ERROR: BuildServicePath failed with status 0x%x\n", status));
353 return status;
354 }
355
356 if (KeyValueInformation->DataLength == 0 ||
357 KeyValueInformation->DataLength > 0xFFFF)
358 {
360 __DBGPRINT(("ERROR: BuildServicePath failed with status 0x%x\n", status));
361 return status;
362 }
363
364 name.Buffer = (PWCH)KeyValueInformation->Data;
365 name.Length = (USHORT)KeyValueInformation->DataLength;
366 name.MaximumLength = (USHORT)KeyValueInformation->DataLength;
367
368 lastChar = (PWCHAR)KeyValueInformation->Data + KeyValueInformation->DataLength / sizeof(WCHAR);
369 if (KeyValueInformation->DataLength >= sizeof(WCHAR) && *lastChar == UNICODE_NULL)
370 {
371 name.Length = (USHORT)KeyValueInformation->DataLength - sizeof(WCHAR);
372 }
373
374 buffer = ExAllocatePoolZero(PagedPool, name.Length + sizeof(regPath), WDFLDR_TAG);
375 if (buffer != NULL)
376 {
377 ServicePath->Length = 0;
378 ServicePath->MaximumLength = name.Length + sizeof(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\");//106;
381
382 if (!NT_SUCCESS(status))
383 {
385 ServicePath->Length = 0;
387 }
388 }
389 else
390 {
392 __DBGPRINT(("ERROR: ExAllocatePoolWithTag failed with Status 0x%x\n", status));
393 }
394
395 return status;
396}
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_OBJECT_TYPE_MISMATCH
Definition: d3dkmdt.h:46
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define L(x)
Definition: resources.c:13
#define PagedPool
Definition: env_spec_w32.h:308
GLuint buffer
Definition: glext.h:5915
#define REG_SZ
Definition: layer.c:22
_In_ PCUNICODE_STRING ServicePath
Definition: library.c:55
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
#define REG_EXPAND_SZ
Definition: nt_native.h:1497
WCHAR * PWCH
Definition: ntbasedef.h:422
#define UNICODE_NULL
NTSTRSAFEVAPI RtlUnicodeStringPrintf(_In_ PUNICODE_STRING DestinationString, _In_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:3241
#define CONST
Definition: pedump.c:81
unsigned short USHORT
Definition: pedump.c:61
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: name.c:39
Definition: ps.c:97
uint16_t * PWCHAR
Definition: typedefs.h:56
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define WDFLDR_TAG
Definition: wdfloader.h:17
#define __DBGPRINT(_x_)
Definition: wdfloader.h:62
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by GetClassServicePath(), and GetVersionServicePath().

◆ ClassAddReference()

VOID NTAPI ClassAddReference ( _In_ PCLASS_MODULE  ClassModule)

Definition at line 761 of file class.c.

763{
764 InterlockedIncrement(&ClassModule->ClassRefCount);
765 DPRINT_VERBOSE(("Added reference to class %wZ, RefCount=%d\n",
766 &ClassModule->Service, ClassModule->ClassRefCount));
767}
#define InterlockedIncrement
Definition: armddk.h:53
@ ClassModule
Definition: ipstats.h:82
#define DPRINT_VERBOSE(_x_)
Definition: wdfloader.h:31

Referenced by WdfRegisterClassLibrary().

◆ ClassClientCreate()

PCLASS_CLIENT_MODULE ClassClientCreate ( )

Definition at line 137 of file class.c.

138{
139 PCLASS_CLIENT_MODULE pNewClassClientModule;
140
141 pNewClassClientModule = ExAllocatePoolZero(NonPagedPool, sizeof(*pNewClassClientModule), WDFLDR_TAG);
142 if (pNewClassClientModule != NULL)
143 {
144 InitializeListHead(&pNewClassClientModule->ClassLinkage);
145 InitializeListHead(&pNewClassClientModule->ClientLinkage);
146 }
147
148 return pNewClassClientModule;
149}
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
LIST_ENTRY ClassLinkage
Definition: wdfloader.h:191
LIST_ENTRY ClientLinkage
Definition: wdfloader.h:190

Referenced by WdfVersionBindClass().

◆ ClassClose()

VOID ClassClose ( _In_ PCLASS_MODULE  ClassModule)

Definition at line 48 of file class.c.

50{
51 if (ClassModule->ClassFileObject != NULL)
52 {
53 ObDereferenceObject(ClassModule->ClassFileObject);
54 ClassModule->ClassFileObject = NULL;
55 }
56}
#define ObDereferenceObject
Definition: obfuncs.h:203

◆ ClassCreate()

PCLASS_MODULE ClassCreate ( _In_ PWDF_CLASS_LIBRARY_INFO  ClassLibInfo,
_In_ PLIBRARY_MODULE  LibModule,
_In_ PUNICODE_STRING  ServiceName 
)

Definition at line 75 of file class.c.

79{
80 PCLASS_MODULE pNewClassModule;
82
83 pNewClassModule = ExAllocatePoolZero(NonPagedPool, sizeof(*pNewClassModule), WDFLDR_TAG);
84 if (pNewClassModule == NULL)
85 return NULL;
86
87 if (ClassLibInfo != NULL)
88 {
89 pNewClassModule->ImplicitlyLoaded = TRUE;
90 pNewClassModule->ClassLibraryInfo = ClassLibInfo;
91 pNewClassModule->Version.Major = ClassLibInfo->Version.Major;
92 pNewClassModule->Version.Minor = ClassLibInfo->Version.Minor;
93 pNewClassModule->Version.Build = ClassLibInfo->Version.Build;
94 }
95
96 pNewClassModule->ClassRefCount = 1;
97 pNewClassModule->Library = LibModule;
99 InitializeListHead(&pNewClassModule->ClientsListHead);
100 InitializeListHead(&pNewClassModule->LibraryLinkage);
101
102 pNewClassModule->Service.Buffer = ExAllocatePoolZero(PagedPool, ServiceName->MaximumLength, WDFLDR_TAG);
103 if (pNewClassModule->Service.Buffer == NULL)
104 {
105 goto clean;
106 }
107 pNewClassModule->Service.MaximumLength = ServiceName->MaximumLength;
108 RtlCopyUnicodeString(&pNewClassModule->Service, ServiceName);
109 status = GetImageName(ServiceName, &pNewClassModule->ImageName);
110
111 if (!NT_SUCCESS(status))
112 {
113 goto clean;
114 }
115
116 pNewClassModule->IsBootDriver = ServiceCheckBootStart(&pNewClassModule->Service);
117 status = GetImageInfo(&pNewClassModule->ImageName,
118 &pNewClassModule->ImageAddress,
119 &pNewClassModule->ImageSize);
120
121 if (NT_SUCCESS(status))
122 {
123 return pNewClassModule;
124 }
125 else
126 {
127 __DBGPRINT(("GetImageBase failed\n"));
128 }
129
130clean:
131 ClassCleanupAndFree(pNewClassModule);
132
133 return NULL;
134}
static WCHAR ServiceName[]
Definition: browser.c:20
#define TRUE
Definition: types.h:120
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
_Must_inspect_result_ NTSTATUS GetImageName(_In_ PFX_DRIVER_GLOBALS DriverGlobals, _Out_ PUNICODE_STRING ImageName)
PLIBRARY_MODULE LibModule
Definition: library.c:59
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
VOID ClassCleanupAndFree(_In_ PCLASS_MODULE ClassModule)
Definition: class.c:59
NTSTATUS GetImageInfo(_In_ PCUNICODE_STRING ImageName, _Out_ PVOID *ImageBase, _Out_ PULONG ImageSize)
Definition: common.c:182
BOOLEAN ServiceCheckBootStart(_In_ PUNICODE_STRING Service)
Definition: registry.c:194
WDF_CLASS_VERSION Version
Definition: wdfloader.h:174
LONG ClassRefCount
Definition: wdfloader.h:177
BOOLEAN ImplicitlyLoaded
Definition: wdfloader.h:183
PLIBRARY_MODULE Library
Definition: wdfloader.h:179
LIST_ENTRY LibraryLinkage
Definition: wdfloader.h:171
UNICODE_STRING ImageName
Definition: wdfloader.h:182
LIST_ENTRY ClientsListHead
Definition: wdfloader.h:170
BOOLEAN IsBootDriver
Definition: wdfloader.h:184
UNICODE_STRING Service
Definition: wdfloader.h:172
PVOID ImageAddress
Definition: wdfloader.h:180
PWDF_CLASS_LIBRARY_INFO ClassLibraryInfo
Definition: wdfloader.h:173
ERESOURCE ClientsListLock
Definition: wdfloader.h:169
ULONG ImageSize
Definition: wdfloader.h:181

◆ ClassLinkInClient()

NTSTATUS ClassLinkInClient ( _In_ PCLASS_MODULE  ClassModule,
_In_ PWDF_CLASS_BIND_INFO  ClassBindInfo,
_In_ PWDF_BIND_INFO  BindInfo,
_Out_ PCLASS_CLIENT_MODULE  ClassClientModule 
)

Definition at line 170 of file class.c.

175{
176 PCLIENT_MODULE pClienInfo;
178
179 ClassClientModule->Class = ClassModule;
180 ClassClientModule->ClientClassBindInfo = ClassBindInfo;
182 pClienInfo = LibraryFindClientLocked(ClassModule->Library, BindInfo);
183
184 if (pClienInfo != NULL)
185 {
186 ClassClientModule->Client = pClienInfo;
187 InsertTailList(&pClienInfo->ClassListHead, &ClassClientModule->ClassLinkage);
188 }
189
191
192 if (pClienInfo != NULL)
193 {
194 ClassAcquireClientLock(&ClassModule->ClientsListLock);
195 InsertTailList(&ClassModule->ClientsListHead, &ClassClientModule->ClientLinkage);
196 ClassReleaseClientLock(&ClassModule->ClientsListLock);
198 }
199 else
200 {
202 __DBGPRINT(("ERROR: Could not locate client from Info %p, status 0x%x\n", BindInfo, status));
203 }
204
205 return status;
206}
#define InsertTailList(ListHead, Entry)
VOID LibraryReleaseClientLock(_In_ PLIBRARY_MODULE LibModule)
Definition: library.c:373
BOOLEAN LibraryAcquireClientLock(_In_ PLIBRARY_MODULE LibModule)
Definition: library.c:365
PCLIENT_MODULE LibraryFindClientLocked(_In_ PLIBRARY_MODULE LibModule, _In_ PWDF_BIND_INFO BindInfo)
Definition: class.c:152
VOID ClassReleaseClientLock(_In_ PERESOURCE Resource)
Definition: class.c:21
VOID ClassAcquireClientLock(_In_ PERESOURCE Resource)
Definition: class.c:13
#define STATUS_SUCCESS
Definition: shellext.h:65
LIST_ENTRY ClassListHead
Definition: wdfloader.h:164
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
WDF_BIND_INFO BindInfo

Referenced by WdfVersionBindClass().

◆ ClassOpen()

NTSTATUS ClassOpen ( _Inout_ PCLASS_MODULE  ClassModule,
_In_ PUNICODE_STRING  ObjectName 
)

Definition at line 29 of file class.c.

32{
35
36 if (!ObjectName)
37 return STATUS_SUCCESS;
38
40
41 if (NT_SUCCESS(status))
42 ClassModule->ClassDriverObject = deviceObject->DriverObject;
43
44 return status;
45}
MxDeviceObject deviceObject
#define FILE_READ_DATA
Definition: nt_native.h:628
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1435
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:64

Referenced by WdfRegisterClassLibrary().

◆ ClassReleaseClientReference()

VOID ClassReleaseClientReference ( _In_ PCLASS_MODULE  ClassModule)

Definition at line 770 of file class.c.

772{
773 int refs;
774
775 __DBGPRINT(("Dereference module %wZ\n", &ClassModule->Service));
776 refs = InterlockedDecrement(&ClassModule->ClientRefCount);
777
778 if (refs <= 0)
779 {
781 }
782 else
783 {
784 __DBGPRINT(("Dereference module %wZ still has %d references\n",
785 &ClassModule->Service, refs));
786 }
787}
#define InterlockedDecrement
Definition: armddk.h:52
DRIVER_UNLOAD ClassUnload
Definition: classp.h:1356

Referenced by DereferenceClassVersion().

◆ ClassRemoveFromLibraryList()

VOID ClassRemoveFromLibraryList ( _In_ PCLASS_MODULE  ClassModule)

Definition at line 692 of file class.c.

694{
695 PLIST_ENTRY libLinkEntry;
696 BOOLEAN removed;
697
699 libLinkEntry = &ClassModule->LibraryLinkage;
700
701 if (IsListEmpty(libLinkEntry))
702 {
703 removed = FALSE;
704 }
705 else
706 {
707 RemoveEntryList(libLinkEntry);
708 InitializeListHead(libLinkEntry);
709 removed = TRUE;
710 }
712
713 if (removed)
714 {
715 if (InterlockedExchangeAdd(&ClassModule->ClassRefCount, -1) == 1)
717 }
718}
unsigned char BOOLEAN
#define FALSE
Definition: types.h:117
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define InterlockedExchangeAdd
Definition: interlocked.h:196
VOID FxLdrAcquireLoadedModuleLock(VOID)
Definition: common.c:13
VOID FxLdrReleaseLoadedModuleLock(VOID)
Definition: common.c:20
Definition: typedefs.h:120

Referenced by ClassUnload(), and WdfRegisterClassLibrary().

◆ DereferenceClassVersion()

VOID DereferenceClassVersion ( _In_ PWDF_CLASS_BIND_INFO  ClassBindInfo,
_In_ PWDF_BIND_INFO  BindInfo,
_In_ PWDF_COMPONENT_GLOBALS  Globals 
)

Definition at line 790 of file class.c.

794{
795 PCLASS_MODULE pClassModule;
796
798 pClassModule = ClassBindInfo->ClassModule;
799
800 if (pClassModule)
801 {
802 if (pClassModule->ClassLibraryInfo &&
804 {
805 pClassModule->ClassLibraryInfo->ClassLibraryUnbindClient(ClassBindInfo, &Globals);
806 }
807 ClassUnlinkClient(pClassModule, ClassBindInfo);
808 ClassReleaseClientReference(pClassModule);
809 ClassBindInfo->ClassModule = NULL;
810 }
811}
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
VOID ClassReleaseClientReference(_In_ PCLASS_MODULE ClassModule)
Definition: class.c:770
VOID ClassUnlinkClient(_In_ PCLASS_MODULE ClassModule, _In_ PWDF_CLASS_BIND_INFO ClassBindInfo)
Definition: class.c:721
PFN_CLASS_LIBRARY_UNBIND_CLIENT ClassLibraryUnbindClient
Definition: wdfldr.h:113

Referenced by WdfVersionBindClass(), and WdfVersionUnbindClass().

◆ DereferenceVersion()

NTSTATUS NTAPI DereferenceVersion ( _In_ PWDF_BIND_INFO  Info,
_In_opt_ PWDF_COMPONENT_GLOBALS  Globals 
)

Dereference a WDF library version.

Parameters
InfoBinding information
GlobalsComponent globals to clean up
Returns
NTSTATUS Success or failure status

Definition at line 630 of file wdfldr.c.

633{
635 NTSTATUS unregisterStatus = STATUS_SUCCESS;
636 PLIBRARY_MODULE pLibModule;
637
639
640 if (!Info || !Info->Module)
641 {
642 DPRINT_ERROR(("Invalid Info or Module is NULL\n"));
644 }
645
646 pLibModule = Info->Module;
647
648 // Unregister the client if we have globals
649 if (Globals && pLibModule->LibraryInfo &&
651 {
652 unregisterStatus = pLibModule->LibraryInfo->LibraryUnregisterClient(Info, Globals);
653 if (!NT_SUCCESS(unregisterStatus))
654 {
655 DPRINT_ERROR(("LibraryUnregisterClient failed with status 0x%x\n", unregisterStatus));
657 {
658 DPRINT_VERBOSE(("LibraryUnregisterClient failed\n"));
659 }
660 }
661 }
662
663 // Unlink the client
664 if (!LibraryUnlinkClient(pLibModule, Info))
665 {
666 DPRINT_ERROR(("LibraryUnlinkClient failed\n"));
668 {
669 DPRINT_VERBOSE(("LibraryUnlinkClient failed\n"));
670 }
671 }
672
673 // Release the reference
674 LibraryReleaseReference(pLibModule);
675
676 // Clear the module reference
677 Info->Module = NULL;
678
680 return NT_SUCCESS(unregisterStatus) ? status : unregisterStatus;
681}
VOID NTAPI LibraryReleaseReference(_In_ PLIBRARY_MODULE LibModule)
Release a reference to a library module.
Definition: library.c:280
BOOLEAN LibraryUnlinkClient(_In_ PLIBRARY_MODULE LibModule, _In_ PWDF_BIND_INFO BindInfo)
Definition: library.c:475
PWDF_LIBRARY_INFO LibraryInfo
Definition: wdfloader.h:119
PFNLIBRARYUNREGISTERCLIENT LibraryUnregisterClient
Definition: fxldr.h:144
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
WDFLDR_DIAGS WdfLdrDiags
Definition: wdfldr.c:27
#define DPRINT_TRACE_ENTRY()
Definition: wdfloader.h:47
#define DPRINT_TRACE_EXIT()
Definition: wdfloader.h:54
#define DPRINT_ERROR(_x_)
Definition: wdfloader.h:39

◆ FindClassByServiceNameLocked()

PCLASS_MODULE FindClassByServiceNameLocked ( _In_ PUNICODE_STRING  Path,
_Out_ PLIBRARY_MODULE LibModule 
)

Definition at line 585 of file class.c.

588{
589 PLIST_ENTRY libEntry;
590 PLIBRARY_MODULE pLibModule;
591 PLIST_ENTRY classEntry;
592 PCLASS_MODULE pClassModule;
593 UNICODE_STRING needleName;
594
595 GetNameFromPath(ServicePath, &needleName);
596
598 {
599 goto end;
600 }
601
602 for (libEntry = WdfLdrGlobals.LoadedModulesList.Flink;
603 libEntry != &WdfLdrGlobals.LoadedModulesList;
604 libEntry = libEntry->Flink)
605 {
606 pLibModule = CONTAINING_RECORD(libEntry, LIBRARY_MODULE, LibraryListEntry);
607
608 for (classEntry = pLibModule->ClassListHead.Flink;
609 classEntry != &pLibModule->ClassListHead;
610 classEntry = classEntry->Flink)
611 {
612 UNICODE_STRING haystackName;
613 pClassModule = CONTAINING_RECORD(classEntry, CLASS_MODULE, LibraryLinkage);
614 GetNameFromPath(&pClassModule->Service, &haystackName);
615
616 if (RtlEqualUnicodeString(&needleName, &haystackName, TRUE))
617 {
618 if (LibModule != NULL)
619 {
620 *LibModule = pLibModule;
621 }
622
623 return pClassModule;
624 }
625 }
626 }
627
628end:
629 if (LibModule != NULL)
630 *LibModule = NULL;
631
632 return NULL;
633}
VOID GetNameFromPath(_In_ PCUNICODE_STRING Path, _Out_ PUNICODE_STRING Name)
Definition: fxtelemetry.cpp:54
GLuint GLuint end
Definition: gl.h:1545
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
LIST_ENTRY ClassListHead
Definition: wdfloader.h:125
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY LoadedModulesList
Definition: wdfloader.h:73
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
WDF_LDR_GLOBALS WdfLdrGlobals
Definition: wdfldr.c:28

Referenced by ReferenceClassVersion(), and WdfRegisterClassLibrary().

◆ FindLibraryByServicePathLocked()

PLIBRARY_MODULE FindLibraryByServicePathLocked ( _In_ PCUNICODE_STRING  ServicePath)

◆ FindModuleByClientService()

NTSTATUS NTAPI FindModuleByClientService ( _In_ PUNICODE_STRING  RegistryPath,
_Out_ PLIBRARY_MODULE Library 
)

Referenced by WdfRegisterClassLibrary().

◆ FxLdrAcquireLoadedModuleLock()

VOID FxLdrAcquireLoadedModuleLock ( VOID  )

◆ FxLdrQueryData()

NTSTATUS FxLdrQueryData ( _In_ HANDLE  KeyHandle,
_In_ PUNICODE_STRING  ValueName,
_In_ ULONG  Tag,
_Out_ PKEY_VALUE_PARTIAL_INFORMATION KeyValPartialInfo 
)

Definition at line 267 of file registry.c.

272{
275 ULONG resultLength;
276
277 *KeyValPartialInfo = NULL;
278 for (;;)
279 {
280 status = ZwQueryValueKey(KeyHandle, ValueName, KeyValuePartialInformation, NULL, 0, &resultLength);
282 {
283 if (!NT_SUCCESS(status))
284 {
285 __DBGPRINT(("ERROR: ZwQueryValueKey failed with status 0x%x\n", status));
286 }
287
288 return status;
289 }
290
291 status = RtlULongAdd(resultLength, 0xCu, &resultLength);
292 if (!NT_SUCCESS(status))
293 {
294 __DBGPRINT(("ERROR: Computing length of data under %wZ failed with status 0x%x\n", ValueName, status));
295
296 return status;
297 }
298
299 pKeyInfo = ExAllocatePoolWithTag(PagedPool, resultLength, Tag);
300
301 if (pKeyInfo == NULL)
302 {
303 break;
304 }
305
306 RtlZeroMemory(pKeyInfo, resultLength);
307 status = ZwQueryValueKey(
308 KeyHandle,
309 ValueName,
311 pKeyInfo,
312 resultLength,
313 &resultLength);
314
315 if (NT_SUCCESS(status))
316 {
317 *KeyValPartialInfo = pKeyInfo;
318 return status;
319 }
320
321 ExFreePoolWithTag(pKeyInfo, WDFLDR_TAG);
322
324 {
325 __DBGPRINT(("ERROR: ZwQueryValueKey (%wZ) failed with Status 0x%x\n", ValueName, status));
326
327 return status;
328 }
329 }
330
331 __DBGPRINT(("ERROR: ExAllocatePoolWithTag failed with Status 0x%x\n", STATUS_INSUFFICIENT_RESOURCES));
332
334}
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
@ KeyValuePartialInformation
Definition: nt_native.h:1185
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4071
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243

Referenced by GetClassServicePath(), GetImageName(), and GetVersionServicePath().

◆ FxLdrQueryUlong()

NTSTATUS FxLdrQueryUlong ( _In_ HANDLE  KeyHandle,
_In_ PUNICODE_STRING  ValueName,
_Out_ PULONG  Value 
)

Definition at line 231 of file registry.c.

235{
237 ULONG resultLength;
239
240 keyValue.DataLength = 0;
241 keyValue.TitleIndex = 0;
242 keyValue.Type = 0;
243 keyValue.Data[0] = 0;
244 status = ZwQueryValueKey(KeyHandle, ValueName, KeyValuePartialInformation, &keyValue, sizeof(keyValue), &resultLength);
245 if (NT_SUCCESS(status))
246 {
247 if (keyValue.Type != REG_DWORD || keyValue.DataLength != sizeof(*Value))
248 {
250 }
251 else
252 {
253 *Value = keyValue.Data[0];
255 }
256 }
257 else
258 {
259 __DBGPRINT(("ERROR: ZwQueryValueKey failed with Status 0x%x\n", status));
260 }
261
262 return status;
263}
#define STATUS_INVALID_BUFFER_SIZE
Definition: ntstatus.h:772
#define REG_DWORD
Definition: sdbapi.c:615
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by ServiceCheckBootStart(), and WdfLdrDiagnosticsValueByNameAsULONG().

◆ FxLdrReleaseLoadedModuleLock()

VOID FxLdrReleaseLoadedModuleLock ( VOID  )

◆ GetImageInfo()

NTSTATUS GetImageInfo ( _In_ PCUNICODE_STRING  ImageName,
_Out_ PVOID ImageBase,
_Out_ PULONG  ImageSize 
)

Definition at line 182 of file common.c.

186{
187 ANSI_STRING ansiImageName;
189
191
192 if (!NT_SUCCESS(status))
193 {
194 __DBGPRINT(("ERROR: RtlUnicodeStringToAnsiString failed with Status 0x%x\n", status));
195 return status;
196 }
197
198 PAUX_MODULE_EXTENDED_INFO modulesBuffer;
199 ULONG modulesSize;
200 for (;;)
201 {
204 NULL);
205 if (!NT_SUCCESS(status))
206 {
207 goto clean;
208 }
209
210 modulesBuffer = ExAllocatePoolZero(PagedPool, modulesSize, WDFLDR_TAG);
211 if (modulesBuffer == NULL)
212 {
214 __DBGPRINT(("ERROR: ExAllocatePoolWithTag failed\n"));
215
216 goto clean;
217 }
218
221 modulesBuffer);
223 {
224 ExFreePoolWithTag(modulesBuffer, WDFLDR_TAG);
225 continue;
226 }
227 else
228 {
229 break;
230 }
231 }
232
233 if (NT_SUCCESS(status))
234 {
235 for (SIZE_T i = 0; i < modulesSize / sizeof(AUX_MODULE_EXTENDED_INFO); i++)
236 {
237 // Compare our image name to names returned by AuxKlib
238 if (modulesBuffer[i].FileNameOffset < AUX_KLIB_MODULE_PATH_LEN &&
239 _strnicmp(&modulesBuffer[i].FullPathName[modulesBuffer[i].FileNameOffset],
240 ansiImageName.Buffer, ansiImageName.Length) == 0)
241 {
242 *ImageBase = modulesBuffer[i].BasicInfo.ImageBase;
243 *ImageSize = modulesBuffer[i].ImageSize;
244 break;
245 }
246 }
247 }
248 else
249 {
250 __DBGPRINT(("ERROR: AuxKlibQueryModuleInformation failed with Status 0x%x\n", status));
251 }
252
253 ExFreePoolWithTag(modulesBuffer, WDFLDR_TAG);
254
255clean:
256 RtlFreeAnsiString(&ansiImageName);
257 return status;
258}
NTSTATUS NTAPI AuxKlibQueryModuleInformation(_In_ PULONG InformationLength, _In_ ULONG SizePerModule, _Inout_ PAUX_MODULE_EXTENDED_INFO ModuleInfo)
Definition: aux_klib.c:53
struct _AUX_MODULE_EXTENDED_INFO AUX_MODULE_EXTENDED_INFO
#define AUX_KLIB_MODULE_PATH_LEN
Definition: aux_klib.h:31
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const char * ImageName
Definition: image.c:34
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlFreeAnsiString(PANSI_STRING AnsiString)
AUX_MODULE_BASIC_INFO BasicInfo
Definition: aux_klib.h:38
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by ClassCreate(), DECLARE_INTERFACE_(), LibraryLinkInClient(), and WdfRegisterLibrary().

◆ GetImageName()

NTSTATUS GetImageName ( _In_ PCUNICODE_STRING  ServicePath,
_In_ PUNICODE_STRING  ImageName 
)

◆ GetNameFromPath()

VOID GetNameFromPath ( _In_ PCUNICODE_STRING  Path,
_Out_ PUNICODE_STRING  Name 
)

Definition at line 54 of file fxtelemetry.cpp.

78{
79 BOOLEAN foundSlash;
80
81 ASSERT(Path != NULL);
82
83 //
84 // Ideally a check of Path->Length == 0 would be sufficient except that
85 // PreFAST thinks that Length can be odd, so it thinks Length == 1 is possible.
86 // Comparing Length < sizeof(WCHAR) satisfies PreFAST and keeps the logic
87 // at runtime correct.
88 //
89 if (Path->Length < sizeof(WCHAR)) {
91 return;
92 }
93
94 //
95 // Initialize Name to point to the last WCHAR of the buffer and we will work
96 // our way backwards to the beginning of the string or a '\'
97 //
98
99 Name->Buffer = WDF_PTR_ADD_OFFSET_TYPE(Path->Buffer,
100 Path->Length - sizeof(WCHAR),
101 PWCH);
102 Name->Length = sizeof(WCHAR);
103 foundSlash = FALSE;
104
105 while (Name->Buffer >= Path->Buffer) {
106 if (*Name->Buffer == L'\\') {
107 //
108 // Skip the \ in the buffer moving forward a character and adjusting
109 // the length
110 //
111 foundSlash = TRUE;
112 Name->Buffer++;
113 Name->Length -= sizeof(WCHAR);
114 break;
115 }
116
117 //
118 // Move backwards in the string
119 //
120 Name->Buffer--;
121 Name->Length += sizeof(WCHAR);
122 }
123
124 if (foundSlash && Name->Length == 0) {
125 //
126 // Handle the case where a slash was found and it is the only character
127 //
128 Name->Buffer = NULL;
129 }
130 else if (foundSlash == FALSE) {
131 //
132 // Handle the case where no slash was found. In this case, Name->Buffer
133 // points to one WCHAR before the beginning of the string.
134 //
135 Name->Length -= sizeof(WCHAR);
136 Name->Buffer++;
137 }
138
139 //
140 // Need to set MaximumLength to the same value as Length so that the struct
141 // format is valid.
142 //
143 Name->MaximumLength = Name->Length;
144}
PRTL_UNICODE_STRING_BUFFER Path
LPWSTR Name
Definition: desk.c:124
#define ASSERT(a)
Definition: mode.c:44
#define WDF_PTR_ADD_OFFSET_TYPE(_ptr, _offset, _type)
Definition: wdfcore.h:141

Referenced by GetImageName().

◆ GetVersionServicePath()

NTSTATUS GetVersionServicePath ( _In_ PWDF_BIND_INFO  BindInfo,
_Out_ PUNICODE_STRING  ServicePath 
)

Get service path from bind info and registry.

Parameters
BindInfoBind information
ServicePathService path in registry
Returns
STATUS_SUCCESS on success, error code otherwise

Definition at line 141 of file registry.c.

144{
147 HANDLE handleRegKey = NULL;
149
150 status = GetVersionRegistryHandle(BindInfo, &handleRegKey);
151
152 if (!NT_SUCCESS(status))
153 {
154 __DBGPRINT(("ERROR: GetVersionRegistryHandle failed with Status 0x%x\n", status));
155 }
156 else
157 {
158 // get service name
159 status = FxLdrQueryData(handleRegKey, &ValueName, WDFLDR_TAG, &pKeyVal);
160
161 if (!NT_SUCCESS(status))
162 {
163 __DBGPRINT(("ERROR: QueryData failed with status 0x%x\n", status));
164 }
165 else
166 {
168 }
169 }
170
171 if (!NT_SUCCESS(status))
172 {
174
175 if (!NT_SUCCESS(status))
176 {
177 __DBGPRINT(("ERROR: GetVersionServicePath failed with Status 0x%x\n", status));
178 }
179 }
180 else
181 {
182 __DBGPRINT(("(%wZ)\n", ServicePath));
183 }
184
185 if (handleRegKey != NULL)
186 ZwClose(handleRegKey);
187 if (pKeyVal != NULL)
189
190 return status;
191}
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
NTSTATUS FxLdrQueryData(_In_ HANDLE KeyHandle, _In_ PUNICODE_STRING ValueName, _In_ ULONG Tag, _Out_ PKEY_VALUE_PARTIAL_INFORMATION *KeyValPartialInfo)
Definition: registry.c:267
NTSTATUS NTAPI GetDefaultServiceName(_In_ PWDF_BIND_INFO BindInfo, _Out_ PUNICODE_STRING RegistryPath)
Create default service path from bind info.
Definition: registry.c:88
NTSTATUS BuildServicePath(_In_ PKEY_VALUE_PARTIAL_INFORMATION KeyValueInformation, _In_ PUNICODE_STRING ServicePath)
Definition: registry.c:338
NTSTATUS NTAPI GetVersionRegistryHandle(_In_ PWDF_BIND_INFO BindInfo, _Out_ PHANDLE HandleRegKey)
Open framework version registry key.
Definition: registry.c:21
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by ReferenceVersion().

◆ LibraryAcquireClientLock()

BOOLEAN LibraryAcquireClientLock ( _In_ PLIBRARY_MODULE  LibModule)

◆ LibraryAddToClassListLocked()

PLIST_ENTRY LibraryAddToClassListLocked ( _In_ PLIBRARY_MODULE  LibModule,
_In_ PCLASS_MODULE  ClassModule 
)

Definition at line 673 of file class.c.

676{
678
679 if (!LibModule || !ClassModule)
680 return NULL;
681
682 result = &ClassModule->LibraryLinkage;
684
685 DPRINT_VERBOSE(("Added class %wZ to library %wZ\n",
686 &ClassModule->Service, &LibModule->ServicePath));
687
688 return result;
689}
#define InsertHeadList(ListHead, Entry)
GLuint64EXT * result
Definition: glext.h:11304
UNICODE_STRING ServicePath
Definition: wdfloader.h:113

Referenced by ReferenceClassVersion(), and WdfRegisterClassLibrary().

◆ LibraryClose()

VOID LibraryClose ( _Inout_ PLIBRARY_MODULE  LibModule)

Dereferences KMDF library's device object.

Definition at line 195 of file library.c.

197{
199 {
202 }
203}
PFILE_OBJECT LibraryFileObject
Definition: wdfloader.h:117

Referenced by DllUnload(), LibraryDereference(), and LibraryUnload().

◆ LibraryCreate()

NTSTATUS LibraryCreate ( _In_opt_ PWDF_LIBRARY_INFO  LibraryInfo,
_In_ PCUNICODE_STRING  ServicePath,
_Out_ PLIBRARY_MODULE OutLibraryModule 
)

◆ LibraryDereference()

VOID LibraryDereference ( _In_ PLIBRARY_MODULE  LibModule)

Definition at line 300 of file library.c.

302{
303 BOOLEAN cleanupNeeded = FALSE;
304
307 {
309 {
311 InitializeListHead(&LibModule->LibraryListEntry); // Indicate removal process
312 cleanupNeeded = TRUE;
313 }
314 }
316
317 if (cleanupNeeded)
318 {
321 else
324 }
325}
VOID LibraryClose(_Inout_ PLIBRARY_MODULE LibModule)
Dereferences KMDF library's device object.
Definition: library.c:195
VOID LibraryFree(_In_ PLIBRARY_MODULE LibModule)
Definition: library.c:13
LONG LibraryRefCount
Definition: wdfloader.h:108
LIST_ENTRY LibraryListEntry
Definition: wdfloader.h:109
VOID LibraryUnload()

Referenced by LibraryFindOrLoad(), WdfRegisterLibrary(), WdfVersionBind(), and WdfVersionUnbind().

◆ LibraryFindOrLoad()

NTSTATUS LibraryFindOrLoad ( _In_ PCUNICODE_STRING  ServicePath,
_Out_ PLIBRARY_MODULE LibModule 
)

Definition at line 206 of file library.c.

209{
210 BOOLEAN loadNeeded = FALSE;
212
215
216 if (pLibModule == NULL)
217 {
218 // Client driver is loaded before the library, we need to create it here
219 status = LibraryCreate(NULL, ServicePath, &pLibModule);
220 if (NT_SUCCESS(status))
221 {
222 loadNeeded = TRUE;
223 }
224 }
225 else
226 {
228 }
229
230 // Reference the library
231 if (pLibModule)
233
235
236 // We've just created a library, time to load the actual driver
237 if (loadNeeded)
238 {
239 // This will call WdfRegisterLibrary (as part of KMDF's DriverEntry)
240 status = ZwLoadDriver((PUNICODE_STRING)ServicePath);
241 if (NT_SUCCESS(status) && !pLibModule->LibraryInfo)
242 {
243 __DBGPRINT(("ZwLoadDriver(%wZ) succeeded but Libray information was returned\n",
244 ServicePath));
246 }
247 else if (!NT_SUCCESS(status))
248 {
249 __DBGPRINT(("ZwLoadDriver(%wZ) failed with status %x\n", ServicePath, status));
250 }
251
252 if (!NT_SUCCESS(status))
253 {
254 LibraryDereference(pLibModule);
255 // Cleanup created library
256 ASSERT(pLibModule->LibraryInfo == NULL);
257 LibraryDereference(pLibModule);
258 pLibModule = NULL;
259 }
260 }
261
262 *LibModule = pLibModule;
263 return status;
264}
VOID LibraryDereference(_In_ PLIBRARY_MODULE LibModule)
Definition: library.c:300
status
Definition: library.c:86
#define STATUS_NOT_SAFE_MODE_DRIVER
Definition: ntstatus.h:1034
NTSTATUS LibraryCreate(_In_opt_ PWDF_LIBRARY_INFO LibraryInfo, _In_ PCUNICODE_STRING ServicePath, _Out_ PLIBRARY_MODULE *OutLibraryModule)
PLIBRARY_MODULE FindLibraryByServicePathLocked(_In_ PCUNICODE_STRING ServicePath)

Referenced by ReferenceVersion().

◆ LibraryFree()

VOID LibraryFree ( _In_ PLIBRARY_MODULE  LibModule)

Definition at line 13 of file library.c.

15{
17
18 if (!LibModule)
19 {
20 DPRINT_ERROR(("LibModule is NULL\n"));
21 return;
22 }
23
25 {
28 }
29
31 {
34 }
35
39
41}
#define ExDeleteResourceLite(res)
Definition: env_spec_w32.h:647
DPRINT_TRACE_ENTRY()
DPRINT_TRACE_EXIT()
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
UNICODE_STRING ImageName
Definition: wdfloader.h:114

Referenced by DllUnload(), LibraryDereference(), and LibraryUnload().

◆ LibraryLinkInClient()

NTSTATUS LibraryLinkInClient ( _In_ PLIBRARY_MODULE  LibModule,
_In_ PUNICODE_STRING  ServicePath,
_In_ PWDF_BIND_INFO  BindInfo,
_In_ PVOID  Context,
_Out_ PCLIENT_MODULE OutClientModule 
)

Create client module and add it to library client list.

Parameters
LibModuleLibrary that client is being added to
ServicePathClient driver service registry path
BindInfoBind information
ContextClient context
OutClientModuleCreated client module added to library clients list
Returns
STATUS_SUCCESS on success, error code otherwise

Definition at line 404 of file library.c.

410{
411 PCLIENT_MODULE clientModule;
413
414 clientModule = ExAllocatePoolWithTag(NonPagedPool, sizeof(*clientModule), WDFLDR_TAG);
415
416 if (clientModule == NULL)
417 {
418 __DBGPRINT(("ERROR: ExAllocatePoolWithTag failed\n"));
419 __DBGPRINT(("ERROR: Client module NOT linked\n"));
420
422 }
423
424 *clientModule = (CLIENT_MODULE){
425 .Context = Context,
426 .Info = BindInfo
427 };
428
429 InitializeListHead(&clientModule->ClassListHead);
430 InitializeListHead(&clientModule->LibListEntry);
431
432 status = GetImageName(ServicePath, &clientModule->ImageName);
433 if (NT_SUCCESS(status))
434 {
435 __DBGPRINT(("Client Image Name: %wZ\n", &clientModule->ImageName));
436
437 status = GetImageInfo(&clientModule->ImageName,
438 &clientModule->ImageAddr,
439 &clientModule->ImageSize);
440 if (!NT_SUCCESS(status))
441 {
442 __DBGPRINT(("GetImageInfo failed with status 0x%x\n", status));
443 __DBGPRINT(("ERROR: Client module NOT linked\n"));
444 ClientFree(clientModule);
445
446 return status;
447 }
448 }
449
454
455 *OutClientModule = clientModule;
456 return STATUS_SUCCESS;
457}
static VOID ClientFree(_In_ PCLIENT_MODULE ClientModule)
Definition: library.c:382
PVOID ImageAddr
Definition: wdfloader.h:160
LIST_ENTRY LibListEntry
Definition: wdfloader.h:157
UNICODE_STRING ImageName
Definition: wdfloader.h:162
ULONG ImageSize
Definition: wdfloader.h:161
LONG ClientRefCount
Definition: wdfloader.h:110
LIST_ENTRY ClientsListHead
Definition: wdfloader.h:120
struct _CLIENT_MODULE CLIENT_MODULE

Referenced by WdfVersionBind().

◆ LibraryOpen()

NTSTATUS LibraryOpen ( _Inout_ PLIBRARY_MODULE  LibModule,
_In_ PCUNICODE_STRING  ObjectName 
)

Opens KMDF library's driver object by its name and fills some library structure data.

Parameters
LibModuleLibrary module to update
ObjectNameDevice object name
Returns
STATUS_SUCCESS on success, error code otherwise

Definition at line 167 of file library.c.

170{
172
173 if (ObjectName == NULL)
174 {
175 return STATUS_SUCCESS;
176 }
177
181 &deviceObject);
182
183 if (NT_SUCCESS(status))
184 {
186 }
187
188 return status;
189}
PDRIVER_OBJECT LibraryDriverObject
Definition: wdfloader.h:118

Referenced by WdfRegisterLibrary().

◆ LibraryReference()

VOID LibraryReference ( _In_ PLIBRARY_MODULE  LibModule)

◆ LibraryReleaseClientLock()

VOID LibraryReleaseClientLock ( _In_ PLIBRARY_MODULE  LibModule)

◆ LibraryReleaseReference()

VOID NTAPI LibraryReleaseReference ( _In_ PLIBRARY_MODULE  LibModule)

Release a reference to a library module.

Definition at line 280 of file library.c.

282{
283 LONG refCount;
285
287 DPRINT_VERBOSE(("Released reference to library %wZ, RefCount=%d\n",
288 &LibModule->ServicePath, refCount));
289
290 if (refCount <= 0)
291 {
292 DPRINT(("Library %wZ reference count reached zero, unloading\n", &LibModule->ServicePath));
294 }
295
297}
long LONG
Definition: pedump.c:60
#define DPRINT
Definition: sndvol32.h:73

Referenced by DereferenceVersion().

◆ LibraryUnlinkClient()

BOOLEAN LibraryUnlinkClient ( _In_ PLIBRARY_MODULE  LibModule,
_In_ PWDF_BIND_INFO  BindInfo 
)

Definition at line 475 of file library.c.

478{
480
481 // search in library clients entry to remove
482 BOOLEAN found = FALSE;
483 PCLIENT_MODULE clientModule;
486 entry = entry->Flink)
487 {
488 clientModule = CONTAINING_RECORD(entry, CLIENT_MODULE, LibListEntry);
489 if (clientModule->Info == BindInfo)
490 {
491 found = TRUE;
492 break;
493 }
494 }
495
496 if (found)
497 {
498 RemoveEntryList(&clientModule->LibListEntry);
500 }
501
503
504 if (found)
505 {
506 InitializeListHead(&clientModule->LibListEntry);
507 ClientFree(clientModule);
508 return TRUE;
509 }
510
511 __DBGPRINT(("ERROR: Client module %p, bind %p NOT found\n", LibModule, BindInfo));
512 return FALSE;
513}
uint32_t entry
Definition: isohybrid.c:63
static VOID LibraryClientDereference(_In_ PLIBRARY_MODULE LibModule)
Definition: library.c:461
PWDF_BIND_INFO Info
Definition: wdfloader.h:163

Referenced by DereferenceVersion(), and WdfVersionUnbind().

◆ LibraryUnload()

VOID LibraryUnload ( _In_ PLIBRARY_MODULE  LibModule)

Definition at line 328 of file library.c.

330{
332
333 /* This occurs because of how WDF ClassDrivers behave. */
335 return;
336
338
340 if (!NT_SUCCESS(status))
341 {
342 __DBGPRINT(("LibraryDecommission failed %X\n", status));
343 }
344
346
347 __DBGPRINT(("Unloading library %wZ\n", &LibModule->ServicePath));
348
350
352 if (!NT_SUCCESS(status))
353 {
354 __DBGPRINT(("unload of %wZ returned 0x%x (this may not be a true error if someone else attempted to stop"
355 " the service first)\n",
357 status));
358 }
359
360 // Free the library module directly - caller handles the cleanup sequence
362}
NTSYSAPI NTSTATUS NTAPI ZwUnloadDriver(_In_ PUNICODE_STRING DriverServiceName)
BOOLEAN IsBootDriver
Definition: wdfloader.h:111
PFNLIBRARYDECOMMISSION LibraryDecommission
Definition: fxldr.h:142

◆ LibraryUnloadClasses()

PLIST_ENTRY LibraryUnloadClasses ( _In_ PLIBRARY_MODULE  LibModule)

Definition at line 636 of file class.c.

638{
639 PLIST_ENTRY classListHead;
641 PCLASS_MODULE pClassModule;
642 LIST_ENTRY removedList;
643
644 InitializeListHead(&removedList);
645 classListHead = &LibModule->ClassListHead;
646
647 if (IsListEmpty(classListHead))
648 return classListHead;
649
650 while (!IsListEmpty(classListHead))
651 {
652 entry = RemoveHeadList(classListHead);
653 InsertTailList(&removedList, entry);
654 }
655
656 while (!IsListEmpty(&removedList))
657 {
658 entry = RemoveHeadList(&removedList);
660 pClassModule = CONTAINING_RECORD(entry, CLASS_MODULE, LibraryLinkage);
661
662 __DBGPRINT(("Unload class library %wZ (%p)\n", &pClassModule->Service, pClassModule));
663
664 ClassUnload(pClassModule, 0);
665 if (InterlockedExchangeAdd(&pClassModule->ClassRefCount, -1) == 1)
666 ClassCleanupAndFree(pClassModule);
667 }
668
669 return classListHead;
670}
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964

Referenced by DllUnload().

◆ ReferenceClassVersion()

NTSTATUS ReferenceClassVersion ( _In_ PWDF_CLASS_BIND_INFO  ClassBindInfo,
_In_ PWDF_BIND_INFO  BindInfo,
_Out_ PCLASS_MODULE ClassModule 
)

Definition at line 423 of file class.c.

427{
428 PWDF_BIND_INFO pBindInfo;
429 PCLASS_MODULE pClassModule;
430 UNICODE_STRING driverServiceName;
431 PLIBRARY_MODULE pLibModule;
432 BOOLEAN created;
434
435 *ClassModule = NULL;
436 pBindInfo = BindInfo;
437 created = FALSE;
438 status = GetClassServicePath(ClassBindInfo, BindInfo, &driverServiceName);
439
440 if (!NT_SUCCESS(status))
441 {
442 RtlFreeUnicodeString(&driverServiceName);
443 return status;
444 }
446 pClassModule = FindClassByServiceNameLocked(&driverServiceName, &pLibModule);
447
448 if (!pLibModule)
449 {
450 pLibModule = pBindInfo->Module;
451 }
452
453 if (pLibModule == pBindInfo->Module)
454 {
455 if (pClassModule)
456 {
457 InterlockedExchangeAdd(&pClassModule->ClassRefCount, 1);
458 }
459 else
460 {
461 pClassModule = ClassCreate(NULL, pLibModule, &driverServiceName);
462
463 if (pClassModule)
464 {
465 InterlockedExchangeAdd(&pClassModule->ClassRefCount, 1);
466 LibraryAddToClassListLocked(pLibModule, pClassModule);
467 created = TRUE;
468 }
469 else
470 {
472 }
473 }
474 }
475 else
476 {
478
479 __DBGPRINT(("class %S bound to library %p,client bound to library %p, status 0x%x\n",
480 ClassBindInfo->ClassName,
481 pLibModule,
482 pBindInfo->Module,
483 status));
484 }
486
487 if (!created)
488 {
489 if (!NT_SUCCESS(status))
490 goto clean;
491
492 ClassBindInfo->ClassModule = pClassModule;
493 *ClassModule = pClassModule;
494 }
495
496 /* Class logic: Only call ZwLoadDriver if:
497 * 1. Class module was newly created, OR
498 * 2. Class module exists but has no ClassLibraryInfo
499 */
500 if (created || (pClassModule && !pClassModule->ClassLibraryInfo))
501 {
502
503 status = ZwLoadDriver(&driverServiceName);
504 if (!NT_SUCCESS(status))
505 {
506
510 {
511 /* Driver might already be loaded as boot driver - UCX*/
513 }
514 }
515 else if (pClassModule && !pClassModule->ClassLibraryInfo)
516 {
518 }
519 }
520 else
521 {
522 /* Class module exists and has ClassLibraryInfo - skip ZwLoadDriver */
524 }
525
526 /* Always set the class module regardless of ZwLoadDriver result (Again.. UCX) */
527 if (pClassModule && NT_SUCCESS(status))
528 {
529 ClassBindInfo->ClassModule = pClassModule;
530 *ClassModule = pClassModule;
531
532 InterlockedExchangeAdd(&pClassModule->ClientRefCount, 1);
533 goto exit_success;
534 }
535
536clean:
537 if (pClassModule && InterlockedExchangeAdd(&pClassModule->ClassRefCount, -1) == 1)
538 ClassCleanupAndFree(pClassModule);
539
540exit_success:
541
542 RtlFreeUnicodeString(&driverServiceName);
543
544 return status;
545}
static DRIVER_DISPATCH ClassCreate
Definition: kbdclass.c:18
#define STATUS_IMAGE_ALREADY_LOADED
Definition: ntstatus.h:600
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:419
PCLASS_MODULE FindClassByServiceNameLocked(_In_ PUNICODE_STRING ServicePath, _Out_ PLIBRARY_MODULE *LibModule)
Definition: class.c:585
PLIST_ENTRY LibraryAddToClassListLocked(_In_ PLIBRARY_MODULE LibModule, _In_ PCLASS_MODULE ClassModule)
Definition: class.c:673
NTSTATUS GetClassServicePath(_In_ PWDF_CLASS_BIND_INFO ClassBindInfo, _In_ PWDF_BIND_INFO BindInfo, _Out_ PUNICODE_STRING ServicePath)
Definition: class.c:371
LONG ClientRefCount
Definition: wdfloader.h:178
PLIBRARY_MODULE Module
Definition: fxldr.h:136
#define STATUS_DRIVER_INTERNAL_ERROR
Definition: udferr_usr.h:177
#define STATUS_OBJECT_PATH_NOT_FOUND
Definition: udferr_usr.h:151
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149

Referenced by WdfVersionBindClass().

◆ ReferenceVersion()

NTSTATUS NTAPI ReferenceVersion ( _In_ PWDF_BIND_INFO  Info,
_Out_ PLIBRARY_MODULE Module 
)

Reference a WDF library version.

Parameters
InfoBinding information containing version details
ModulePointer to receive the library module
Returns
NTSTATUS Success or failure status

Definition at line 576 of file wdfldr.c.

579{
581 UNICODE_STRING libraryServicePath = { 0 };
582
584
585 if (!Info || !Module)
586 {
587 DPRINT_ERROR(("Invalid parameters: Info=%p, Module=%p\n", Info, Module));
589 }
590
591 *Module = NULL;
592 /* Multiple ways to find the correct library - once again UCX stresses this extensively */
593 status = GetVersionServicePath(Info, &libraryServicePath);
594 if (!NT_SUCCESS(status))
595 {
596 DPRINT_ERROR(("GetVersionServicePath failed with status 0x%x\n", status));
597 goto Exit;
598 }
599
600 status = LibraryFindOrLoad(&libraryServicePath, Module);
601 if (NT_SUCCESS(status))
602 {
603 Info->Module = *Module;
604 DPRINT_VERBOSE(("Referenced version for library %wZ\n", &libraryServicePath));
605 }
606 else
607 {
608 DPRINT_ERROR(("LibraryFindOrLoad failed with status 0x%x\n", status));
609 }
610
611Exit:
612 if (libraryServicePath.Buffer)
613 {
614 RtlFreeUnicodeString(&libraryServicePath);
615 }
616
618 return status;
619}
NTSTATUS LibraryFindOrLoad(_In_ PCUNICODE_STRING ServicePath, _Out_ PLIBRARY_MODULE *LibModule)
Definition: library.c:206
NTSTATUS GetVersionServicePath(_In_ PWDF_BIND_INFO BindInfo, _Out_ PUNICODE_STRING ServicePath)
Get service path from bind info and registry.
Definition: registry.c:141
static void Exit(void)
Definition: sock.c:1330

Referenced by WdfVersionBind().

◆ ServiceCheckBootStart()

BOOLEAN ServiceCheckBootStart ( _In_ PUNICODE_STRING  Service)

Definition at line 194 of file registry.c.

196{
198 OBJECT_ATTRIBUTES objectAttributes;
201 ULONG value;
202 UNICODE_STRING valueName = RTL_CONSTANT_STRING(L"Start");
203
205 status = ZwOpenKey(&keyHandle, KEY_READ, &objectAttributes);
206
208 {
209 if (NT_SUCCESS(status))
210 {
211 status = FxLdrQueryUlong(keyHandle, &valueName, &value);
212 if (NT_SUCCESS(status))
213 {
214 result = value == 0;
215 }
216 }
217 else
218 {
219 __DBGPRINT(("ZwOpenKey(%wZ) failed: %08X\n", Service, status));
220 }
221 }
222
223 if (keyHandle)
225
226 return result;
227}
WDFKEY keyHandle
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KEY_READ
Definition: nt_native.h:1026
@ Service
Definition: ntsecapi.h:292
NTSTATUS FxLdrQueryUlong(_In_ HANDLE KeyHandle, _In_ PUNICODE_STRING ValueName, _Out_ PULONG Value)
Definition: registry.c:231
Definition: pdh_main.c:96

Referenced by ClassCreate().

Variable Documentation

◆ WdfLdrDiags

WDFLDR_DIAGS WdfLdrDiags
extern

Definition at line 27 of file wdfldr.c.

Referenced by DereferenceVersion(), DllInitialize(), and WdfRegisterClassLibrary().

◆ WdfLdrGlobals