2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: lib/cmlib/cmse.c
5 * PURPOSE: Configuration Manager Library - Security Subsystem Interface
6 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
9 /* INCLUDES ******************************************************************/
15 /* FUNCTIONS *****************************************************************/
19 CmpRemoveSecurityCellList(IN PHHIVE Hive
,
20 IN HCELL_INDEX SecurityCell
)
22 PCM_KEY_SECURITY SecurityData
, FlinkCell
, BlinkCell
;
26 // ASSERT( (((PCMHIVE)Hive)->HiveSecurityLockOwner == KeGetCurrentThread()) || (CmpTestRegistryLockExclusive() == TRUE) );
28 SecurityData
= HvGetCell(Hive
, SecurityCell
);
29 if (!SecurityData
) return;
31 FlinkCell
= HvGetCell(Hive
, SecurityData
->Flink
);
34 HvReleaseCell(Hive
, SecurityCell
);
38 BlinkCell
= HvGetCell(Hive
, SecurityData
->Blink
);
41 HvReleaseCell(Hive
, SecurityData
->Flink
);
42 HvReleaseCell(Hive
, SecurityCell
);
47 ASSERT(FlinkCell
->Blink
== SecurityCell
);
48 ASSERT(BlinkCell
->Flink
== SecurityCell
);
50 /* Unlink the security block and free it */
51 FlinkCell
->Blink
= SecurityData
->Blink
;
52 BlinkCell
->Flink
= SecurityData
->Flink
;
54 CmpRemoveFromSecurityCache(Hive
, SecurityCell
);
57 /* Release the cells */
58 HvReleaseCell(Hive
, SecurityData
->Blink
);
59 HvReleaseCell(Hive
, SecurityData
->Flink
);
60 HvReleaseCell(Hive
, SecurityCell
);
65 CmpFreeSecurityDescriptor(IN PHHIVE Hive
,
68 PCM_KEY_NODE CellData
;
69 PCM_KEY_SECURITY SecurityData
;
73 // ASSERT( (((PCMHIVE)Hive)->HiveSecurityLockOwner == KeGetCurrentThread()) || (CmpTestRegistryLockExclusive() == TRUE) );
75 CellData
= HvGetCell(Hive
, Cell
);
76 if (!CellData
) return;
78 ASSERT(CellData
->Signature
== CM_KEY_NODE_SIGNATURE
);
80 // FIXME: ReactOS-specific: check whether this key has a security block.
81 // On Windows there is no such check, all keys seem to have a valid
83 // If we remove this check on ReactOS (and continue running) then we get
84 // a BSOD at the end...
85 if (CellData
->Security
== HCELL_NIL
)
87 DPRINT("Cell 0x%08x (data 0x%p) has no security block!\n", Cell
, CellData
);
88 HvReleaseCell(Hive
, Cell
);
92 SecurityData
= HvGetCell(Hive
, CellData
->Security
);
95 HvReleaseCell(Hive
, Cell
);
99 ASSERT(SecurityData
->Signature
== CM_KEY_SECURITY_SIGNATURE
);
101 if (SecurityData
->ReferenceCount
> 1)
103 SecurityData
->ReferenceCount
--;
105 else // if (SecurityData->ReferenceCount <= 1)
107 CmpRemoveSecurityCellList(Hive
, CellData
->Security
);
108 HvFreeCell(Hive
, CellData
->Security
);
111 CellData
->Security
= HCELL_NIL
;
112 HvReleaseCell(Hive
, CellData
->Security
);
113 HvReleaseCell(Hive
, Cell
);