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.

136 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. adlconvert.h
  5. Abstract:
  6. The private header file for the ADL conversion routines
  7. Author:
  8. t-eugenz - August 2000
  9. Environment:
  10. User mode only.
  11. Revision History:
  12. Created - August 2000
  13. --*/
  14. #pragma once
  15. //
  16. // Weights for the weight function to determine the optimal pops
  17. // These weights can be modified to change the behavior of the conversion.
  18. // The algorithm selects an action by trying to maximize the weight of the
  19. // action. For more flexibility (such as squaring some quentities, etc),
  20. // the algorithm itself should be changed in FindOptimalPop()
  21. //
  22. // RESTRICTION: The weight of popping a block of any height off a single stack
  23. // MUST be positive
  24. //
  25. //
  26. // This quantity is added to the weight of the action for every additional
  27. // permission bit expressed by the ADL statement created by this action.
  28. //
  29. #define WEIGHT_PERM_BIT (4)
  30. //
  31. // This quantity is added to the weight of the action for every additional
  32. // Principal expressed by the ADL statement created by this action.
  33. //
  34. #define WEIGHT_STACK_HEIGHT (7)
  35. //
  36. // This quantity is added to the weight of the action for every item which
  37. // will have to be popped off in order to take this action. See the algorithm
  38. // description in adlconvert.cpp for more details.
  39. //
  40. #define WEIGHT_ITEM_ABOVE_POP (-5)
  41. //
  42. // This quantity is added for every permission name beyond the first needed
  43. // to express a given access mask. This should be a penalty, however for
  44. // better results this should NOT negate the bonus from WEIGHT_PERM_BIT.
  45. // Therefore, if this is negative, it should be greater than (- WEIGHT_PERM_BIT)
  46. //
  47. #define WEIGHT_PERMISSION_NAME (-1)
  48. //
  49. // The stacks in the DACL->ADL conversion consist of these elements
  50. //
  51. typedef struct
  52. {
  53. PSID pSid;
  54. DWORD dwFlags;
  55. BOOL bAllow;
  56. } BIT_STACK_ELEM, *PBIT_STACK_ELEM;
  57. //
  58. // Forward declarations for DACL->ADL conversion
  59. //
  60. DWORD GetStackBlockSize(
  61. IN const PBIT_STACK_ELEM pStack,
  62. IN DWORD dwStartOffset,
  63. IN DWORD dwStackSize
  64. );
  65. void ConvertDaclToStacks(
  66. IN const PACL pDacl,
  67. IN const PADL_PARSER_CONTROL pControl,
  68. OUT DWORD pdwStackSize[32],
  69. OUT PBIT_STACK_ELEM pStacks[32]
  70. );
  71. BOOL FindBlockInStack(
  72. IN const PBIT_STACK_ELEM pBlock,
  73. IN const DWORD dwBlockSize,
  74. IN const PBIT_STACK_ELEM pStack,
  75. IN const DWORD dwStackSize,
  76. IN const DWORD dwStackTop,
  77. OUT PDWORD pdwBlockStart
  78. );
  79. BOOL FindOptimalPop(
  80. IN const PADL_PARSER_CONTROL pControl,
  81. IN const PBIT_STACK_ELEM pStacks[32],
  82. IN const DWORD pdwStackSize[32],
  83. IN const DWORD pdwStackTop[32],
  84. OUT PDWORD pdwStacksPopped,
  85. OUT PDWORD pdwBlockSize,
  86. OUT DWORD pdwPopOffsets[32]
  87. );
  88. void ConvertStacksToPops(
  89. IN const PADL_PARSER_CONTROL pControl,
  90. IN const PBIT_STACK_ELEM pStacks[32],
  91. IN const DWORD pdwStackSize[32],
  92. IN const DWORD pdwStackTop[32],
  93. OUT list< pair<DWORD, DWORD> > * pListPops
  94. );
  95. DWORD NumStringsForMask(
  96. IN const PADL_PARSER_CONTROL pControl,
  97. IN ACCESS_MASK amMask
  98. );