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.

666 lines
17 KiB

  1. #if !defined __PCH_H
  2. #define __PCH_H
  3. #define SECURITY_WIN32 1
  4. // The debugger can't handle symbols more than 255 characters long.
  5. // STL often creates symbols longer than that.
  6. // When symbols are longer than 255 characters, the warning is issued.
  7. #pragma warning(disable:4786)
  8. //////////////////////////////////////////////////////////////////////
  9. // HEADER INCLUDES //
  10. //////////////////////////////////////////////////////////////////////
  11. #include "resource.h"
  12. #include <windows.h>
  13. #include <vector>
  14. #include <map>
  15. #include <tchar.h>
  16. #include <comdef.h>
  17. #include <wbemidl.h>
  18. #include <iostream>
  19. #include <msxml2.h>
  20. #include <lmcons.h>
  21. #include <conio.h>
  22. #include <math.h>
  23. #include <chstring.h>
  24. #include <shlwapi.h>
  25. #include <winsock2.h>
  26. #include <security.h>
  27. #include <Provexce.h>
  28. using namespace std;
  29. class CParsedInfo;
  30. class CWMICommandLine;
  31. extern CWMICommandLine g_wmiCmd;
  32. #ifdef _WIN64
  33. typedef __int64 WMICLIINT;
  34. #else
  35. typedef int WMICLIINT;
  36. #endif
  37. #ifdef _WIN64
  38. typedef UINT_PTR WMICLIUINT;
  39. #else
  40. typedef UINT WMICLIUINT;
  41. #endif
  42. #ifdef _WIN64
  43. typedef DWORD_PTR WMICLIULONG;
  44. #else
  45. typedef ULONG WMICLIULONG;
  46. #endif
  47. //////////////////////////////////////////////////////////////////////
  48. // USER DEFINED CONSTANTS //
  49. //////////////////////////////////////////////////////////////////////
  50. #define MAX_BUFFER 4095
  51. #define BUFFER32 32
  52. #define BUFFER64 64
  53. #define BUFFER512 512
  54. #define BUFFER255 255
  55. #define BUFFER1024 1024
  56. #define CLI_ROLE_DEFAULT _T("root\\cli")
  57. #define CLI_NAMESPACE_DEFAULT _T("root\\cimv2")
  58. #define CLI_LOCALE_DEFAULT _T("ms_409")
  59. #define CLI_TOKEN_W _T("W")
  60. #define CLI_TOKEN_CLASS _T("CLASS")
  61. #define CLI_TOKEN_PATH _T("PATH")
  62. #define CLI_TOKEN_WHERE _T("WHERE")
  63. #define CLI_TOKEN_EXIT _T("EXIT")
  64. #define CLI_TOKEN_RESTORE _T("RESTORE")
  65. #define CLI_TOKEN_QUIT _T("QUIT")
  66. #define CLI_TOKEN_CONTEXT _T("CONTEXT")
  67. #define CLI_TOKEN_GET _T("GET")
  68. #define CLI_TOKEN_LIST _T("LIST")
  69. #define CLI_TOKEN_SET _T("SET")
  70. #define CLI_TOKEN_DUMP _T("DUMP")
  71. #define CLI_TOKEN_CALL _T("CALL")
  72. #define CLI_TOKEN_ASSOC _T("ASSOC")
  73. #define CLI_TOKEN_CREATE _T("CREATE")
  74. #define CLI_TOKEN_DELETE _T("DELETE")
  75. #define CLI_TOKEN_HELP _T("?")
  76. #define CLI_TOKEN_NAMESPACE _T("NAMESPACE")
  77. #define CLI_TOKEN_ROLE _T("ROLE")
  78. #define CLI_TOKEN_NODE _T("NODE")
  79. #define CLI_TOKEN_IMPLEVEL _T("IMPLEVEL")
  80. #define CLI_TOKEN_AUTHLEVEL _T("AUTHLEVEL")
  81. #define CLI_TOKEN_LOCALE _T("LOCALE")
  82. #define CLI_TOKEN_PRIVILEGES _T("PRIVILEGES")
  83. #define CLI_TOKEN_TRACE _T("TRACE")
  84. #define CLI_TOKEN_RECORD _T("RECORD")
  85. #define CLI_TOKEN_INTERACTIVE _T("INTERACTIVE")
  86. #define CLI_TOKEN_FAILFAST _T("FAILFAST")
  87. #define CLI_TOKEN_USER _T("USER")
  88. #define CLI_TOKEN_PASSWORD _T("PASSWORD")
  89. #define CLI_TOKEN_OUTPUT _T("OUTPUT")
  90. #define CLI_TOKEN_APPEND _T("APPEND")
  91. #define CLI_TOKEN_AGGREGATE _T("AGGREGATE")
  92. #define CLI_TOKEN_COLON _T(":")
  93. #define CLI_TOKEN_COMMA _T(",")
  94. #define CLI_TOKEN_FSLASH _T("/")
  95. #define CLI_TOKEN_HYPHEN _T("-")
  96. #define CLI_TOKEN_HASH _T("#")
  97. #define CLI_TOKEN_SPACE _T(" ")
  98. #define CLI_TOKEN_DOT _T(".")
  99. #define CLI_TOKEN_2DOT _T("..")
  100. #define CLI_TOKEN_EQUALTO _T("=")
  101. #define CLI_TOKEN_NULL _T("")
  102. #define CLI_TOKEN_BSLASH _T("\\")
  103. #define CLI_TOKEN_2BSLASH _T("\\\\")
  104. #define CLI_TOKEN_LEFT_PARAN _T("(")
  105. #define CLI_TOKEN_RIGHT_PARAN _T(")")
  106. #define CLI_TOKEN_ONE _T("1")
  107. #define CLI_TOKEN_TWO _T("2")
  108. #define CLI_TOKEN_SINGLE_QUOTE _T("\'")
  109. #define CLI_TOKEN_DOUBLE_QUOTE _T("\"")
  110. #define CLI_TOKEN_TAB _T("\t")
  111. #define CLI_TOKEN_SEMICOLON _T(";")
  112. #define CLI_TOKEN_NEWLINE _T("\n")
  113. #define CLI_TOKEN_TABLE _T("TABLE")
  114. #define CLI_TOKEN_MOF _T("MOF")
  115. #define CLI_TOKEN_TEXTVALUE _T("TEXTVALUE")
  116. #define CLI_TOKEN_ENABLE _T("ENABLE")
  117. #define CLI_TOKEN_DISABLE _T("DISABLE")
  118. #define CLI_TOKEN_ON _T("ON")
  119. #define CLI_TOKEN_OFF _T("OFF")
  120. #define CLI_TOKEN_BRIEF _T("BRIEF")
  121. #define CLI_TOKEN_FULL _T("FULL")
  122. #define CLI_TOKEN_STDOUT _T("STDOUT")
  123. #define CLI_TOKEN_CLIPBOARD _T("CLIPBOARD")
  124. #define CLI_TOKEN_VALUE _T("VALUE")
  125. #define CLI_TOKEN_ALL _T("ALL")
  126. #define CLI_TOKEN_FORMAT _T("FORMAT")
  127. #define CLI_TOKEN_EVERY _T("EVERY")
  128. #define CLI_TOKEN_REPEAT _T("REPEAT")
  129. #define CLI_TOKEN_TRANSLATE _T("TRANSLATE")
  130. #define CLI_TOKEN_NONINTERACT _T("NOINTERACTIVE")
  131. #define CLI_TOKEN_DUMP _T("DUMP")
  132. #define CLI_TOKEN_FROM _T("FROM")
  133. #define CLI_TOKEN_WHERE _T("WHERE")
  134. #define XSL_FORMAT_TABLE _T("WmiCliTableFormat.xsl")
  135. #define XSL_FORMAT_MOF _T("WmiCliMofFormat.xsl")
  136. #define XSL_FORMAT_VALUE _T("WmiCliValueFormat.xsl")
  137. #define XSL_FORMAT_TEXTVALUE _T("TextValueList.xsl")
  138. #define TEMP_BATCH_FILE _T("TempWmicBatchFile.bat")
  139. #define CLI_XSLMAPPINGS_FILE _T("XSL-Mappings.xml")
  140. #define CLI_XSLSECTION_NAME _T("XSLMAPPINGS")
  141. #define WBEM_LOCATION _T("\\wbem\\")
  142. #define RESPONSE_YES _T("Y")
  143. #define RESPONSE_NO _T("N")
  144. #define RESPONSE_HELP _T("?")
  145. #define EXEC_NAME _T("wmic")
  146. #define CLI_TOKEN_AND _T(" AND ")
  147. #define CLI_TOKEN_WRITE _T("Write")
  148. #define WMISYSTEM_CLASS _T("__CLASS")
  149. #define WMISYSTEM_DERIVATION _T("__DERIVATION")
  150. #define WMISYSTEM_DYNASTY _T("__DYNASTY")
  151. #define WMISYSTEM_GENUS _T("__GENUS")
  152. #define WMISYSTEM_NAMESPACE _T("__NAMESPACE")
  153. #define WMISYSTEM_PATH _T("__PATH")
  154. #define WMISYSTEM_PROPERTYCOUNT _T("__PROPERTYCOUNT")
  155. #define WMISYSTEM_REPLATH _T("__RELPATH")
  156. #define WMISYSTEM_SERVER _T("__SERVER")
  157. #define WMISYSTEM_SUPERCLASS _T("__SUPERCLASS")
  158. #define MULTINODE_XMLSTARTTAG _T("<CIM>")
  159. #define MULTINODE_XMLENDTAG _T("</CIM>")
  160. #define MULTINODE_XMLASSOCSTAG1 _T("<ASSOC.OBJECTARRAY>")
  161. #define MULTINODE_XMLASSOCETAG1 _T("</ASSOC.OBJECTARRAY>")
  162. #define MULTINODE_XMLASSOCSTAG2 _T("<VALUE.OBJECT>")
  163. #define MULTINODE_XMLASSOCETAG2 _T("</VALUE.OBJECT>")
  164. #define CLI_TOKEN_RESULTCLASS _T("RESULTCLASS")
  165. #define CLI_TOKEN_RESULTROLE _T("RESULTROLE")
  166. #define CLI_TOKEN_ASSOCCLASS _T("ASSOCCLASS")
  167. #define CLI_TOKEN_LOCALHOST _T("LOCALHOST")
  168. #define NULL_STRING _T("\0")
  169. #define NULL_CSTRING "\0"
  170. #define BACK_SPACE 0x08
  171. #define BLANK_CHAR 0x00
  172. #define CARRIAGE_RETURN 0x0D
  173. #define ASTERIX _T( "*" )
  174. #define BEEP_SOUND _T( "\a" )
  175. #define NULL_CHAR _T( '\0' )
  176. #define TOKEN_NA _T("N/A")
  177. #define MAXPASSWORDSIZE BUFFER64
  178. #define FORMAT_STRING( buffer, format, value ) \
  179. wsprintf( buffer, format, value )
  180. #define EXCLUDESYSPROP _T("ExcludeSystemProperties")
  181. #define NODESCAVLBL _T("<<Descripiton - Not Available>>")
  182. #define UNICODE_SIGNATURE "\xFF\xFE"
  183. #define UNICODE_BIGEND_SIGNATURE "\xFE\xFF"
  184. #define UTF8_SIGNATURE "\xEF\xBB"
  185. //////////////////////////////////////////////////////////////////////
  186. // NUMERIC CONSTANTS //
  187. //////////////////////////////////////////////////////////////////////
  188. const WMICLIINT OUT_OF_MEMORY = 48111;
  189. const WMICLIINT UNKNOWN_ERROR = 44520;
  190. const WMICLIINT MOFCOMP_ERROR = 49999;
  191. const WMICLIINT SET_CONHNDLR_ROUTN_FAIL = 48112;
  192. const WMICLIINT NOINTERACTIVE = 0;
  193. const WMICLIINT INTERACTIVE = 1;
  194. const WMICLIINT DEFAULTMODE = 2;
  195. const WMICLIINT DEFAULT_SCR_BUF_HEIGHT = 300;
  196. const WMICLIINT DEFAULT_SCR_BUF_WIDTH = 1500;
  197. //////////////////////////////////////////////////////////////////////
  198. // ENUMERATED DATA TYPES //
  199. //////////////////////////////////////////////////////////////////////
  200. // IMPERSONATION LEVEL
  201. typedef enum tag_IMPERSONATIONLEVEL
  202. {
  203. IMPDEFAULT = 0,
  204. IMPANONYMOUS = 1,
  205. IMPIDENTIFY = 2,
  206. IMPERSONATE = 3,
  207. IMPDELEGATE = 4
  208. }IMPLEVEL;
  209. // AUTHENTICATION LEVEL
  210. typedef enum tag_AUTHENTICATIONLEVEL
  211. {
  212. AUTHDEFAULT = 0,
  213. AUTHNONE = 1,
  214. AUTHCONNECT = 2,
  215. AUTHCALL = 3,
  216. AUTHPKT = 4,
  217. AUTHPKTINTEGRITY = 5,
  218. AUTHPKTPRIVACY = 6
  219. }AUTHLEVEL;
  220. // HELP OPTION
  221. typedef enum tag_HELPOPTION
  222. {
  223. HELPBRIEF = 0,
  224. HELPFULL = 1
  225. }HELPOPTION;
  226. // ENUMERATED RETURN CODES for PARSER ENGINE
  227. typedef enum tag_RETCODE
  228. {
  229. PARSER_ERROR = 0,
  230. PARSER_DISPHELP = 1,
  231. PARSER_EXECCOMMAND = 2,
  232. PARSER_MESSAGE = 3,
  233. PARSER_CONTINUE = 4,
  234. PARSER_ERRMSG = 5,
  235. PARSER_OUTOFMEMORY = 6
  236. } RETCODE;
  237. // ENUMERATED HELP OPTION POSSIBILITES
  238. typedef enum tag_HELPTYPE
  239. {
  240. GlblAllInfo,
  241. Namespace,
  242. Role,
  243. Node,
  244. User,
  245. Password,
  246. Locale,
  247. RecordPath,
  248. Privileges,
  249. Level,
  250. AuthLevel,
  251. Interactive,
  252. Trace,
  253. CmdAllInfo,
  254. GETVerb,
  255. SETVerb,
  256. LISTVerb,
  257. CALLVerb,
  258. DUMPVerb,
  259. ASSOCVerb,
  260. CREATEVerb,
  261. DELETEVerb,
  262. AliasVerb,
  263. PATH,
  264. WHERE,
  265. CLASS,
  266. PWhere,
  267. EXIT,
  268. TRANSLATE,
  269. EVERY,
  270. FORMAT,
  271. VERBSWITCHES,
  272. DESCRIPTION,
  273. GETSwitchesOnly,
  274. LISTSwitchesOnly,
  275. CONTEXTHELP,
  276. GLBLCONTEXT,
  277. ASSOCSwitchesOnly,
  278. RESULTCLASShelp,
  279. RESULTROLEhelp,
  280. ASSOCCLASShelp,
  281. FAILFAST,
  282. REPEAT,
  283. OUTPUT,
  284. APPEND,
  285. Aggregate
  286. } HELPTYPE;
  287. // ENUMERATED TOKEN LEVELS
  288. typedef enum tag_TOKENLEVEL
  289. {
  290. LEVEL_ONE = 1,
  291. LEVEL_TWO = 2
  292. } TOKENLEVEL;
  293. // ENUMERATED SESSION RETURN CODES.
  294. typedef enum tag_SESSIONRETCODE
  295. {
  296. SESSION_ERROR = 0,
  297. SESSION_SUCCESS = 1,
  298. SESSION_QUIT = 2,
  299. } SESSIONRETCODE;
  300. // Property In or Out type for parameters
  301. typedef enum tag_INOROUT
  302. {
  303. INP = 0,
  304. OUTP = 1,
  305. UNKNOWN = 2
  306. } INOROUT;
  307. typedef enum tag_GLBLSWITCHFLAG
  308. {
  309. NAMESPACE = 1,
  310. NODE = 2,
  311. USER = 4,
  312. PASSWORD = 8,
  313. LOCALE = 16
  314. } GLBLSWITCHFLAG;
  315. typedef enum tag_VERBTYPE
  316. {
  317. CLASSMETHOD = 0,
  318. STDVERB = 1,
  319. CMDLINE = 2,
  320. NONALIAS = 3
  321. } VERBTYPE;
  322. typedef enum tag_ERRLOGOPT
  323. {
  324. NO_LOGGING = 0,
  325. ERRORS_ONLY = 1,
  326. EVERY_OPERATION = 2
  327. } ERRLOGOPT;
  328. // ENUMERATED Assoc Switches POSSIBILITES
  329. typedef enum tag_ASSOCSwitch
  330. {
  331. RESULTCLASS = 0,
  332. RESULTROLE = 1,
  333. ASSOCCLASS = 2
  334. } ASSOCSwitch;
  335. // ENUMERATED Output or Append option
  336. typedef enum tag_OUTPUTSPEC
  337. {
  338. STDOUT = 0,
  339. CLIPBOARD = 1,
  340. FILEOUTPUT = 2
  341. } OUTPUTSPEC;
  342. // ENUMERATED Interactive Option POSSIBILITES
  343. typedef enum tag_INTEROPTION
  344. {
  345. NO = 0,
  346. YES = 1,
  347. HELP= 2
  348. } INTEROPTION;
  349. // ENUMERATED values for File types
  350. typedef enum tag_FILETYPE
  351. {
  352. ANSI_FILE = 0,
  353. UNICODE_FILE = 1,
  354. UNICODE_BIGENDIAN_FILE = 2,
  355. UTF8_FILE = 3
  356. } FILETYPE;
  357. //////////////////////////////////////////////////////////////////////
  358. // TYPE DEFINITIONS //
  359. //////////////////////////////////////////////////////////////////////
  360. typedef vector<_TCHAR*> CHARVECTOR;
  361. typedef vector<LPSTR> LPSTRVECTOR;
  362. typedef map<_bstr_t, _bstr_t, less<_bstr_t> > BSTRMAP;
  363. typedef map<_TCHAR*, _TCHAR*, less<_TCHAR*> > CHARMAP;
  364. typedef basic_string<_TCHAR> STRING;
  365. typedef map<_bstr_t, WMICLIINT> CHARINTMAP;
  366. typedef vector<_bstr_t> BSTRVECTOR;
  367. typedef map<_bstr_t, BSTRVECTOR, less<_bstr_t> > QUALDETMAP;
  368. typedef struct tag_PROPERTYDETAILS
  369. {
  370. _bstr_t Derivation; // Derivation - actual property name.
  371. _bstr_t Description; // Description about the property.
  372. _bstr_t Type; // Type of property CIMTYPE.
  373. _bstr_t Operation; // Read or Write flag for the property.
  374. _bstr_t Default; // Default values in case of method parameters
  375. INOROUT InOrOut; // Specifies Input or Output parameter in case
  376. // of method arguments.
  377. QUALDETMAP QualDetMap; // Qualifiers associated with the property.
  378. } PROPERTYDETAILS;
  379. typedef map<_bstr_t, PROPERTYDETAILS, less<_bstr_t> > PROPDETMAP;
  380. typedef struct tag_METHODDETAILS // or VERBDETAILS
  381. {
  382. _bstr_t Description; // Desription.
  383. _bstr_t Status; // Implemented or Not.
  384. PROPDETMAP Params; // In and Out parameters and types of the method.
  385. } METHODDETAILS;
  386. typedef map<_bstr_t, METHODDETAILS, less<_bstr_t> > METHDETMAP;
  387. typedef map<_bstr_t, BSTRVECTOR, less<_bstr_t> > ALSFMTDETMAP;
  388. // For cascading transforms.
  389. typedef struct tag_XSLTDET
  390. {
  391. _bstr_t FileName;
  392. BSTRMAP ParamMap;
  393. } XSLTDET;
  394. typedef vector<XSLTDET> XSLTDETVECTOR;
  395. //////////////////////////////////////////////////////////////////////
  396. // USER DEFINED MACROS //
  397. //////////////////////////////////////////////////////////////////////
  398. // SAFEIRELEASE(pIObj)
  399. #define SAFEIRELEASE(pIObj) \
  400. if (pIObj) \
  401. { \
  402. pIObj->Release(); \
  403. pIObj = NULL; \
  404. }
  405. // SAFEBSTRFREE(bstrVal)
  406. #define SAFEBSTRFREE(bstrVal) \
  407. if(bstrVal) \
  408. { \
  409. SysFreeString(bstrVal); \
  410. bstrVal = NULL; \
  411. }
  412. // SAFEADESTROY(psaNames)
  413. #define SAFEADESTROY(psaNames) \
  414. if(psaNames) \
  415. { \
  416. SafeArrayDestroy(psaNames); \
  417. psaNames= NULL; \
  418. }
  419. // SAFEDELETE(pszVal)
  420. #define SAFEDELETE(pszVal) \
  421. if(pszVal) \
  422. { \
  423. delete [] pszVal; \
  424. pszVal = NULL; \
  425. }
  426. // VARIANTCLEAR(v)
  427. #define VARIANTCLEAR(v) \
  428. VariantClear(&v); \
  429. // ONFAILTHROWERROR(hr)
  430. #define ONFAILTHROWERROR(hr) \
  431. if (FAILED(hr)) \
  432. _com_issue_error(hr);
  433. //////////////////////////////////////////////////////////////////////
  434. // GLOBAL FUNCTIONS //
  435. //////////////////////////////////////////////////////////////////////
  436. // Compare two strings (ignore case) and returns TRUE if
  437. // they are equal
  438. BOOL CompareTokens(_TCHAR* pszToken1, _TCHAR* pszToken2);
  439. // Connect to the WMI on the specified machine with input
  440. // user credentials.
  441. HRESULT Connect(IWbemLocator* pILocator, IWbemServices** pISvc,
  442. BSTR bstrNS, BSTR bstrUser, BSTR bstrPwd,
  443. BSTR bstrLocale, CParsedInfo& rParsedInfo);
  444. // Set the security privileges at the interface level
  445. HRESULT SetSecurity(IUnknown* pIUnknown, _TCHAR* pszAuthority,
  446. _TCHAR* pszDomain, _TCHAR* pszUser,
  447. _TCHAR* pszPassword, UINT uAuthLevel,
  448. UINT uImpLevel);
  449. // Parse Authority string into user and domain info.
  450. SCODE ParseAuthorityUserArgs(BSTR& bstrAuthArg, BSTR& bstrUserArg,
  451. BSTR& bstrAuthority, BSTR& bstrUser);
  452. // Converts the UNICODE string to MBCS string
  453. BOOL ConvertWCToMBCS(LPTSTR lpszMsg, LPVOID* lpszDisp, UINT uCP);
  454. // Finds a string in the CHARVECTOR.
  455. BOOL Find(CHARVECTOR& cvVector,
  456. _TCHAR* pszStrToFind,
  457. CHARVECTOR::iterator& theIterator);
  458. // Finds a property in the PROPDETMAP.
  459. BOOL Find(PROPDETMAP& pdmPropDetMap,
  460. _TCHAR* pszPropToFind,
  461. PROPDETMAP::iterator& theIterator,
  462. BOOL bExcludeNumbers = FALSE);
  463. // Finds a property in the BSTRMAP.
  464. BOOL Find(BSTRMAP& bmBstrMap,
  465. _TCHAR* pszStrToFind,
  466. BSTRMAP::iterator& theIterator);
  467. // Frames the XSL File path and updates the rParsedInfo object.
  468. BOOL FrameFileAndAddToXSLTDetVector(XSLTDET xdXSLTDet,
  469. CParsedInfo& rParsedInfo);
  470. // Unquotes the string enclosed in double quotes.
  471. void UnQuoteString(_TCHAR*& pszString);
  472. // Display contents of a VARIANT type data object.
  473. void DisplayVARIANTContent(VARIANT vtObject);
  474. // Get Attributes of property
  475. HRESULT GetPropertyAttributes(IWbemClassObject* pIObj,
  476. BSTR bstrProp,
  477. PROPERTYDETAILS& pdPropDet,
  478. BOOL bTrace);
  479. // Convert CIMTYPE to VariantType
  480. HRESULT ConvertCIMTYPEToVarType( VARIANT& varDest, VARIANT& varSrc,
  481. _TCHAR* bstrCIMType );
  482. // Displays the localized string
  483. void DisplayMessage(LPTSTR lpszMsg, UINT uCP = CP_OEMCP,
  484. BOOL bIsError = FALSE, BOOL bIsLog = FALSE);
  485. // Free memory held by
  486. void CleanUpCharVector(CHARVECTOR& cvCharVector);
  487. void FindAndReplaceAll(STRING& strString, _TCHAR* pszFromStr,
  488. _TCHAR* pszToStr);
  489. // Search and replace all the occurences of entity references.
  490. void FindAndReplaceEntityReferences(_bstr_t& bstrString);
  491. BOOL IsSysProp(_TCHAR* pszProp);
  492. void EraseMessage(UINT uID);
  493. //To display the trace of COM methods invoked
  494. void WMITRACEORERRORLOG(HRESULT hr, INT nLine, char* pszFile, _bstr_t bstrMsg,
  495. DWORD dwThreadId, CParsedInfo& rParsedInfo, BOOL bTrace,
  496. DWORD dwError = 0, _TCHAR* pszResult = NULL);
  497. // Displays wi32 error.
  498. void DisplayWin32Error();
  499. // Accepts password in invisible mode.
  500. void AcceptPassword(_TCHAR* pszPassword);
  501. // Checks for output redirection.
  502. BOOL IsRedirection();
  503. // Checks for value set or not.
  504. BOOL IsValueSet(_TCHAR* pszFromValue, _TCHAR& cValue1, _TCHAR& cValue2);
  505. // Handler routine to handle CTRL + C so as free
  506. // the memory allocated during the program execution.
  507. BOOL CtrlHandler(DWORD fdwCtrlType);
  508. void DisplayString(UINT uID, UINT uCP, LPTSTR lpszParam = NULL,
  509. BOOL bIsError = FALSE, BOOL bIsLog = FALSE);
  510. void SubstituteEscapeChars(CHString& sTemp, LPCWSTR lpszSub);
  511. void RemoveEscapeChars(CHString& sTemp);
  512. //Frames the Namespace
  513. void FrameNamespace(_TCHAR* pszRoleOrNS, _TCHAR* pszRoleOrNSToUpdate);
  514. // Set the buffer size of the command line
  515. void SetScreenBuffer(SHORT nHeight = DEFAULT_SCR_BUF_HEIGHT,
  516. SHORT nWidth = DEFAULT_SCR_BUF_WIDTH);
  517. // Get the buffer size of the command line
  518. void GetScreenBuffer(SHORT& nHeight, SHORT& nWidth);
  519. // Formats the resource string with parameter substitution.
  520. void WMIFormatMessage(UINT uID, WMICLIINT nParamCount, _bstr_t& bstrMsg,
  521. LPTSTR lpszParam, ...);
  522. // Validates a node by using socket functions.
  523. BOOL PingNode(_TCHAR* pszNode);
  524. // If pszNodeName == NULL then check for GetNode() else pszNodeName itself.
  525. BOOL IsFailFastAndNodeExist(CParsedInfo& rParsedInfo, _TCHAR* pszNodeName = NULL);
  526. // Initilaizes windows socket interface.
  527. BOOL InitWinsock ();
  528. // Uninitializes windows socket interface.
  529. BOOL TermWinsock ();
  530. // Get _bstr_t object equivalent to Varaint passed.
  531. void GetBstrTFromVariant(VARIANT& vtVar, _bstr_t& bstrObj,
  532. _TCHAR* pszType = NULL);
  533. // Close the output file.
  534. BOOL CloseOutputFile();
  535. // Close the append file.
  536. BOOL CloseAppendFile();
  537. // Checks if the next token indicates the presence
  538. // of '/' or '-'
  539. BOOL IsOption(_TCHAR* pszToken);
  540. // Copy string to global memory.
  541. HGLOBAL CopyStringToHGlobal(LPTSTR psz);
  542. // Copy data to clip board.
  543. void CopyToClipBoard(_bstr_t& bstrClipBoardBuffer);
  544. // Checks file is valid or not.
  545. RETCODE IsValidFile(_TCHAR* pszFileName);
  546. // It checks whether the current operation is class
  547. // level operation or instance level operation
  548. BOOL IsClassOperation(CParsedInfo& rParsedInfo);
  549. // Enable or Disable all privileges
  550. HRESULT ModifyPrivileges(BOOL bEnable);
  551. #endif