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.

190 lines
4.1 KiB

  1. #ifndef __WBEMDELTA_H__
  2. #define __WBEMDELTA_H__
  3. #include "precomp.h"
  4. #include <reg.h>
  5. #include <stdio.h>
  6. #include <map>
  7. #include <wstring.h>
  8. #include <wstlallc.h>
  9. #define SERVICE_NAME _T("winmgmt")
  10. #define SVC_KEY _T("System\\CurrentControlSet\\Services")
  11. #define HOME_REG_PATH _T("Software\\Microsoft\\WBEM\\CIMOM")
  12. #define KNOWN_SERVICES _T("KnownSvcs")
  13. #define INITIAL_BREAK _T("Break")
  14. #define WBEM_REG_ADAP __TEXT("Software\\Microsoft\\WBEM\\CIMOM\\ADAP")
  15. #define WBEM_NORESYNCPERF __TEXT("NoResyncPerf")
  16. #define WBEM_NOSHELL __TEXT("NoShell")
  17. #define WBEM_WMISETUP __TEXT("WMISetup")
  18. #define WBEM_ADAPEXTDLL __TEXT("ADAPExtDll")
  19. typedef struct tagCheckLibStruct {
  20. BYTE Signature[16];
  21. FILETIME FileTime;
  22. DWORD FileSize;
  23. } CheckLibStruct;
  24. #define ADAP_PERFLIB_STATUS_KEY L"WbemAdapStatus"
  25. #define ADAP_PERFLIB_SIGNATURE L"WbemAdapFileSignature"
  26. #define ADAP_PERFLIB_SIZE L"WbemAdapFileSize"
  27. #define ADAP_PERFLIB_TIME L"WbemAdapFileTime"
  28. //
  29. //
  30. // Linkable string
  31. //
  32. ////////////////////////////////
  33. struct LinkString {
  34. LIST_ENTRY Entry;
  35. DWORD Size;
  36. TCHAR pString[1]; // just a placeholder
  37. };
  38. //
  39. // this is the version of the function with the actual delta dredge
  40. // but in the current design the delta dredge is fooled by perflibs
  41. // that returns errors from their open function
  42. //
  43. ///////////////////////
  44. DWORD WINAPI
  45. DeltaDredge(DWORD dwNumServicesArgs,
  46. LPWSTR *lpServiceArgVectors);
  47. //
  48. // this is the version of the function without the actual delta dredge
  49. //
  50. ///////////////////////
  51. DWORD WINAPI
  52. DeltaDredge2(DWORD dwNumServicesArgs,
  53. LPWSTR *lpServiceArgVectors);
  54. //
  55. //
  56. // a class that wraps what we want to know about a perflib
  57. //
  58. /////////////////////////////////////////////////////////////////
  59. class CPerfLib {
  60. private:
  61. TCHAR * m_wstrServiceName;
  62. TCHAR * m_wstrFull;
  63. HKEY m_hKey;
  64. BOOL m_bOK;
  65. TCHAR * m_pwcsLibrary;
  66. TCHAR * m_pwcsOpenProc;
  67. TCHAR * m_pwcsCollectProc;
  68. TCHAR * m_pwcsCloseProc;
  69. public:
  70. enum {
  71. Perf_Invalid,
  72. Perf_Disabled,
  73. Perf_SetupOK,
  74. Perf_Changed,
  75. Perf_SeemsNew,
  76. Perf_NotChanged,
  77. };
  78. CPerfLib(TCHAR * SvcName);
  79. ~CPerfLib();
  80. HRESULT GetFileSignature( CheckLibStruct * pCheckLib );
  81. int CheckFileSignature(HKEY hKey);
  82. int VerifyLoaded();
  83. int VerifyLoadable();
  84. int CPerfLib::InitializeEntryPoints(HKEY hKey);
  85. HKEY GetHKey(){ return m_hKey; };
  86. TCHAR * GetServiceName(){ return m_wstrServiceName; };
  87. BOOL IsOK(){ return m_bOK; };
  88. };
  89. //
  90. //
  91. // a Wrapper class for the std::map
  92. //
  93. /////////////////////////////////////////////////////////////
  94. class BoolAlloc : public wbem_allocator<bool>
  95. {
  96. };
  97. class WCmp{
  98. public:
  99. bool operator()(WString pFirst,WString pSec) const;
  100. };
  101. typedef std::map<WString,bool,WCmp,BoolAlloc> MapSvc;
  102. class CSvcs
  103. {
  104. public:
  105. CSvcs();
  106. ~CSvcs();
  107. DWORD Load();
  108. DWORD Add(WCHAR * pService);
  109. LONG AddRef(){
  110. return InterlockedIncrement(&m_cRef);
  111. };
  112. LONG Release(){
  113. LONG lRet = InterlockedDecrement(&m_cRef);
  114. if (0 == lRet){
  115. delete this;
  116. }
  117. return lRet;
  118. };
  119. BOOL Find(WCHAR * pStr);
  120. MapSvc& GetMap() { return m_SetServices; };
  121. private:
  122. LONG m_cRef;
  123. MapSvc m_SetServices;
  124. };
  125. #ifdef COUNTER
  126. //
  127. // Counter
  128. //
  129. //////////////////////////////////////
  130. class StartStop {
  131. public:
  132. static LARGE_INTEGER g_liFreq;
  133. static char g_pBuff[256];
  134. LARGE_INTEGER liTimeStart;
  135. LARGE_INTEGER liTimeStop;
  136. char * m_pString;
  137. StartStop(char * pString):m_pString(pString)
  138. {
  139. QueryPerformanceCounter(&liTimeStart);
  140. };
  141. ~StartStop()
  142. {
  143. QueryPerformanceCounter(&liTimeStop);
  144. wsprintfA(g_pBuff,"%I64u %I64u %I64u %s\n",
  145. (liTimeStop.QuadPart)/(g_liFreq.QuadPart),
  146. (liTimeStart.QuadPart)/(g_liFreq.QuadPart),
  147. (liTimeStop.QuadPart-liTimeStart.QuadPart)/(g_liFreq.QuadPart),
  148. m_pString);
  149. OutputDebugStringA(g_pBuff);
  150. };
  151. };
  152. #endif
  153. #endif /*__WBEMDELTA_H__*/