Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

170 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. regcell.c
  5. Abstract:
  6. This module contains cell manipulation functions.
  7. Author:
  8. Dragos C. Sambotin (dragoss) 30-Dec-1998
  9. Revision History:
  10. --*/
  11. #include "chkreg.h"
  12. extern PUCHAR Base;
  13. extern ULONG HiveLength;
  14. BOOLEAN
  15. IsCellAllocated(
  16. HCELL_INDEX Cell
  17. )
  18. /*
  19. Routine Description:
  20. Checks if the cell is allocated (i.e. the size is negative).
  21. Arguments:
  22. Cell - supplies the cell index of the cell of interest.
  23. Return Value:
  24. TRUE if Cell is allocated. FALSE otherwise.
  25. */
  26. {
  27. PHCELL pcell;
  28. if( Cell >= HiveLength ) return FALSE;
  29. pcell = (PHCELL)(Base + Cell);
  30. return (pcell->Size < 0) ? TRUE : FALSE;
  31. }
  32. LONG
  33. GetCellSize(
  34. HCELL_INDEX Cell
  35. )
  36. /*
  37. Routine Description:
  38. Retrieves the size of the specified cell.
  39. Arguments:
  40. Cell - supplies the cell index of the cell of interest.
  41. Return Value:
  42. The size of the cell.
  43. */
  44. {
  45. LONG size;
  46. PHCELL pcell;
  47. pcell = (PHCELL)(Base + Cell);
  48. size = pcell->Size * -1;
  49. return size;
  50. }
  51. VOID
  52. FreeCell(
  53. HCELL_INDEX Cell
  54. )
  55. /*
  56. Routine Description:
  57. Frees a cell.
  58. Arguments:
  59. Cell - supplies the cell index of the cell of interest.
  60. Return Value:
  61. NONE.
  62. */
  63. {
  64. PHCELL pcell;
  65. pcell = (PHCELL)(Base + Cell);
  66. pcell->Size *= -1;
  67. ASSERT(pcell->Size >= 0 );
  68. }
  69. BOOLEAN
  70. AllocateCell(
  71. HCELL_INDEX Cell
  72. )
  73. /*
  74. Routine Description:
  75. Allocates a cell, by ensuring a negative size on it
  76. Arguments:
  77. Cell - supplies the cell index of the cell of interest.
  78. Return Value:
  79. NONE.
  80. */
  81. {
  82. PHCELL pcell;
  83. if( Cell >= HiveLength ) return FALSE;
  84. pcell = (PHCELL)(Base + Cell);
  85. pcell->Size *= -1;
  86. if( pcell->Size >= 0 ) return FALSE;
  87. return TRUE;
  88. }
  89. PCELL_DATA
  90. GetCell(
  91. HCELL_INDEX Cell
  92. )
  93. /*
  94. Routine Description:
  95. Retrieves the memory address of the cell specified by Cell.
  96. Arguments:
  97. Cell - supplies the cell index of the cell of interest.
  98. Return Value:
  99. The memory address of Cell.
  100. */
  101. {
  102. PHCELL pcell;
  103. pcell = (PHCELL)(Base + Cell);
  104. return (struct _CELL_DATA *)&(pcell->u.NewCell.u.UserData);
  105. }