32#define CMTRACE(x, fmt, ...) TRACE(fmt, ##__VA_ARGS__)
39#define CM_BOOT_DEBUG 0x20
41#define IS_NULL_TERMINATED(Buffer, Size) \
42 (((Size) >= sizeof(WCHAR)) && ((Buffer)[(Size) / sizeof(WCHAR) - 1] == UNICODE_NULL))
90 HCELL_INDEX SelectCell, AutoSelectCell, SelectValueCell, ControlSetCell;
131 *AutoSelect = *(
PBOOLEAN)CurrentData;
150 L"ControlSet%03lu", *ControlSetId);
180 *CurrentData = *ControlSetId;
185 return ControlSetCell;
222 PULONG DriverTag, TagOrder;
231 if (!
Value)
return -2;
234 if (!DriverTag)
return -2;
239 if (!
Node)
return -2;
245 if (!TagValue)
return -2;
258 for (CurrentTag = 1; CurrentTag <= TagOrder[0]; CurrentTag++)
261 if (TagOrder[CurrentTag] == *DriverTag)
264 if (BufferAllocated) Hive->Free(TagOrder,
Length);
270 if (BufferAllocated) Hive->Free(TagOrder,
Length);
308 Entry != DriverListHead;
321 *FoundDriver = DriverNode;
485 if (!RegistryString->
Buffer)
558 DriverNode->
Tag = -1;
646 return (*
Data == LoadType);
684 HCELL_INDEX ServicesCell, ControlCell, GroupOrderCell, DriverCell;
697 if (!ControlNode)
return FALSE;
706 if (!ServicesNode)
return FALSE;
739 default:
return FALSE;
755 CmpIsSafe(Hive, SafeBootCell, DriverCell))
836 Current = &OrderList->Buffer[OrderList->Length /
sizeof(
WCHAR)];
837 while (
Current > OrderList->Buffer)
852 NextEntry = DriverListHead->
Flink;
853 while (NextEntry != DriverListHead)
861 NextEntry = NextEntry->
Flink;
937 if (!ListValue)
return FALSE;
948 return CmpDoSort(DriverListHead, &OrderList);
962 if (StartNode == EndNode)
return TRUE;
965 CurrentNode = StartNode;
969 PreviousNode = CurrentNode;
978 if (PreviousNode->
Tag > CurrentNode->
Tag)
981 if (CurrentNode == EndNode)
994 while ((PreviousNode->
Tag > CurrentNode->
Tag) && (PreviousNode != StartNode))
1007 if (PreviousNode == StartNode) StartNode = CurrentNode;
1009 }
while (CurrentNode != EndNode);
1035 NextEntry = DriverListHead->
Flink;
1036 while (NextEntry != DriverListHead)
1050 NextEntry = NextEntry->
Flink;
1056 if (NextEntry == DriverListHead)
break;
1060 &CurrentNode->
Group,
1066 }
while (NextEntry != DriverListHead);
1098 if (!DriverNode)
return FALSE;
1103 if (!SafeBootNode)
return FALSE;
1111 if (!KeyValue)
return FALSE;
1162 Hive->Free(
Name.Buffer,
Name.MaximumLength);
1171 if (!KeyValue)
return FALSE;
#define OBJ_NAME_PATH_SEPARATOR
#define DBG_DEFAULT_CHANNEL(ch)
RtlInitEmptyUnicodeString(SymbolicLinkName, NULL, 0)
#define CMTRACE(x, fmt,...)
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 CmpIsLoadType(_In_ PHHIVE Hive, _In_ HCELL_INDEX Cell, _In_ SERVICE_LOAD_TYPE LoadType)
Checks whether the specified driver has the expected load type.
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.
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,...
static BOOLEAN CmpIsSafe(_In_ PHHIVE Hive, _In_ HCELL_INDEX SafeBootCell, _In_ HCELL_INDEX DriverCell)
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 IS_NULL_TERMINATED(Buffer, Size)
static BOOLEAN CmpDoSort(_Inout_ PLIST_ENTRY DriverListHead, _In_ PCUNICODE_STRING OrderList)
Performs the driver list sorting, according to the ordering list.
static BOOLEAN CmpOrderGroup(_In_ PBOOT_DRIVER_NODE StartNode, _In_ PBOOT_DRIVER_NODE EndNode)
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.
VOID NTAPI CmpFreeDriverList(_In_ PHHIVE Hive, _Inout_ PLIST_ENTRY DriverListHead)
Empties the driver list and frees all allocated driver nodes in it.
struct _CM_KEY_NODE * PCM_KEY_NODE
struct _CM_KEY_VALUE * PCM_KEY_VALUE
HCELL_INDEX NTAPI CmpFindSubKeyByNumber(IN PHHIVE Hive, IN PCM_KEY_NODE Node, IN ULONG Number)
HCELL_INDEX NTAPI CmpFindSubKeyByName(IN PHHIVE Hive, IN PCM_KEY_NODE Parent, IN PCUNICODE_STRING SearchName)
BOOLEAN NTAPI CmpGetValueData(IN PHHIVE Hive, IN PCM_KEY_VALUE Value, OUT PULONG Length, OUT PVOID *Buffer, OUT PBOOLEAN BufferAllocated, OUT PHCELL_INDEX CellToRelease)
VOID NTAPI CmpCopyCompressedName(OUT PWCHAR Destination, IN ULONG DestinationLength, IN PWCHAR Source, IN ULONG SourceLength)
HCELL_INDEX NTAPI CmpFindValueByName(IN PHHIVE Hive, IN PCM_KEY_NODE KeyNode, IN PCUNICODE_STRING Name)
PCELL_DATA NTAPI CmpValueToData(IN PHHIVE Hive, IN PCM_KEY_VALUE Value, OUT PULONG Length)
USHORT NTAPI CmpCompressedNameSize(IN PWCHAR Name, IN ULONG Length)
#define HvGetCell(Hive, Cell)
#define NT_SUCCESS(StatCode)
#define RTL_CONSTANT_STRING(s)
DRIVER_INITIALIZE DriverEntry
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
#define IsListEmpty(ListHead)
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
#define RemoveHeadList(ListHead)
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
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
_In_ ULONG _In_ ULONG _In_ ULONG Length
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
UNICODE_STRING RegistryPath
BOOT_DRIVER_LIST_ENTRY ListEntry
WCHAR Name[ANYSIZE_ARRAY]
PRELEASE_CELL_ROUTINE ReleaseCellRoutine
struct _LIST_ENTRY * Blink
struct _LIST_ENTRY * Flink
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
#define SERVICE_ERROR_CRITICAL
enum _CM_SERVICE_LOAD_TYPE SERVICE_LOAD_TYPE