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.

251 lines
7.2 KiB

  1. /****************************************************************************
  2. Copyright information : Copyright (c) 1998-1999 Microsoft Corporation
  3. File Name : WMICommandLn.h
  4. Project Name : WMI Command Line
  5. Author Name : Ch.Sriramachandramurthy
  6. Date of Creation (dd/mm/yy) : 27th-September-2000
  7. Version Number : 1.0
  8. Brief Description : This file consist of class declaration of
  9. class CWMICommandLine
  10. Revision History :
  11. Last Modified By : Ch. Sriramachandramurthy
  12. Last Modified Date : 16th-January-2001
  13. ****************************************************************************/
  14. // WMICommandLine.h : header file
  15. //
  16. /*-------------------------------------------------------------------
  17. Class Name : CWMICommandLine
  18. Class Type : Concrete
  19. Brief Description : This class encapsulates the functionality needed
  20. for synchronization the funtionality of three
  21. functional components identified for the WmiCli.exe.
  22. Super Classes : None
  23. Sub Classes : None
  24. Classes Used : CParsedInfo
  25. CExecEngine
  26. CFormatEngine
  27. CParserEngine
  28. Interfaces Used : WMI COM Interfaces
  29. --------------------------------------------------------------------*/
  30. // forward declaration of classes
  31. class CParserEngine;
  32. class CExecEngine;
  33. class CFormatEngine;
  34. class CParsedInfo;
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CWMICommandLine
  37. class CWMICommandLine
  38. {
  39. public:
  40. // Construction
  41. CWMICommandLine();
  42. // Destruction
  43. ~CWMICommandLine();
  44. // Restrict Assignment
  45. CWMICommandLine& operator=(CWMICommandLine& rWmiCmdLn);
  46. // Attributes
  47. private:
  48. //Pointer to the locator object .
  49. IWbemLocator *m_pIWbemLocator;
  50. //CParserEngine object
  51. CParserEngine m_ParserEngine;
  52. //CExecEngine object
  53. CExecEngine m_ExecEngine;
  54. //CFormatEngine object
  55. CFormatEngine m_FormatEngine;
  56. //CParsedInfo object
  57. CParsedInfo m_ParsedInfo;
  58. // error level
  59. WMICLIUINT m_uErrLevel;
  60. // handle to registry key
  61. HKEY m_hKey;
  62. // handle Ctrl+ events
  63. BOOL m_bBreakEvent;
  64. // specifies accepting input (==TRUE) or executing command (==FALSE)
  65. BOOL m_bAccCmd;
  66. // << description to be added >>
  67. BOOL m_bDispRes;
  68. // Flag to specify windows socket interface initialization.
  69. BOOL m_bInitWinSock;
  70. // Buffer to hold data to be send to clipboard.
  71. CHString m_chsClipBoardBuffer;
  72. // added by (Nag)
  73. BSTRMAP m_bmKeyWordtoFileName;
  74. // Height of console buffer before starting utility.
  75. SHORT m_nHeight;
  76. // Width of console buffer before starting utility.
  77. SHORT m_nWidth;
  78. BOOL m_bCtrlHandlerError;
  79. // Checks whether mof files timestamps are the same as those which were mofcompiled.
  80. BOOL EqualTimeStamps( const _bstr_t& path, LPCWSTR mofs[], __int64* filestamps, DWORD dw_mofs );
  81. // Set mof files timestamps to registry when mofcompiled.
  82. BOOL SetTimeStamps( LPCWSTR mofs[], const __int64* filestamps, DWORD dw_mofs );
  83. // clean registry and namespace when update fails
  84. void MofCompFailureCleanUp ( LPCWSTR mofs[], DWORD dw_mofs );
  85. // Operations
  86. public:
  87. // Does the initialization ofthe COM library and the security
  88. // at the process level
  89. BOOL Initialize();
  90. //Gets the Format Engine Object
  91. CFormatEngine& GetFormatObject();
  92. //Gets the Parse Information Object
  93. CParsedInfo& GetParsedInfoObject();
  94. //Uninitializes the the member variables when the execution of a
  95. //command string issued on the command line is completed.
  96. void Uninitialize();
  97. //processes the given command string
  98. SESSIONRETCODE ProcessCommandAndDisplayResults(_TCHAR* pszBuffer);
  99. //Puts the process to a wait state, launches a worker thread
  100. //that keeps track of kbhit()
  101. void SleepTillTimeoutOrKBhit(DWORD dwMilliSeconds);
  102. //Thread procedure polling for keyboard hit
  103. static DWORD WINAPI PollForKBhit(LPVOID lpParam);
  104. //Function to check whether the input string's first token
  105. //is 'quit'|'exit', if so return true else return false.
  106. BOOL IsSessionEnd();
  107. //Set the session error value
  108. void SetSessionErrorLevel(SESSIONRETCODE ssnRetCode);
  109. //Get the session error value
  110. WMICLIUINT GetSessionErrorLevel();
  111. // This function check whether the /USER global switch
  112. // has been specified without /PASSWORD, if so prompts
  113. // for the password
  114. void CheckForPassword();
  115. // Checks whether the given namespace is available or not.
  116. BOOL IsNSAvailable(const _bstr_t& bstrNS);
  117. // Checks whether the wmic.exe is being launched for the first time.
  118. BOOL IsFirstTime();
  119. // Register the aliases info / localized descriptions
  120. HRESULT RegisterMofs();
  121. // Compile the MOF file.
  122. HRESULT CompileMOFFile(IMofCompiler* pIMofComp,
  123. const _bstr_t& bstrFile,
  124. WMICLIINT& nErr);
  125. // Set break event falg
  126. void SetBreakEvent(BOOL bFlag);
  127. // Get break event flag
  128. BOOL GetBreakEvent();
  129. // Set Accept Command flag
  130. void SetAcceptCommand(BOOL bFlag);
  131. // Get Accept Command flag
  132. BOOL GetAcceptCommand();
  133. // Set displayresults flag status
  134. void SetDisplayResultsFlag(BOOL bFlag);
  135. // Get DisplayResults flag status
  136. BOOL GetDisplayResultsFlag();
  137. // Set Windows sockect interface flag
  138. void SetInitWinSock(BOOL bFlag);
  139. // Get Windows sockect interface flag
  140. BOOL GetInitWinSock();
  141. // Buffer data to send clipboard.
  142. void AddToClipBoardBuffer(LPCWSTR pszOutput);
  143. // Get Buffered output in clip board buffer.
  144. CHString& GetClipBoardBuffer();
  145. // Clear Clip Board Buffer.
  146. void EmptyClipBoardBuffer();
  147. // Check if the file is xml or batch file. If it is batch file
  148. // then parse it, get commands and write the commands into
  149. // batch file and redirect the stdin to that file.
  150. BOOL ReadXMLOrBatchFile(HANDLE hInFile);
  151. // Frames the XML string for context info
  152. void FrameContextInfoFragment(_bstr_t& bstrContext);
  153. // Frames the XML header info
  154. void FrameNodeListFragment(_bstr_t& bstrNodeList);
  155. // Frames the XML string for Request info
  156. void FrameXMLHeader(_bstr_t& bstrHeader, WMICLIINT nIter);
  157. // Frames the XML string for NodeList info
  158. void FrameRequestNode(_bstr_t& bstrRequest);
  159. // Frames the XML string for commandline info
  160. void FrameCommandLineComponents(_bstr_t& bstrCommandComponent);
  161. // Frames the XML string for formats info
  162. void FrameFormats(_bstr_t& bstrFormats);
  163. // Frames the XML string for properties info
  164. void FramePropertiesInfo(_bstr_t& bstrProperties);
  165. // Gets the xslfile name corrsponding to the keyword passed
  166. // from the BSTRMAP
  167. BOOL GetFileFromKey(_bstr_t bstrkeyName, _bstr_t& bstrFileName);
  168. // Frames the BSTR Map contains the key words and
  169. // corresponding files from the XSL mapping file
  170. void GetFileNameMap();
  171. // Get the XSL file names for keywords
  172. void GetXSLMappings(_TCHAR *pszFilePath);
  173. // This function returns a reference to the token vector
  174. CHARVECTOR& GetTokenVector();
  175. inline BOOL GetCtrlHandlerError() { return m_bCtrlHandlerError; };
  176. inline void SetCtrlHandlerError(BOOL bFlag) { m_bCtrlHandlerError = bFlag; };
  177. // sets/resets screen buffer
  178. BOOL ScreenBuffer ( BOOL bSet = TRUE );
  179. // return mappings
  180. const BSTRMAP* GetMappingsMap () const
  181. {
  182. return &m_bmKeyWordtoFileName;
  183. };
  184. };