00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#include "cmp.h"
00022
00023
#ifdef ALLOC_PRAGMA
00024
#pragma alloc_text(PAGE,CmpDeleteTree)
00025
#pragma alloc_text(PAGE,CmpFreeKeyByCell)
00026
#pragma alloc_text(PAGE,CmpMarkKeyDirty)
00027
#endif
00028
00029
00030
00031
00032
00033
VOID
00034 CmpDeleteTree(
00035
PHHIVE Hive,
00036 HCELL_INDEX Cell
00037 )
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 {
00066 ULONG count;
00067
HCELL_INDEX ptr1;
00068
HCELL_INDEX ptr2;
00069
HCELL_INDEX parent;
00070
PCM_KEY_NODE Node;
00071
00072
CMLOG(
CML_MAJOR,
CMS_SAVRES) {
00073 KdPrint((
"CmpDeleteTree:\n"));
00074 KdPrint((
"\tHive=%08lx Cell=%08lx\n",
Hive,
Cell));
00075 }
00076
00077 ptr1 =
Cell;
00078
00079
while(
TRUE) {
00080
00081 Node = (
PCM_KEY_NODE)
HvGetCell(
Hive, ptr1);
00082 count = Node->
SubKeyCounts[
Stable] +
00083 Node->
SubKeyCounts[
Volatile];
00084 parent = Node->
Parent;
00085
00086
if (count > 0) {
00087
00088
00089
00090
00091 ptr2 =
CmpFindSubKeyByNumber(
Hive, Node, 0);
00092
00093 Node = (
PCM_KEY_NODE)
HvGetCell(
Hive, ptr2);
00094 count = Node->
SubKeyCounts[
Stable] +
00095 Node->
SubKeyCounts[
Volatile];
00096
00097
if (count > 0) {
00098
00099
00100
00101
00102 ptr1 = ptr2;
00103
continue;
00104
00105 }
else {
00106
00107
00108
00109
00110
CmpFreeKeyByCell(
Hive, ptr2,
TRUE);
00111
continue;
00112 }
00113
00114 }
else {
00115
00116
00117
00118
00119
if (ptr1 !=
Cell) {
00120
00121
00122
00123
00124 ptr1 = parent;
00125
continue;
00126
00127 }
else {
00128
00129
00130
00131
00132
return;
00133 }
00134 }
00135 }
00136 }
00137
00138
00139
NTSTATUS
00140 CmpFreeKeyByCell(
00141
PHHIVE Hive,
00142 HCELL_INDEX Cell,
00143 BOOLEAN Unlink
00144 )
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 {
00168
PCELL_DATA ptarget;
00169
PCELL_DATA pparent;
00170
PCELL_DATA plist;
00171 ULONG i;
00172
00173
00174
00175
00176
if (!
CmpMarkKeyDirty(
Hive,
Cell)) {
00177
return STATUS_NO_LOG_SPACE;
00178 }
00179
00180
00181
00182
00183 ptarget =
HvGetCell(
Hive,
Cell);
00184
ASSERT((ptarget->
u.
KeyNode.
SubKeyCounts[
Stable] +
00185 ptarget->
u.
KeyNode.
SubKeyCounts[
Volatile]) == 0);
00186
00187
00188
if (Unlink ==
TRUE) {
00189 BOOLEAN Success;
00190
00191 Success =
CmpRemoveSubKey(
Hive, ptarget->
u.
KeyNode.
Parent,
Cell);
00192
if (!Success) {
00193
return STATUS_INSUFFICIENT_RESOURCES;
00194 }
00195 pparent =
HvGetCell(
Hive, ptarget->
u.
KeyNode.
Parent);
00196
if ( (pparent->
u.
KeyNode.
SubKeyCounts[
Stable] +
00197 pparent->
u.
KeyNode.
SubKeyCounts[
Volatile]) == 0)
00198 {
00199 pparent->
u.
KeyNode.
MaxNameLen = 0;
00200 pparent->
u.
KeyNode.
MaxClassLen = 0;
00201 }
00202 }
00203
00204
00205
00206
00207
00208
00209
00210
00211
if (!(ptarget->
u.
KeyNode.
Flags &
KEY_HIVE_EXIT) &&
00212 !(ptarget->
u.
KeyNode.
Flags &
KEY_PREDEF_HANDLE) ) {
00213
00214
00215
00216
00217
if (ptarget->
u.
KeyNode.
ValueList.
Count > 0) {
00218
00219
00220 plist =
HvGetCell(
Hive, ptarget->
u.
KeyNode.
ValueList.
List);
00221
00222
for (i = 0; i < ptarget->
u.
KeyNode.
ValueList.
Count; i++) {
00223
CmpFreeValue(
Hive, plist->
u.
KeyList[i]);
00224 }
00225
00226
HvFreeCell(
Hive, ptarget->
u.
KeyNode.
ValueList.
List);
00227 }
00228
00229
00230
00231
00232
CmpFreeSecurityDescriptor(
Hive,
Cell);
00233 }
00234
00235
00236
00237
00238
CmpFreeKeyBody(
Hive,
Cell);
00239
00240
return STATUS_SUCCESS;
00241 }
00242
00243
00244 BOOLEAN
00245 CmpMarkKeyDirty(
00246
PHHIVE Hive,
00247 HCELL_INDEX Cell
00248 )
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270 {
00271
PCELL_DATA ptarget;
00272
PCELL_DATA plist;
00273
PCELL_DATA security;
00274
PCELL_DATA pvalue;
00275 ULONG i;
00276 ULONG realsize;
00277
00278
00279
00280
00281
00282 ptarget =
HvGetCell(
Hive,
Cell);
00283
ASSERT(ptarget->
u.
KeyNode.
SubKeyCounts[
Stable] == 0);
00284
ASSERT(ptarget->
u.
KeyNode.
SubKeyCounts[
Volatile] == 0);
00285
00286
if (ptarget->
u.
KeyNode.
Flags &
KEY_HIVE_EXIT) {
00287
00288
00289
00290
00291
00292
00293
return(
TRUE);
00294 }
00295
00296
00297
00298
00299
if (!
HvMarkCellDirty(
Hive,
Cell)) {
00300
return FALSE;
00301 }
00302
00303
00304
00305
00306
if (ptarget->
u.
KeyNode.
Class !=
HCELL_NIL) {
00307
if (!
HvMarkCellDirty(
Hive, ptarget->
u.
KeyNode.
Class)) {
00308
return FALSE;
00309 }
00310 }
00311
00312
00313
00314
00315
if (ptarget->
u.
KeyNode.
Security !=
HCELL_NIL) {
00316
if (!
HvMarkCellDirty(
Hive, ptarget->
u.
KeyNode.
Security)) {
00317
return FALSE;
00318 }
00319
00320 security =
HvGetCell(
Hive, ptarget->
u.
KeyNode.
Security);
00321
if (! (
HvMarkCellDirty(
Hive, security->
u.
KeySecurity.
Flink) &&
00322
HvMarkCellDirty(
Hive, security->
u.
KeySecurity.
Blink)))
00323 {
00324
return FALSE;
00325 }
00326 }
00327
00328
00329
00330
00331
if ( !(ptarget->
u.
KeyNode.
Flags &
KEY_PREDEF_HANDLE) &&
00332 (ptarget->
u.
KeyNode.
ValueList.
Count > 0)
00333 ) {
00334
00335
00336
if (!
HvMarkCellDirty(
Hive, ptarget->
u.
KeyNode.
ValueList.
List)) {
00337
return FALSE;
00338 }
00339 plist =
HvGetCell(
Hive, ptarget->
u.
KeyNode.
ValueList.
List);
00340
00341
for (i = 0; i < ptarget->
u.
KeyNode.
ValueList.
Count; i++) {
00342
if (!
HvMarkCellDirty(
Hive, plist->
u.
KeyList[i])) {
00343
return FALSE;
00344 }
00345
00346 pvalue =
HvGetCell(
Hive, plist->
u.
KeyList[i]);
00347
00348
if (!
CmpIsHKeyValueSmall(realsize, pvalue->
u.
KeyValue.
DataLength)) {
00349
if (!
HvMarkCellDirty(
Hive, pvalue->
u.
KeyValue.
Data)) {
00350
return(
FALSE);
00351 }
00352 }
00353 }
00354 }
00355
00356
if (ptarget->
u.
KeyNode.
Flags &
KEY_HIVE_ENTRY) {
00357
00358
00359
00360
00361
00362
return TRUE;
00363 }
00364
00365
00366
00367
00368
if (!
CmpMarkIndexDirty(
Hive, ptarget->
u.
KeyNode.
Parent,
Cell)) {
00369
return FALSE;
00370 }
00371
00372
00373
00374
00375
if (!
HvMarkCellDirty(
Hive, ptarget->
u.
KeyNode.
Parent)) {
00376
return FALSE;
00377 }
00378
00379
00380
return TRUE;
00381 }