ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

cmkeydel.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS Kernel
00003  * LICENSE:         GPL - See COPYING in the top level directory
00004  * FILE:            ntoskrnl/config/cmkeydel.c
00005  * PURPOSE:         Configuration Manager - Key Body Deletion
00006  * PROGRAMMERS:     Alex Ionescu (alex.ionescu@reactos.org)
00007  */
00008 
00009 /* INCLUDES ******************************************************************/
00010 
00011 #include "ntoskrnl.h"
00012 #define NDEBUG
00013 #include "debug.h"
00014 
00015 /* FUNCTIONS *****************************************************************/
00016 
00017 BOOLEAN
00018 NTAPI
00019 CmpMarkKeyDirty(IN PHHIVE Hive,
00020                 IN HCELL_INDEX Cell,
00021                 IN BOOLEAN CheckNoSubkeys)
00022 {
00023     PCELL_DATA CellData, ListData, SecurityData, ValueData;
00024     ULONG i;
00025 
00026     /* Get the cell data for our target */
00027     CellData = HvGetCell(Hive, Cell);
00028     if (!CellData) return FALSE;
00029 
00030     /* Check if sanity checks requested */
00031     if (CheckNoSubkeys)
00032     {
00033         /* Do them */
00034         ASSERT(CellData->u.KeyNode.SubKeyCounts[Stable] == 0);
00035         ASSERT(CellData->u.KeyNode.SubKeyCounts[Volatile] == 0);
00036     }
00037 
00038     /* If this is an exit hive, there's nothing to do */
00039     if (CellData->u.KeyNode.Flags & KEY_HIVE_EXIT)
00040     {
00041         /* Release the cell and get out */
00042         HvReleaseCell(Hive, Cell);
00043         return TRUE;
00044     }
00045 
00046     /* Otherwise, mark it dirty and release it */
00047     HvMarkCellDirty(Hive, Cell, FALSE);
00048     HvReleaseCell(Hive, Cell);
00049 
00050     /* Check if we have a class */
00051     if (CellData->u.KeyNode.Class != HCELL_NIL)
00052     {
00053         /* Mark it dirty */
00054         HvMarkCellDirty(Hive, CellData->u.KeyNode.Class, FALSE);
00055     }
00056 
00057     /* Check if we have security */
00058     if (CellData->u.KeyNode.Security != HCELL_NIL)
00059     {
00060         /* Mark it dirty */
00061         HvMarkCellDirty(Hive, CellData->u.KeyNode.Security, FALSE);
00062 
00063         /* Get the security data and release it */
00064         SecurityData = HvGetCell(Hive, CellData->u.KeyNode.Security);
00065         if (!SecurityData) ASSERT(FALSE);
00066         HvReleaseCell(Hive, CellData->u.KeyNode.Security);
00067 
00068         /* Mark the security links dirty too */
00069         HvMarkCellDirty(Hive, SecurityData->u.KeySecurity.Flink, FALSE);
00070         HvMarkCellDirty(Hive, SecurityData->u.KeySecurity.Blink, FALSE);
00071     }
00072 
00073     /* Check if we have any values */
00074     if (CellData->u.KeyNode.ValueList.Count > 0)
00075     {
00076         /* Dirty the value list */
00077         HvMarkCellDirty(Hive, CellData->u.KeyNode.ValueList.List, FALSE);
00078 
00079         /* Get the list data itself, and release it */
00080         ListData = HvGetCell(Hive, CellData->u.KeyNode.ValueList.List);
00081         if (!ListData) ASSERT(FALSE);
00082         HvReleaseCell(Hive, CellData->u.KeyNode.ValueList.List);
00083 
00084         /* Loop all values */
00085         for (i = 0; i < CellData->u.KeyNode.ValueList.Count; i++)
00086         {
00087             /* Dirty each value */
00088             HvMarkCellDirty(Hive, ListData->u.KeyList[i], FALSE);
00089 
00090             /* Get the value data and release it */
00091             ValueData = HvGetCell(Hive, ListData->u.KeyList[i]);
00092             ASSERT(ValueData);
00093             HvReleaseCell(Hive,ListData->u.KeyList[i]);
00094 
00095             /* Mark the value data dirty too */
00096             if (!CmpMarkValueDataDirty(Hive, &ValueData->u.KeyValue))
00097             {
00098                 /* Failure */
00099                 return FALSE;
00100             }
00101         }
00102     }
00103 
00104     /* If this is an entry hive, we're done */
00105     if (CellData->u.KeyNode.Flags & KEY_HIVE_ENTRY) return TRUE;
00106 
00107     /* Otherwise mark the index dirty too */
00108     if (!CmpMarkIndexDirty(Hive, CellData->u.KeyNode.Parent, Cell))
00109     {
00110         /* Failure */
00111         return FALSE;
00112     }
00113 
00114     /* Finally, mark the parent dirty */
00115     HvMarkCellDirty(Hive, CellData->u.KeyNode.Parent, FALSE);
00116     return TRUE;
00117 }
00118 
00119 BOOLEAN
00120 NTAPI
00121 CmpFreeKeyBody(IN PHHIVE Hive,
00122                IN HCELL_INDEX Cell)
00123 {
00124     PCELL_DATA CellData;
00125 
00126     /* Get the key node */
00127     CellData = HvGetCell(Hive, Cell);
00128     if (!CellData) ASSERT(FALSE);
00129 
00130     /* Check if we can delete the child cells */
00131     if (!(CellData->u.KeyNode.Flags & KEY_HIVE_EXIT))
00132     {
00133         /* Check if we have a security cell */
00134         if (CellData->u.KeyNode.Security != HCELL_NIL)
00135         {
00136             /* Free the security cell */
00137             HvFreeCell(Hive, CellData->u.KeyNode.Security);
00138         }
00139 
00140         /* Check if we have a class */
00141         if (CellData->u.KeyNode.ClassLength > 0)
00142         {
00143             /* Free it */
00144             HvFreeCell(Hive, CellData->u.KeyNode.Class);
00145         }
00146     }
00147 
00148     /* Release and free the cell */
00149     HvReleaseCell(Hive, Cell);
00150     HvFreeCell(Hive, Cell);
00151     return TRUE;
00152 }
00153 
00154 NTSTATUS
00155 NTAPI
00156 CmpFreeKeyByCell(IN PHHIVE Hive,
00157                  IN HCELL_INDEX Cell,
00158                  IN BOOLEAN Unlink)
00159 {
00160     PCELL_DATA CellData, ParentData, ListData;
00161     ULONG i;
00162     BOOLEAN Result;
00163 
00164     /* Mark the entire key dirty */
00165     CmpMarkKeyDirty(Hive, Cell ,TRUE);
00166 
00167     /* Get the target node and release it */
00168     CellData = HvGetCell(Hive, Cell);
00169     if (!CellData) ASSERT(FALSE);
00170     HvReleaseCell(Hive, Cell);
00171 
00172     /* Make sure we don't have subkeys */
00173     ASSERT((CellData->u.KeyNode.SubKeyCounts[Stable] +
00174             CellData->u.KeyNode.SubKeyCounts[Volatile]) == 0);
00175 
00176     /* Check if we have to unlink */
00177     if (Unlink)
00178     {
00179         /* Remove the subkey */
00180         Result = CmpRemoveSubKey(Hive, CellData->u.KeyNode.Parent, Cell);
00181         if (!Result) return STATUS_INSUFFICIENT_RESOURCES;
00182 
00183         /* Get the parent node and release it */
00184         ParentData = HvGetCell(Hive, CellData->u.KeyNode.Parent);
00185         if (!ParentData) ASSERT(FALSE);
00186         HvReleaseCell(Hive, CellData->u.KeyNode.Parent);
00187 
00188         /* Check if the parent node has no more subkeys */
00189         if (!(ParentData->u.KeyNode.SubKeyCounts[Stable] +
00190               ParentData->u.KeyNode.SubKeyCounts[Volatile]))
00191         {
00192             /* Then free the cached name/class lengths */
00193             ParentData->u.KeyNode.MaxNameLen = 0;
00194             ParentData->u.KeyNode.MaxClassLen = 0;
00195         }
00196     }
00197 
00198     /* Check if we have any values */
00199     if (CellData->u.KeyNode.ValueList.Count > 0)
00200     {
00201         /* Get the value list and release it */
00202         ListData = HvGetCell(Hive, CellData->u.KeyNode.ValueList.List);
00203         if (!ListData) ASSERT(FALSE);
00204         HvReleaseCell(Hive, CellData->u.KeyNode.ValueList.List);
00205 
00206         /* Loop every value */
00207         for (i = 0; i < CellData->u.KeyNode.ValueList.Count; i++)
00208         {
00209             /* Free it */
00210             if (!CmpFreeValue(Hive, ListData->u.KeyList[i])) ASSERT(FALSE);
00211         }
00212 
00213         /* Free the value list */
00214         HvFreeCell(Hive, CellData->u.KeyNode.ValueList.List);
00215     }
00216 
00217     /* Free the key body itself, and then return our status */
00218     if (!CmpFreeKeyBody(Hive, Cell)) return STATUS_INSUFFICIENT_RESOURCES;
00219     return STATUS_SUCCESS;
00220 }

Generated on Sun May 27 2012 04:37:07 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.