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.

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