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))
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;
#define OBJ_NAME_PATH_SEPARATOR
#define DBG_DEFAULT_CHANNEL(ch)
#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)
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,...)
base of all file and directory entries
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 RTL_CONSTANT_STRING(s)
#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