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.

86 lines
4.1 KiB

  1. // --------------------------------------------------------------------------
  2. // Module Name: BadApplicationManager.h
  3. //
  4. // Copyright (c) 2000, Microsoft Corporation
  5. //
  6. // Classes to manage bad applications in the fast user switching environment.
  7. //
  8. // History: 2000-08-25 vtan created
  9. // --------------------------------------------------------------------------
  10. #ifndef _BadApplicationManager_
  11. #define _BadApplicationManager_
  12. #include <lpcfus.h>
  13. #include "BadApplication.h"
  14. #include "DynamicArray.h"
  15. #include "KernelResources.h"
  16. #include "Thread.h"
  17. // --------------------------------------------------------------------------
  18. // CBadApplicationManager
  19. //
  20. // Purpose: Implements managing of bad applications started on this
  21. // machine. This object should only exist once.
  22. //
  23. // History: 2000-08-25 vtan created
  24. // --------------------------------------------------------------------------
  25. class CBadApplicationManager : public CThread
  26. {
  27. private:
  28. typedef struct
  29. {
  30. HANDLE hProcess;
  31. BAM_TYPE bamType;
  32. DWORD dwSessionID;
  33. CBadApplication badApplication;
  34. } BAD_APPLICATION_INFO, *PBAD_APPLICATION_INFO;
  35. public:
  36. CBadApplicationManager (HINSTANCE hInstance);
  37. virtual ~CBadApplicationManager (void);
  38. NTSTATUS Terminate (void);
  39. bool QueryRunning (const CBadApplication& badApplication, DWORD dwSessionID);
  40. NTSTATUS RegisterRunning (const CBadApplication& badApplication, HANDLE hProcess, BAM_TYPE bamType);
  41. NTSTATUS QueryInformation (const CBadApplication& badApplication, HANDLE& hProcess);
  42. NTSTATUS RequestSwitchUser (void);
  43. static NTSTATUS PerformTermination (HANDLE hProcess, bool fAllowForceTerminate);
  44. protected:
  45. virtual DWORD Entry (void);
  46. private:
  47. static NTSTATUS TerminateForcibly (HANDLE hProcess);
  48. static NTSTATUS TerminateGracefully (HANDLE hProcess);
  49. void Cleanup (void);
  50. void Handle_Logon (void);
  51. void Handle_Logoff (DWORD dwSessionID);
  52. void Handle_Connect (DWORD dwSessionID, HANDLE hToken);
  53. void Handle_Disconnect (DWORD dwSessionID, HANDLE hToken);
  54. LRESULT Handle_WM_WTSSESSION_CHANGE (WPARAM wParam, LPARAM lParam);
  55. static LRESULT CALLBACK NotificationWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  56. static DWORD WINAPI RegisterThreadProc (void *pParameter);
  57. private:
  58. HINSTANCE _hInstance;
  59. HMODULE _hModule;
  60. ATOM _atom;
  61. HWND _hwnd;
  62. bool _fTerminateWatcherThread,
  63. _fRegisteredNotification;
  64. DWORD _dwSessionIDLastConnect;
  65. HANDLE _hTokenLastUser;
  66. CCriticalSection _lock;
  67. CEvent _hEvent;
  68. CDynamicArray _badApplications;
  69. CDynamicCountedObjectArray _restoreApplications;
  70. static const int INDEX_EVENT;
  71. static const int INDEX_HANDLES;
  72. static const int INDEX_RESERVED;
  73. static const WCHAR s_szDefaultDesktop[];
  74. };
  75. #endif /* _BadApplicationManager_ */