Source code of Windows XP (NT5)
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.

150 lines
4.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995
  5. //
  6. // File: hostobj.h
  7. //
  8. // Contents: Contains the main application object
  9. //
  10. //----------------------------------------------------------------------------
  11. //****************************************************************************
  12. //
  13. // Forward declarations
  14. //
  15. //****************************************************************************
  16. class CScriptHost;
  17. class CMachine;
  18. class CProcessThread;
  19. class CStatusDialog;
  20. //****************************************************************************
  21. //
  22. // Classes
  23. //
  24. //****************************************************************************
  25. //+---------------------------------------------------------------------------
  26. //
  27. // Class: CMTScript (cmt)
  28. //
  29. // Purpose: Class which runs the main thread for the process.
  30. //
  31. //----------------------------------------------------------------------------
  32. #define MAX_STATUS_VALUES 16 // Maximum allowed StatusValue values.
  33. class CMTScript : public CThreadComm
  34. {
  35. friend int PASCAL WinMain(HINSTANCE hInstance,
  36. HINSTANCE hPrevInstance,
  37. LPSTR lpCmdLine,
  38. int nCmdShow);
  39. friend LRESULT CALLBACK
  40. MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  41. friend class CConfig;
  42. public:
  43. CMTScript();
  44. ~CMTScript();
  45. DECLARE_STANDARD_IUNKNOWN(CMTScript);
  46. // Script Debugging helpers
  47. IProcessDebugManager * _pPDM;
  48. IDebugApplication * _pDA;
  49. DWORD _dwAppCookie;
  50. CScriptHost *GetPrimaryScript();
  51. CProcessThread *GetProcess(int index);
  52. BOOL GetScriptNames(TCHAR *pchBuffer, long *pcBuffer);
  53. // These methods are thread safe.
  54. HRESULT AddProcess(CProcessThread *pProc);
  55. CProcessThread * FindProcess(DWORD dwProcId);
  56. HRESULT get_StatusValue(long nIndex, long *pnStatus);
  57. HRESULT put_StatusValue(long nIndex, long nStatus);
  58. // Hack function to work around JSCRIPT.DLL bug
  59. HRESULT HackCreateInstance(REFCLSID, IUnknown *, DWORD, REFIID, LPVOID*);
  60. BOOL SetScriptPath(const TCHAR *pszScriptPath, const TCHAR *pszInitScript);
  61. BOOL _fHackVersionChecked;
  62. IClassFactory * _pJScriptFactory;
  63. HRESULT RunScript(LPWSTR bstrPath, VARIANT *pvarParams);
  64. protected:
  65. virtual BOOL Init();
  66. virtual DWORD ThreadMain();
  67. void InitScriptDebugger();
  68. void DeInitScriptDebugger();
  69. BOOL ConfigureUI();
  70. void CleanupUI();
  71. HRESULT LoadTypeLibraries();
  72. void ShowMenu(int x, int y);
  73. void Reboot();
  74. void Restart();
  75. void OpenStatusDialog();
  76. void HandleThreadMessage();
  77. HRESULT UpdateOptionSettings(BOOL fSave);
  78. void CleanupOldProcesses();
  79. private:
  80. BOOL _fInDestructor;
  81. BOOL _fRestarting;
  82. HWND _hwnd;
  83. CStatusDialog *_pStatusDialog;
  84. public:
  85. struct OPTIONSETTINGS : public CThreadLock
  86. {
  87. OPTIONSETTINGS();
  88. static void GetModulePath(CStr *pstr);
  89. void GetScriptPath(CStr *cstrPage); // internally does a LOCK_LOCALS
  90. void GetInitScript(CStr *cstr); // internally does a LOCK_LOCALS
  91. CStr cstrScriptPath;
  92. CStr cstrInitScript;
  93. };
  94. ITypeLib * _pTypeLibEXE;
  95. ITypeInfo * _pTIMachine;
  96. IGlobalInterfaceTable * _pGIT;
  97. // _rgnStatusValues: Simple array of status values -- Multithreaded access, but no locking necessary
  98. long _rgnStatusValues[MAX_STATUS_VALUES];
  99. // ***************************
  100. // THREAD-SAFE MEMBER DATA
  101. // All access to the following members must be protected by LOCK_LOCALS()
  102. // or InterlockedXXX.
  103. //
  104. OPTIONSETTINGS _options;
  105. CMachine* _pMachine;
  106. VARIANT _vPublicData;
  107. VARIANT _vPrivateData;
  108. DWORD _dwPublicDataCookie;
  109. DWORD _dwPrivateDataCookie;
  110. DWORD _dwPublicSerialNum;
  111. DWORD _dwPrivateSerialNum;
  112. CStackPtrAry<CScriptHost*, 10> _aryScripts;
  113. CStackPtrAry<CProcessThread*, 10> _aryProcesses;
  114. };