ReactOS 0.4.16-dev-334-g4d9f67c
config.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/ke/config.c
5 * PURPOSE: Configuration Tree Routines
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include <ntoskrnl.h>
12#define NDEBUG
13#include <debug.h>
14
15/* FUNCTIONS *****************************************************************/
16
17/*
18 * @implemented
19 */
25 IN PULONG ComponentKey OPTIONAL)
26{
28
29 /* Start Search at Root */
31 Class,
32 Type,
33 ComponentKey,
34 &NextLink);
35}
36
37/*
38 * @implemented
39 */
45 IN PULONG ComponentKey OPTIONAL,
47{
48 ULONG Key = 0;
49 ULONG Mask = 0;
52
53 /* If we did get a key, then use it instead */
54 if (ComponentKey)
55 {
56 Key = *ComponentKey;
57 Mask = -1;
58 }
59
60 /* Loop the Components until we find a a match */
61 while (Child)
62 {
63 /* Check if we are starting somewhere already */
64 if (*NextLink)
65 {
66 /* If we've found the place where we started, clear and continue */
67 if (Child == *NextLink) *NextLink = NULL;
68 }
69 else
70 {
71 /* Try to get a match */
72 if ((Child->ComponentEntry.Class) == Class &&
73 (Child->ComponentEntry.Type) == Type &&
74 (Child->ComponentEntry.Key & Mask) == Key)
75 {
76 /* Match found */
77 return Child;
78 }
79 }
80
81 /* Now we've also got to lookup the siblings */
82 Sibling = Child->Sibling;
83 while (Sibling)
84 {
85 /* Check if we are starting somewhere already */
86 if (*NextLink)
87 {
88 /* If we've found the place where we started, clear and continue */
89 if (Sibling == *NextLink) *NextLink = NULL;
90 }
91 else
92 {
93 /* Try to get a match */
94 if ((Sibling->ComponentEntry.Class == Class) &&
95 (Sibling->ComponentEntry.Type == Type) &&
96 (Sibling->ComponentEntry.Key & Mask) == Key)
97 {
98 /* Match found */
99 return Sibling;
100 }
101 }
102
103 /* We've got to check if the Sibling has a Child as well */
104 if (Sibling->Child)
105 {
106 /* We're just going to call ourselves again */
107 ReturnEntry = KeFindConfigurationNextEntry(Sibling->Child,
108 Class,
109 Type,
110 ComponentKey,
111 NextLink);
112 if (ReturnEntry) return ReturnEntry;
113 }
114
115 /* Next Sibling */
116 Sibling = Sibling->Sibling;
117 }
118
119 /* Next Child */
120 Child = Child->Child;
121 }
122
123 /* If we got here, nothing was found */
124 return NULL;
125}
Type
Definition: Type.h:7
#define NULL
Definition: types.h:112
unsigned int Mask
Definition: fpcontrol.c:82
PCONFIGURATION_COMPONENT_DATA NTAPI KeFindConfigurationNextEntry(IN PCONFIGURATION_COMPONENT_DATA Child, IN CONFIGURATION_CLASS Class, IN CONFIGURATION_TYPE Type, IN PULONG ComponentKey OPTIONAL, IN PCONFIGURATION_COMPONENT_DATA *NextLink)
Definition: config.c:42
PCONFIGURATION_COMPONENT_DATA NTAPI KeFindConfigurationEntry(IN PCONFIGURATION_COMPONENT_DATA Child, IN CONFIGURATION_CLASS Class, IN CONFIGURATION_TYPE Type, IN PULONG ComponentKey OPTIONAL)
Definition: config.c:22
enum _CONFIGURATION_CLASS CONFIGURATION_CLASS
enum _CONFIGURATION_TYPE CONFIGURATION_TYPE
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
CONFIGURATION_COMPONENT ComponentEntry
Definition: arc.h:168
struct _CONFIGURATION_COMPONENT_DATA * Sibling
Definition: arc.h:167
struct _CONFIGURATION_COMPONENT_DATA * Child
Definition: arc.h:166
CONFIGURATION_TYPE Type
Definition: arc.h:152
CONFIGURATION_CLASS Class
Definition: arc.h:151
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536