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.

219 lines
7.4 KiB

  1. /****************************************************************************
  2. Copyright information : Copyright (c) 1998-1999 Microsoft Corporation
  3. File Name : ExecEngine.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 member variable and
  9. functions declarations of the Execution engine
  10. module.
  11. Revision History :
  12. Last Modified By : Ch. Sriramachandramurthy
  13. Last Modified Date : 20th-March-2001
  14. ****************************************************************************/
  15. /*-------------------------------------------------------------------
  16. Class Name : CExecEngine
  17. Class Type : Concrete
  18. Brief Description : This class encapsulates the functionality needed
  19. for executing the WMI statements that are obtained
  20. as a result of parsing engine. It also performs
  21. verb specific processing using the information
  22. available with CParsedInfo class.
  23. Super Classes : None
  24. Sub Classes : None
  25. Classes Used : CParsedInfo
  26. Interfaces Used : WMI COM Interfaces
  27. --------------------------------------------------------------------*/
  28. class CParsedInfo;
  29. class CExecEngine
  30. {
  31. public:
  32. // Construction
  33. CExecEngine();
  34. // Destruction
  35. ~CExecEngine();
  36. // Restrict Assignment
  37. CExecEngine& operator=(CExecEngine& rExecEngine);
  38. // Attributes
  39. private:
  40. // trace flag
  41. BOOL m_bTrace;
  42. ERRLOGOPT m_eloErrLogOpt;
  43. // Pointer to object of type IWbemObjectTextSrc encapsulates the
  44. // functionality of WMI XML Encoder
  45. IWbemObjectTextSrc *m_pITextSrc;
  46. // Pointer to object of type IWbemLocator, used to obtain IWbemServices
  47. // object.
  48. IWbemLocator *m_pIWbemLocator;
  49. // Pointer to object of type IWbemServices, Used to perform WMI operations
  50. // on target namespace.
  51. IWbemServices *m_pITargetNS;
  52. // Context pointer
  53. IWbemContext *m_pIContext;
  54. BOOL m_bSysProp;
  55. BOOL m_bNoAssoc;
  56. // Operations
  57. private:
  58. // Creates the instance of IWbemObjectTextSrc interface.
  59. HRESULT CreateWMIXMLTextSrc(CParsedInfo& rParsedInfo);
  60. // Creates the instance of IWbemContext interface
  61. HRESULT CreateContext(CParsedInfo& rPrasedInfo);
  62. // Connect to the WMI namespace on the target machine.
  63. HRESULT ConnectToTargetNS(CParsedInfo& rParsedInfo);
  64. // Executes query to give results in XML file format.
  65. // Refers data in the CCommnadSwicthes object of CParsedInfo object.
  66. HRESULT ObtainXMLResultSet(BSTR bstrQuery,
  67. CParsedInfo& rParsedInfo,
  68. _bstr_t& bstrXML,
  69. BOOL bSysProp = TRUE,
  70. BOOL bNotAssoc = TRUE);
  71. HRESULT FrameAssocHeader(_bstr_t bstrPath, _bstr_t& bstrFrag,
  72. BOOL bClass);
  73. // This function changes the property value for the
  74. // given property name and value
  75. BOOL SetPropertyInfo(CParsedInfo& rParsedInfo,
  76. _bstr_t& bstrQuery,
  77. _bstr_t& bstrObject);
  78. // Executes a WMI method specified in the CCommandSwicthes
  79. // object of the CParsedInfo object passed to it.
  80. BOOL ExecWMIMethod(CParsedInfo&);
  81. // Processes and executes GET|LIST verb referring CParsedInfo object
  82. // or to display help in interactive mode by displaying properties of
  83. // concernrd instance.
  84. BOOL ProcessSHOWInfo(CParsedInfo& rParsedInfo, BOOL bVerb=TRUE,
  85. _TCHAR* pszPath=NULL);
  86. // Processes and executes CALL verb referring CParsedInfo object.
  87. BOOL ProcessCALLVerb(CParsedInfo& rParsedInfo);
  88. // Processes and executes SET verb referring CParsedInfo object.
  89. BOOL ProcessSETVerb(CParsedInfo& rParsedInfo);
  90. // Processes and executes CREATE verb referring CParsedInfo object.
  91. BOOL ProcessCREATEVerb(CParsedInfo& rParsedInfo);
  92. // Processes and executes DELETE verb referring CParsedInfo object.
  93. BOOL ProcessDELETEVerb(CParsedInfo& rParsedInfo);
  94. // Processes and executes ASSOC verb referring CParsedInfo object.
  95. BOOL ProcessASSOCVerb(CParsedInfo& rParsedInfo);
  96. // This function constructs the path expression from alias info and
  97. // where info. Used for CALL verb only
  98. BOOL FormPathExprFromWhereExpr(_bstr_t& bstrPath,
  99. CParsedInfo& rParsedInfo);
  100. // This function changes the property values for the given property names
  101. // and values in a passed IWbemClassObject
  102. BOOL SetProperties(CParsedInfo& rParsedInfo,
  103. IWbemClassObject* pIWbemObj,
  104. BOOL bClass);
  105. // Deletes the objects
  106. BOOL DeleteObjects(CParsedInfo& rParsedInfo,
  107. _bstr_t& bstrQuery,
  108. _bstr_t& bstrObject);
  109. // Obtain user response
  110. INTEROPTION GetUserResponse(_TCHAR* pszMsg);
  111. // Create a new instance
  112. BOOL CreateInstance(CParsedInfo& rParsedInfo,
  113. BSTR bstrClass);
  114. // Validate the new input values supplied for the properties
  115. // against the qualifiers details.
  116. BOOL ValidateInParams(CParsedInfo& rParsedInfo,
  117. _bstr_t bstrClass);
  118. BOOL ValidateAlaisInParams(CParsedInfo& rParsedInfo);
  119. BOOL CheckAliasQualifierInfo(CParsedInfo& rParsedInfo,
  120. _bstr_t bstrParam,
  121. WCHAR*& pszValue,
  122. PROPDETMAP pdmPropDetMap);
  123. // Checks the parameter/property value against the following
  124. // qualifiers:
  125. // 1. MaxLen, 2. Values 3. ValuesMap
  126. BOOL CheckQualifierInfo(CParsedInfo& rParsedInfo,
  127. IWbemClassObject* pIObject,
  128. _bstr_t bstrParam,
  129. WCHAR*& pszValue);
  130. // Method Execution
  131. HRESULT ExecuteMethodAndDisplayResults(_bstr_t bstrPath,
  132. CParsedInfo& rParsedinfo,
  133. IWbemClassObject* pIInParam);
  134. // Display the output parameters of method execution.
  135. void DisplayMethExecOutput(CParsedInfo& rParsedInfo);
  136. // Invoke other command line Utilities
  137. BOOL ExecOtherCmdLineUtlty(CParsedInfo& rParsedInfo);
  138. // Checks and returns TRUE if verb invocation mode is interactive
  139. BOOL IsInteractive(CParsedInfo& rParsedInfo);
  140. // Substitute hashes and execute command line utility.
  141. // If pIWbemObj != NULL then utility should be passed with appropriate
  142. // instance values.
  143. void SubstHashAndExecCmdUtility(CParsedInfo& rParsedInfo,
  144. IWbemClassObject *pIWbemObj = NULL);
  145. // Forms query and executes method or command line utility.
  146. HRESULT FormQueryAndExecuteMethodOrUtility(
  147. CParsedInfo& rParsedInfo,
  148. IWbemClassObject *pIInParam = NULL);
  149. // This function takes the input as a path expression and
  150. // extracts the Class and Where expression part from the
  151. // path expression.
  152. BOOL ExtractClassNameandWhereExpr(_TCHAR* pszPathExpr,
  153. CParsedInfo& rParsedInfo,
  154. _TCHAR* pszWhere);
  155. // This function accepts the user response before going
  156. // ahead, when /INTERACTIVE is specified at the verb level
  157. INTEROPTION GetUserResponseEx(_TCHAR* pszMsg);
  158. // Obtain param values from parameter map in the same order as they
  159. // appear in the alias verb definition.
  160. void ObtainInParamsFromParameterMap(CParsedInfo& rParsedinfo,
  161. CHARVECTOR& cvParamValues);
  162. public:
  163. // This function uninitializes the member variables.
  164. void Uninitialize(BOOL bFlag = FALSE);
  165. // Executes the command referring to CCommandSwitches and CGlobalSwitches
  166. // of the CParsedInfo object of CParsedInfo object Passed to it as
  167. // parameters. Puts the results back in to objects passed to it for the
  168. // use of Format Engine.
  169. BOOL ExecuteCommand(CParsedInfo& rParsedInfo);
  170. // Sets the locator object passed via parameter to member
  171. // of the class.
  172. BOOL SetLocatorObject(IWbemLocator* pILocator);
  173. };