Source code of Windows XP (NT5)
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.

164 lines
2.0 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. BOOLEAN
  14. IsCellAllocated(
  15. HCELL_INDEX Cell
  16. )
  17. /*
  18. Routine Description:
  19. Checks if the cell is allocated (i.e. the size is negative).
  20. Arguments:
  21. Cell - supplies the cell index of the cell of interest.
  22. Return Value:
  23. TRUE if Cell is allocated. FALSE otherwise.
  24. */
  25. {
  26. PHCELL pcell;
  27. pcell = (PHCELL)(Base + Cell);
  28. return (pcell->Size < 0) ? TRUE : FALSE;
  29. }
  30. LONG
  31. GetCellSize(
  32. HCELL_INDEX Cell
  33. )
  34. /*
  35. Routine Description:
  36. Retrieves the size of the specified cell.
  37. Arguments:
  38. Cell - supplies the cell index of the cell of interest.
  39. Return Value:
  40. The size of the cell.
  41. */
  42. {
  43. LONG size;
  44. PHCELL pcell;
  45. pcell = (PHCELL)(Base + Cell);
  46. size = pcell->Size * -1;
  47. return size;
  48. }
  49. VOID
  50. FreeCell(
  51. HCELL_INDEX Cell
  52. )
  53. /*
  54. Routine Description:
  55. Frees a cell.
  56. Arguments:
  57. Cell - supplies the cell index of the cell of interest.
  58. Return Value:
  59. NONE.
  60. */
  61. {
  62. PHCELL pcell;
  63. pcell = (PHCELL)(Base + Cell);
  64. pcell->Size *= -1;
  65. ASSERT(pcell->Size >= 0 );
  66. }
  67. VOID
  68. AllocateCell(
  69. HCELL_INDEX Cell
  70. )
  71. /*
  72. Routine Description:
  73. Allocates a cell, by ensuring a negative size on it
  74. Arguments:
  75. Cell - supplies the cell index of the cell of interest.
  76. Return Value:
  77. NONE.
  78. */
  79. {
  80. PHCELL pcell;
  81. pcell = (PHCELL)(Base + Cell);
  82. pcell->Size *= -1;
  83. ASSERT(pcell->Size < 0 );
  84. }
  85. PCELL_DATA
  86. GetCell(
  87. HCELL_INDEX Cell
  88. )
  89. /*
  90. Routine Description:
  91. Retrieves the memory address of the cell specified by Cell.
  92. Arguments:
  93. Cell - supplies the cell index of the cell of interest.
  94. Return Value:
  95. The memory address of Cell.
  96. */
  97. {
  98. PHCELL pcell;
  99. pcell = (PHCELL)(Base + Cell);
  100. return (struct _CELL_DATA *)&(pcell->u.NewCell.u.UserData);
  101. }