32 #define CMTRACE(x, fmt, ...) TRACE(fmt, ##__VA_ARGS__) // DPRINT 39 #define CM_BOOT_DEBUG 0x20 41 #define IS_NULL_TERMINATED(Buffer, Size) \ 42 (((Size) >= sizeof(WCHAR)) && ((Buffer)[(Size) / sizeof(WCHAR) - 1] == UNICODE_NULL)) 92 HCELL_INDEX SelectCell, AutoSelectCell, SelectValueCell, ControlSetCell;
133 *AutoSelect = *(
PBOOLEAN)CurrentData;
152 L"ControlSet%03lu", *ControlSetId);
182 *CurrentData = *ControlSetId;
187 return ControlSetCell;
224 PULONG DriverTag, TagOrder;
233 if (!
Value)
return -2;
236 if (!DriverTag)
return -2;
241 if (!
Node)
return -2;
247 if (!TagValue)
return -2;
260 for (CurrentTag = 1; CurrentTag <= TagOrder[0]; CurrentTag++)
263 if (TagOrder[CurrentTag] == *DriverTag)
266 if (BufferAllocated) Hive->Free(TagOrder,
Length);
272 if (BufferAllocated) Hive->Free(TagOrder,
Length);
309 for (
Entry = DriverListHead->Flink;
310 Entry != DriverListHead;
323 *FoundDriver = DriverNode;
403 if (NameLength <
sizeof(
WCHAR))
407 RtlInitEmptyUnicodeString(&DriverNode->
Name,
434 Length =
sizeof(
L"System32\\Drivers\\") + NameLength +
sizeof(
L".sys");
484 RtlInitEmptyUnicodeString(RegistryString,
487 if (!RegistryString->
Buffer)
531 RtlInitEmptyUnicodeString(&DriverNode->
Group,
NULL, 0);
560 DriverNode->
Tag = -1;
648 return (*
Data == LoadType);
686 HCELL_INDEX ServicesCell, ControlCell, GroupOrderCell, DriverCell;
699 if (!ControlNode)
return FALSE;
708 if (!ServicesNode)
return FALSE;
741 default:
return FALSE;
757 CmpIsSafe(Hive, SafeBootCell, DriverCell))
838 Current = &OrderList->Buffer[OrderList->Length /
sizeof(
WCHAR)];
839 while (Current > OrderList->Buffer)
845 }
while ((*(--Current - 1) !=
UNICODE_NULL) && (Current != OrderList->Buffer));
851 GroupName.
Buffer = Current;
854 NextEntry = DriverListHead->
Flink;
855 while (NextEntry != DriverListHead)
863 NextEntry = NextEntry->
Flink;
939 if (!ListValue)
return FALSE;
950 return CmpDoSort(DriverListHead, &OrderList);
964 if (StartNode == EndNode)
return TRUE;
967 CurrentNode = StartNode;
971 PreviousNode = CurrentNode;
980 if (PreviousNode->
Tag > CurrentNode->
Tag)
983 if (CurrentNode == EndNode)
996 while ((PreviousNode->
Tag > CurrentNode->
Tag) && (PreviousNode != StartNode))
1009 if (PreviousNode == StartNode) StartNode = CurrentNode;
1011 }
while (CurrentNode != EndNode);
1037 NextEntry = DriverListHead->
Flink;
1038 while (NextEntry != DriverListHead)
1052 NextEntry = NextEntry->
Flink;
1058 if (NextEntry == DriverListHead)
break;
1062 &CurrentNode->
Group,
1068 }
while (NextEntry != DriverListHead);
1100 if (!DriverNode)
return FALSE;
1105 if (!SafeBootNode)
return FALSE;
1113 if (!KeyValue)
return FALSE;
1142 RtlInitEmptyUnicodeString(&
Name,
1164 Hive->Free(
Name.Buffer,
Name.MaximumLength);
1173 if (!KeyValue)
return FALSE;
WCHAR Name[ANYSIZE_ARRAY]
#define CMTRACE(x, fmt,...)
_In_ ULONG _In_ ULONG _In_ ULONG Length
BOOT_DRIVER_LIST_ENTRY ListEntry
IN BOOLEAN OUT PSTR Buffer
struct _LIST_ENTRY * Blink
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
BOOLEAN NTAPI CmpGetValueData(IN PHHIVE Hive, IN PCM_KEY_VALUE Value, OUT PULONG Length, OUT PVOID *Buffer, OUT PBOOLEAN BufferAllocated, OUT PHCELL_INDEX CellToRelease)
enum _CM_SERVICE_LOAD_TYPE SERVICE_LOAD_TYPE
HCELL_INDEX NTAPI CmpFindSubKeyByNumber(IN PHHIVE Hive, IN PCM_KEY_NODE Node, IN ULONG Number)
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
BOOLEAN NTAPI CmpAddDriverToList(_In_ PHHIVE Hive, _In_ HCELL_INDEX DriverCell, _In_ HCELL_INDEX GroupOrderCell, _In_ PCUNICODE_STRING RegistryPath, _Inout_ PLIST_ENTRY DriverListHead)
Inserts the specified driver entry into the driver list.
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
#define HvGetCell(Hive, Cell)
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
BOOLEAN NTAPI CmpFindDrivers(_In_ PHHIVE Hive, _In_ HCELL_INDEX ControlSet, _In_ SERVICE_LOAD_TYPE LoadType, _In_opt_ PCWSTR BootFileSystem, _Inout_ PLIST_ENTRY DriverListHead)
Enumerates all drivers within the given control set and load type, present in the "Services" sub-key,...
static BOOLEAN CmpIsSafe(_In_ PHHIVE Hive, _In_ HCELL_INDEX SafeBootCell, _In_ HCELL_INDEX DriverCell)
VOID NTAPI CmpFreeDriverList(_In_ PHHIVE Hive, _Inout_ PLIST_ENTRY DriverListHead)
Empties the driver list and frees all allocated driver nodes in it.
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
#define OBJ_NAME_PATH_SEPARATOR
VOID NTAPI CmpCopyCompressedName(OUT PWCHAR Destination, IN ULONG DestinationLength, IN PWCHAR Source, IN ULONG SourceLength)
BOOLEAN NTAPI CmpSortDriverList(_In_ PHHIVE Hive, _In_ HCELL_INDEX ControlSet, _Inout_ PLIST_ENTRY DriverListHead)
Sorts the driver list, according to the drivers' group load ordering.
struct _CM_KEY_NODE * PCM_KEY_NODE
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
static BOOLEAN CmpDoSort(_Inout_ PLIST_ENTRY DriverListHead, _In_ PCUNICODE_STRING OrderList)
Performs the driver list sorting, according to the ordering list.
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
static BOOLEAN CmpIsLoadType(_In_ PHHIVE Hive, _In_ HCELL_INDEX Cell, _In_ SERVICE_LOAD_TYPE LoadType)
Checks whether the specified driver has the expected load type.
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
struct _LIST_ENTRY * Flink
PCELL_DATA NTAPI CmpValueToData(IN PHHIVE Hive, IN PCM_KEY_VALUE Value, OUT PULONG Length)
#define NT_SUCCESS(StatCode)
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
static ULONG CmpFindTagIndex(_In_ PHHIVE Hive, _In_ HCELL_INDEX TagCell, _In_ HCELL_INDEX GroupOrderCell, _In_ PCUNICODE_STRING GroupName)
Finds the index of the driver's "Tag" value in its corresponding group ordering list.
static BOOLEAN CmpOrderGroup(_In_ PBOOT_DRIVER_NODE StartNode, _In_ PBOOT_DRIVER_NODE EndNode)
#define DBG_DEFAULT_CHANNEL(ch)
BOOLEAN NTAPI CmpResolveDriverDependencies(_Inout_ PLIST_ENTRY DriverListHead)
Removes potential circular dependencies (cycles) and sorts the driver list.
HCELL_INDEX NTAPI CmpFindControlSet(_In_ PHHIVE SystemHive, _In_ HCELL_INDEX RootCell, _In_ PCUNICODE_STRING SelectKeyName, _Out_ PBOOLEAN AutoSelect)
Finds the corresponding "HKLM\SYSTEM\ControlSetXXX" system control set registry key,...
UNICODE_STRING RegistryPath
DRIVER_INITIALIZE DriverEntry
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
HCELL_INDEX NTAPI CmpFindValueByName(IN PHHIVE Hive, IN PCM_KEY_NODE KeyNode, IN PCUNICODE_STRING Name)
struct _CM_KEY_VALUE * PCM_KEY_VALUE
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
#define RtlCopyMemory(Destination, Source, Length)
#define SERVICE_ERROR_CRITICAL
#define IS_NULL_TERMINATED(Buffer, Size)
HCELL_INDEX NTAPI CmpFindSubKeyByName(IN PHHIVE Hive, IN PCM_KEY_NODE Parent, IN PCUNICODE_STRING SearchName)
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
USHORT NTAPI CmpCompressedNameSize(IN PWCHAR Name, IN ULONG Length)
PRELEASE_CELL_ROUTINE ReleaseCellRoutine
base of all file and directory entries
#define RTL_CONSTANT_STRING(s)