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.

129 lines
2.2 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. All rights reserved
  4. Module Name:
  5. lsaapi.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 "lsaapi.hxx"
  17. TLSA_API::TLSA_API(IN ULONG64 baseOffset)
  18. : TLSAP_LOOKUP_PACKAGE_ARGS(baseOffset),
  19. m_baseOffset(baseOffset), m_hr(E_FAIL)
  20. {
  21. m_hr = Initialize();
  22. }
  23. TLSA_API::TLSA_API(void) : m_hr(E_FAIL)
  24. {
  25. }
  26. TLSA_API::~TLSA_API(void)
  27. {
  28. }
  29. HRESULT TLSA_API::IsValid(void) const
  30. {
  31. return m_hr;
  32. }
  33. ULONG64 TLSA_API::GetLogonUser(void) const
  34. {
  35. return m_baseOffset;
  36. }
  37. ULONG64 TLSA_API::GetCallPackage(void) const
  38. {
  39. return m_baseOffset;
  40. }
  41. ULONG64 TLSA_API::GetLsaApiBase(void) const
  42. {
  43. return m_baseOffset;
  44. }
  45. #ifndef TOKEN_SOURCE_LENGTH
  46. #define TOKEN_SOURCE_LENGTH 8
  47. #endif
  48. PCSTR TLSA_API::GetSourceContextSourceName(void) const
  49. {
  50. static ULONG fieldOffset = ReadFieldOffset("_LSAP_LOGON_USER_ARGS", "SourceContext.SourceName");
  51. static CHAR szBuffer[TOKEN_SOURCE_LENGTH + 1] = {0};
  52. if (!ReadMemory(m_baseOffset + fieldOffset,
  53. szBuffer,
  54. TOKEN_SOURCE_LENGTH,
  55. NULL)) {
  56. throw "Read LogonUserArgs SourceContext.SourceName failed";
  57. }
  58. return szBuffer;
  59. }
  60. /******************************************************************************
  61. Private Methods
  62. ******************************************************************************/
  63. /*++
  64. Routine Name:
  65. Initialize
  66. Routine Description:
  67. Do necessary initialization.
  68. Arguments:
  69. None
  70. Return Value:
  71. An HRESULT
  72. --*/
  73. HRESULT TLSA_API::Initialize(void)
  74. {
  75. HRESULT hRetval = E_FAIL;
  76. hRetval = S_OK;
  77. return hRetval;
  78. }
  79. HRESULT TLSA_API::Initialize(IN ULONG64 baseOffset)
  80. {
  81. m_baseOffset = baseOffset;
  82. m_hr = TLSAP_LOOKUP_PACKAGE_ARGS::Initialize(baseOffset);
  83. if (SUCCEEDED(m_hr)) {
  84. m_hr = Initialize();
  85. }
  86. return m_hr;
  87. }