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.

77 lines
1.7 KiB

  1. #pragma once
  2. #include "mischlpr.h"
  3. #include <winsta.h>
  4. // In between _CoGetCallingUserHKCU and _CoCloseCallingUserHKCU
  5. // we impersonate the calling user
  6. // phThreadToken is out only
  7. HRESULT _CoGetCallingUserHKCU(HANDLE* phThreadToken, HKEY* phkey);
  8. HRESULT _CoCloseCallingUserHKCU(HANDLE hThreadToken, HKEY hkey);
  9. HRESULT _GetCurrentUserHKCU(HANDLE* phThreadToken, HKEY* phkey);
  10. HRESULT _CloseCurrentUserHKCU(HANDLE hThreadToken, HKEY hkey);
  11. HRESULT _CoCreateInstanceInConsoleSession(REFCLSID rclsid,
  12. IUnknown* punkOuter, DWORD dwClsContext, REFIID riid, void** ppv);
  13. HRESULT _GiveAllowForegroundToConsoleShell();
  14. class CImpersonateBase
  15. {
  16. public:
  17. virtual HRESULT Impersonate() = 0;
  18. virtual HRESULT RevertToSelf() = 0;
  19. };
  20. class CImpersonateTokenBased : public CImpersonateBase
  21. {
  22. public:
  23. CImpersonateTokenBased();
  24. virtual ~CImpersonateTokenBased();
  25. public:
  26. HRESULT Impersonate();
  27. HRESULT RevertToSelf();
  28. protected:
  29. virtual HRESULT _GetToken(HANDLE* phToken) = 0;
  30. private:
  31. HRESULT _RevertToSelf();
  32. private:
  33. HANDLE _hToken;
  34. };
  35. class CImpersonateConsoleSessionUser : public CImpersonateTokenBased
  36. {
  37. protected:
  38. HRESULT _GetToken(HANDLE* phToken);
  39. };
  40. class CImpersonateEveryone : public CImpersonateTokenBased, public CRefCounted
  41. {
  42. protected:
  43. HRESULT _GetToken(HANDLE* phToken);
  44. };
  45. class CImpersonateCOMCaller : public CImpersonateBase
  46. {
  47. public:
  48. CImpersonateCOMCaller();
  49. ~CImpersonateCOMCaller();
  50. public:
  51. HRESULT Impersonate();
  52. HRESULT RevertToSelf();
  53. private:
  54. HRESULT _RevertToSelf();
  55. private:
  56. BOOL _fImpersonating;
  57. };