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.

138 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. All rights reserved
  4. Module Name:
  5. lsasa.cxx
  6. Abstract:
  7. This file provides useful accssors and mutators.
  8. Author:
  9. Larry Zhu (LZhu) May 1, 2001 Created
  10. Environment:
  11. User Mode -Win32
  12. Revision History:
  13. --*/
  14. #include "precomp.hxx"
  15. #pragma hdrstop
  16. #include "lsasa.hxx"
  17. TSID_AND_ATTRIBUTES::TSID_AND_ATTRIBUTES(void) : m_hr(E_FAIL)
  18. {
  19. }
  20. TSID_AND_ATTRIBUTES::TSID_AND_ATTRIBUTES(IN ULONG64 baseOffset)
  21. : m_baseOffset(baseOffset), m_hr(E_FAIL)
  22. {
  23. m_hr = Initialize();
  24. }
  25. TSID_AND_ATTRIBUTES::~TSID_AND_ATTRIBUTES(void)
  26. {
  27. }
  28. HRESULT TSID_AND_ATTRIBUTES::IsValid(void) const
  29. {
  30. return m_hr;
  31. }
  32. ULONG TSID_AND_ATTRIBUTES::GetcbSID_AND_ATTRIBUTESInArray(void)
  33. {
  34. static ULONG cbSA = ReadTypeSize("nt!_SID_AND_ATTRIBUTES[1]");
  35. static ULONG cbSA2 = ReadTypeSize("nt!_SID_AND_ATTRIBUTES[2]");
  36. return cbSA2 - cbSA;
  37. }
  38. ULONG TSID_AND_ATTRIBUTES::GetcbSID_AND_ATTRIBUTESInArrayDirect(void)
  39. {
  40. static ULONG cbSize = max(ReadPtrSize() + sizeof(ULONG), 2 * ReadPtrSize());
  41. return cbSize;
  42. }
  43. ULONG64 TSID_AND_ATTRIBUTES::GetSidAddrDirect(void) const
  44. {
  45. return m_baseOffset;
  46. }
  47. ULONG64 TSID_AND_ATTRIBUTES::GetSidAddr(void) const
  48. {
  49. return ReadStructPtrField(m_baseOffset, kstrSA, "Sid");
  50. }
  51. ULONG TSID_AND_ATTRIBUTES::GetAttributes(void) const
  52. {
  53. ULONG value = 0;
  54. ReadStructField(m_baseOffset, kstrSA, "Attributes", sizeof(value), &value);
  55. return value;
  56. }
  57. ULONG TSID_AND_ATTRIBUTES::GetAttributesDirect(void) const
  58. {
  59. ULONG value = 0;
  60. if (!ReadMemory(m_baseOffset + ReadPtrSize(), &value, sizeof(value), NULL)) {
  61. DBG_LOG(LSA_ERROR, ("unable to read Attributes for SID_AND_ATTRIBUTES at %#I64x\n", m_baseOffset));
  62. throw "TSID_AND_ATTRIBUTES::GetAttributesDirect failed";
  63. }
  64. return value;
  65. }
  66. /******************************************************************************
  67. Private Methods
  68. ******************************************************************************/
  69. /*++
  70. Routine Name:
  71. Initialize
  72. Routine Description:
  73. Do necessary initialization.
  74. Arguments:
  75. None
  76. Return Value:
  77. An HRESULT
  78. --*/
  79. HRESULT TSID_AND_ATTRIBUTES::Initialize(void)
  80. {
  81. HRESULT hRetval = E_FAIL;
  82. hRetval = S_OK;
  83. return hRetval;
  84. }
  85. HRESULT TSID_AND_ATTRIBUTES::Initialize(IN ULONG64 baseOffset)
  86. {
  87. m_baseOffset = baseOffset;
  88. m_hr = Initialize();
  89. return m_hr;
  90. }