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.

116 lines
3.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1996.
  5. //
  6. // File: window.cxx
  7. //
  8. // Contents: local functions
  9. //
  10. // History: 8/94 davemont Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #include <aclpch.hxx>
  14. #pragma hdrstop
  15. //+---------------------------------------------------------------------------
  16. //
  17. // Function: ReadWindowPropertyRights
  18. //
  19. // Synopsis: Gets the specified security info from the specified handle's
  20. // window
  21. //
  22. // Arguments: [IN hWindow] -- Handle to the open window to
  23. // read the info on
  24. // [IN pRightsList] -- SecurityInfo to read based
  25. // on properties
  26. // [IN cRights] -- Number of items in rights list
  27. // [IN AccessList] -- Access List to fill in
  28. //
  29. // Returns: ERROR_SUCCESS -- Success
  30. // ERROR_INVALID_PARAMETER -- A bad property was encountered
  31. // ERROR_NOT_ENOUGH_MEMORY -- A memory allocation failed
  32. //
  33. //----------------------------------------------------------------------------
  34. DWORD
  35. ReadWindowPropertyRights(IN HANDLE hWindow,
  36. IN PACTRL_RIGHTS_INFO pRightsList,
  37. IN ULONG cRights,
  38. IN CAccessList& AccessList)
  39. {
  40. acDebugOut((DEB_TRACE, "In ReadWindowPropertyRights\n"));
  41. //
  42. // For the moment, there is only service property itself...
  43. //
  44. ASSERT(cRights == 1 && pRightsList[0].pwszProperty == NULL);
  45. if(cRights != 1 || pRightsList[0].pwszProperty != NULL)
  46. {
  47. return(ERROR_INVALID_PARAMETER);
  48. }
  49. UCHAR SDBuff[PSD_BASE_LENGTH];
  50. PISECURITY_DESCRIPTOR pSD = (PISECURITY_DESCRIPTOR)SDBuff;
  51. DWORD dwErr = ERROR_SUCCESS;
  52. ULONG cSize = 0;
  53. //
  54. // Get the security descriptor
  55. //
  56. if(GetUserObjectSecurity(hWindow,
  57. &(pRightsList[0].SeInfo),
  58. pSD,
  59. PSD_BASE_LENGTH,
  60. &cSize) == FALSE)
  61. {
  62. dwErr = GetLastError();
  63. if(dwErr == ERROR_INSUFFICIENT_BUFFER)
  64. {
  65. pSD = (PISECURITY_DESCRIPTOR)AccAlloc(cSize);
  66. if(pSD == NULL)
  67. {
  68. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  69. }
  70. else
  71. {
  72. dwErr = ERROR_SUCCESS;
  73. //
  74. // Let's read it again
  75. //
  76. if(GetUserObjectSecurity(hWindow,
  77. &(pRightsList[0].SeInfo),
  78. pSD,
  79. cSize,
  80. &cSize) == FALSE)
  81. {
  82. dwErr = GetLastError();
  83. }
  84. }
  85. }
  86. }
  87. if(dwErr == ERROR_SUCCESS)
  88. {
  89. //
  90. // Add it
  91. //
  92. dwErr = AccessList.AddSD(pSD,
  93. pRightsList->SeInfo,
  94. pRightsList->pwszProperty);
  95. }
  96. //
  97. // Free our buffer, if necessary
  98. //
  99. if(cSize > PSD_BASE_LENGTH)
  100. {
  101. AccFree(pSD);
  102. }
  103. acDebugOut((DEB_TRACE, "Out ReadWindowPropertyRights: %lu\n", dwErr));
  104. return(dwErr);
  105. }