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.

2600 lines
70 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. wmiump.h
  5. Abstract:
  6. Private headers for WMI user mode
  7. Author:
  8. 16-Jan-1997 AlanWar
  9. Revision History:
  10. --*/
  11. #define _WMI_SOURCE_
  12. //
  13. // Define this to track reference counts
  14. //#define TRACK_REFERNECES
  15. //
  16. // Define this to get extra checks on heap validation
  17. //#define HEAPVALIDATION
  18. //
  19. // Define this to get a trace of critical section
  20. //#define CRITSECTTRACE
  21. //
  22. // Define this to compile WMI to run as a service under NT
  23. #define RUN_AS_SERVICE
  24. //
  25. // Define this to include WMI user mode functionality. Note that if you enable
  26. // this then you also need to fix the files: wmi\dll\sources and wmi\makefil0.
  27. //#define WMI_USER_MODE
  28. //
  29. // Define this to track memory leaks
  30. //#define TRACK_MEMORY_LEAKS
  31. #ifndef MEMPHIS
  32. #define UNICODE
  33. #define _UNICODE
  34. #include <nt.h>
  35. #include <ntrtl.h>
  36. #include <nturtl.h>
  37. #endif
  38. #include <windows.h>
  39. #include <ole2.h>
  40. #include <tchar.h>
  41. #include <stdio.h>
  42. #ifndef MEMPHIS
  43. #include "svcs.h"
  44. #endif
  45. #include <netevent.h>
  46. #ifdef MEMPHIS
  47. //
  48. // CONSIDER: Is there a better place to get this stuff on MEMPHIS
  49. //
  50. // Doubly-linked list manipulation routines. Implemented as macros
  51. // but logically these are procedures.
  52. //
  53. //
  54. // VOID
  55. // InitializeListHead(
  56. // PLIST_ENTRY ListHead
  57. // );
  58. //
  59. #define InitializeListHead(ListHead) (\
  60. (ListHead)->Flink = (ListHead)->Blink = (ListHead))
  61. //
  62. // BOOLEAN
  63. // IsListEmpty(
  64. // PLIST_ENTRY ListHead
  65. // );
  66. //
  67. #define IsListEmpty(ListHead) \
  68. ((ListHead)->Flink == (ListHead))
  69. //
  70. // PLIST_ENTRY
  71. // RemoveHeadList(
  72. // PLIST_ENTRY ListHead
  73. // );
  74. //
  75. #define RemoveHeadList(ListHead) \
  76. (ListHead)->Flink;\
  77. {RemoveEntryList((ListHead)->Flink)}
  78. //
  79. // PLIST_ENTRY
  80. // RemoveTailList(
  81. // PLIST_ENTRY ListHead
  82. // );
  83. //
  84. #define RemoveTailList(ListHead) \
  85. (ListHead)->Blink;\
  86. {RemoveEntryList((ListHead)->Blink)}
  87. //
  88. // VOID
  89. // RemoveEntryList(
  90. // PLIST_ENTRY Entry
  91. // );
  92. //
  93. #define RemoveEntryList(Entry) {\
  94. PLIST_ENTRY _EX_Blink;\
  95. PLIST_ENTRY _EX_Flink;\
  96. _EX_Flink = (Entry)->Flink;\
  97. _EX_Blink = (Entry)->Blink;\
  98. _EX_Blink->Flink = _EX_Flink;\
  99. _EX_Flink->Blink = _EX_Blink;\
  100. }
  101. //
  102. // VOID
  103. // InsertTailList(
  104. // PLIST_ENTRY ListHead,
  105. // PLIST_ENTRY Entry
  106. // );
  107. //
  108. #define InsertTailList(ListHead,Entry) {\
  109. PLIST_ENTRY _EX_Blink;\
  110. PLIST_ENTRY _EX_ListHead;\
  111. _EX_ListHead = (ListHead);\
  112. _EX_Blink = _EX_ListHead->Blink;\
  113. (Entry)->Flink = _EX_ListHead;\
  114. (Entry)->Blink = _EX_Blink;\
  115. _EX_Blink->Flink = (Entry);\
  116. _EX_ListHead->Blink = (Entry);\
  117. }
  118. //
  119. // VOID
  120. // InsertHeadList(
  121. // PLIST_ENTRY ListHead,
  122. // PLIST_ENTRY Entry
  123. // );
  124. //
  125. #define InsertHeadList(ListHead,Entry) {\
  126. PLIST_ENTRY _EX_Flink;\
  127. PLIST_ENTRY _EX_ListHead;\
  128. _EX_ListHead = (ListHead);\
  129. _EX_Flink = _EX_ListHead->Flink;\
  130. (Entry)->Flink = _EX_Flink;\
  131. (Entry)->Blink = _EX_ListHead;\
  132. _EX_Flink->Blink = (Entry);\
  133. _EX_ListHead->Flink = (Entry);\
  134. }
  135. //
  136. //
  137. // PSINGLE_LIST_ENTRY
  138. // PopEntryList(
  139. // PSINGLE_LIST_ENTRY ListHead
  140. // );
  141. //
  142. #define PopEntryList(ListHead) \
  143. (ListHead)->Next;\
  144. {\
  145. PSINGLE_LIST_ENTRY FirstEntry;\
  146. FirstEntry = (ListHead)->Next;\
  147. if (FirstEntry != NULL) { \
  148. (ListHead)->Next = FirstEntry->Next;\
  149. } \
  150. }
  151. //
  152. // VOID
  153. // PushEntryList(
  154. // PSINGLE_LIST_ENTRY ListHead,
  155. // PSINGLE_LIST_ENTRY Entry
  156. // );
  157. //
  158. #define PushEntryList(ListHead,Entry) \
  159. (Entry)->Next = (ListHead)->Next; \
  160. (ListHead)->Next = (Entry)
  161. //
  162. // Define the various device type values. Note that values used by Microsoft
  163. // Corporation are in the range 0-32767, and 32768-65535 are reserved for use
  164. // by customers.
  165. //
  166. #define DEVICE_TYPE ULONG
  167. #define FILE_DEVICE_BEEP 0x00000001
  168. #define FILE_DEVICE_CD_ROM 0x00000002
  169. #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
  170. #define FILE_DEVICE_CONTROLLER 0x00000004
  171. #define FILE_DEVICE_DATALINK 0x00000005
  172. #define FILE_DEVICE_DFS 0x00000006
  173. #define FILE_DEVICE_DISK 0x00000007
  174. #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
  175. #define FILE_DEVICE_FILE_SYSTEM 0x00000009
  176. #define FILE_DEVICE_INPORT_PORT 0x0000000a
  177. #define FILE_DEVICE_KEYBOARD 0x0000000b
  178. #define FILE_DEVICE_MAILSLOT 0x0000000c
  179. #define FILE_DEVICE_MIDI_IN 0x0000000d
  180. #define FILE_DEVICE_MIDI_OUT 0x0000000e
  181. #define FILE_DEVICE_MOUSE 0x0000000f
  182. #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
  183. #define FILE_DEVICE_NAMED_PIPE 0x00000011
  184. #define FILE_DEVICE_NETWORK 0x00000012
  185. #define FILE_DEVICE_NETWORK_BROWSER 0x00000013
  186. #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
  187. #define FILE_DEVICE_NULL 0x00000015
  188. #define FILE_DEVICE_PARALLEL_PORT 0x00000016
  189. #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
  190. #define FILE_DEVICE_PRINTER 0x00000018
  191. #define FILE_DEVICE_SCANNER 0x00000019
  192. #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
  193. #define FILE_DEVICE_SERIAL_PORT 0x0000001b
  194. #define FILE_DEVICE_SCREEN 0x0000001c
  195. #define FILE_DEVICE_SOUND 0x0000001d
  196. #define FILE_DEVICE_STREAMS 0x0000001e
  197. #define FILE_DEVICE_TAPE 0x0000001f
  198. #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
  199. #define FILE_DEVICE_TRANSPORT 0x00000021
  200. #define FILE_DEVICE_UNKNOWN 0x00000022
  201. #define FILE_DEVICE_VIDEO 0x00000023
  202. #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
  203. #define FILE_DEVICE_WAVE_IN 0x00000025
  204. #define FILE_DEVICE_WAVE_OUT 0x00000026
  205. #define FILE_DEVICE_8042_PORT 0x00000027
  206. #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
  207. #define FILE_DEVICE_BATTERY 0x00000029
  208. #define FILE_DEVICE_BUS_EXTENDER 0x0000002a
  209. #define FILE_DEVICE_MODEM 0x0000002b
  210. #define FILE_DEVICE_VDM 0x0000002c
  211. #define FILE_DEVICE_MASS_STORAGE 0x0000002d
  212. #define FILE_DEVICE_SMB 0x0000002e
  213. #define FILE_DEVICE_KS 0x0000002f
  214. #define FILE_DEVICE_CHANGER 0x00000030
  215. #define FILE_DEVICE_SMARTCARD 0x00000031
  216. #define FILE_DEVICE_ACPI 0x00000032
  217. #define FILE_DEVICE_DVD 0x00000033
  218. //
  219. // Macro definition for defining IOCTL and FSCTL function control codes. Note
  220. // that function codes 0-2047 are reserved for Microsoft Corporation, and
  221. // 2048-4095 are reserved for customers.
  222. //
  223. #define CTL_CODE( DeviceType, Function, Method, Access ) ( \
  224. ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
  225. )
  226. //
  227. // Define the method codes for how buffers are passed for I/O and FS controls
  228. //
  229. #define METHOD_BUFFERED 0
  230. #define METHOD_IN_DIRECT 1
  231. #define METHOD_OUT_DIRECT 2
  232. #define METHOD_NEITHER 3
  233. //
  234. // Define the access check value for any access
  235. //
  236. //
  237. // The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
  238. // ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
  239. // constants *MUST* always be in sync.
  240. //
  241. #define FILE_ANY_ACCESS 0
  242. #define FILE_READ_ACCESS ( 0x0001 ) // file & pipe
  243. #define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe
  244. typedef LONG NTSTATUS;
  245. typedef NTSTATUS (*PUSER_THREAD_START_ROUTINE)(
  246. PVOID ThreadParameter
  247. );
  248. #include <stdio.h>
  249. #endif
  250. #include "wmium.h"
  251. #include "wmiumkm.h"
  252. #include "ntwmi.h"
  253. #include "wmiguid.h"
  254. #if DBG
  255. #if defined(_NTDLLBUILD_)
  256. #define EtwpAssert(x) if (! (x) ) { \
  257. BOOLEAN OldLoggingEnabled = EtwpLoggingEnabled; \
  258. EtwpLoggingEnabled = TRUE; \
  259. EtwpDbgPrint(("WMI Assertion: "#x" at %s %d\n", __FILE__, __LINE__)); \
  260. EtwpLoggingEnabled = OldLoggingEnabled; \
  261. DbgBreakPoint(); }
  262. #else
  263. #define EtwpAssert(x) if (! (x) ) { \
  264. BOOLEAN OldLoggingEnabled = EtwpLoggingEnabled; \
  265. EtwpLoggingEnabled = TRUE; \
  266. EtwpDbgPrint(("WMI Assertion: "#x" at %s %d\n", __FILE__, __LINE__)); \
  267. EtwpLoggingEnabled = OldLoggingEnabled; \
  268. DebugBreak(); }
  269. #endif
  270. #else
  271. #define EtwpAssert(x)
  272. #endif
  273. #if DBG
  274. extern BOOLEAN EtwpLoggingEnabled;
  275. #ifdef MEMPHIS
  276. void __cdecl DebugOut(char *Format, ...);
  277. #define EtwpDebugPrint(_x_) { if (EtwpLoggingEnabled) DebugOut _x_; }
  278. #define EtwpDbgPrint(_x_) { if (EtwpLoggingEnabled) DebugOut _x_; }
  279. #else
  280. #define EtwpDebugPrint(_x_) { if (EtwpLoggingEnabled) DbgPrint _x_; }
  281. #define EtwpDbgPrint(_x_) { if (EtwpLoggingEnabled) DbgPrint _x_; }
  282. #endif
  283. #else
  284. #define EtwpDebugPrint(_x_)
  285. #define EtwpDbgPrint(_x_)
  286. #endif
  287. #define NULL_GUID {0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
  288. //
  289. // Registry based config options. Only available on checked builds
  290. //
  291. #define WmiRegKeyText TEXT("\\Registry\\Machine\\System\\CurrentControlSet\\Control\\WMI")
  292. #define PumpTimeoutRegValueText TEXT("NotificationPumpTimeout")
  293. #define LoggingEnableValueText TEXT("LoggingEnabled")
  294. #define DEFAULT_ALLOC_SIZE 4096
  295. //
  296. // WMI RPC related definitions
  297. typedef struct
  298. {
  299. WNODE_HEADER WnodeHeader;
  300. BYTE Data[1];
  301. } WNODE_INTERNAL, *PWNODE_INTERNAL;
  302. #define INTERNAL_PROVIDER_ID 1
  303. //
  304. // Size of initial buffer used to read notifications from kernel mode
  305. #define STARTNOTIFICATIONBUFFERSIZE 4096
  306. #ifdef MEMPHIS
  307. #define WmiRpcProtocolSequence TEXT("ncalrpc")
  308. #define WmiServiceRpcProtocolSequence TEXT("ncalrpc")
  309. #define WmiServiceRpcEndpoint TEXT("WmiRpcEndpoint")
  310. #else
  311. //#define WmiRpcProtocolSequence TEXT("ncalrpc")
  312. //#define WmiRpcEndpointPrefix TEXT("NT")
  313. #define WmiRpcProtocolSequence TEXT("ncacn_np")
  314. #define WmiRpcEndpointPrefix TEXT("\\pipe\\")
  315. #define WmiServiceRpcProtocolSequence TEXT("ncacn_np")
  316. #define WmiServiceRpcEndpoint SVCS_RPC_PIPE
  317. #endif
  318. #define MinRpcCalls 1
  319. #define MaxRpcCalls RPC_C_PROTSEQ_MAX_REQS_DEFAULT
  320. //
  321. // Time to wait between retrying an RPC call that was too busy to complete
  322. #define RPC_BUSY_WAIT_TIMER 500
  323. //
  324. // Number of times to retry an RPC call that was too busy to complete
  325. #define RPC_BUSY_WAIT_RETRIES 5
  326. //
  327. // WMI RPC interface principle name
  328. #define WMI_RPC_PRINC_NAME TEXT("WMI_RPC_PRINC_NAME")
  329. //
  330. // This macro will break CountedString into a pointer to the actual string
  331. // and the actual length of the string excluding any trailing nul characters
  332. #define EtwpBreakCountedString(CountedString, CountedStringLen) { \
  333. CountedStringLen = *CountedString++; \
  334. if (CountedString[(CountedStringLen-sizeof(WCHAR))/sizeof(WCHAR)] == UNICODE_NULL) \
  335. { \
  336. CountedStringLen -= sizeof(WCHAR); \
  337. } \
  338. }
  339. typedef struct
  340. {
  341. HANDLE GuidHandle;
  342. PVOID DeliveryInfo;
  343. ULONG_PTR DeliveryContext;
  344. ULONG Flags;
  345. } NOTIFYEE, *PNOTIFYEE;
  346. #define STATIC_NOTIFYEE_COUNT 2
  347. typedef struct
  348. {
  349. LIST_ENTRY GNList;
  350. GUID Guid;
  351. ULONG RefCount;
  352. ULONG NotifyeeCount;
  353. PNOTIFYEE Notifyee;
  354. NOTIFYEE StaticNotifyee[STATIC_NOTIFYEE_COUNT];
  355. BOOLEAN bInProgress;
  356. } GUIDNOTIFICATION, *PGUIDNOTIFICATION;
  357. #define EtwpAllocGNEntry() (PGUIDNOTIFICATION)EtwpAlloc(sizeof(GUIDNOTIFICATION))
  358. #define EtwpFreeGNEntry(GNEntry) EtwpFree(GNEntry)
  359. #define EtwpReferenceGNEntry(GNEntry) InterlockedIncrement(&GNEntry->RefCount);
  360. //
  361. // Notification Cookie data structures
  362. //#if DBG
  363. //#define NOTIFYCOOKIESPERCHUNK 2
  364. //#else
  365. //#define NOTIFYCOOKIESPERCHUNK 128
  366. //#endif
  367. /*
  368. typedef struct
  369. {
  370. PVOID DeliveryContext;
  371. PVOID DeliveryInfo;
  372. GUID Guid;
  373. BOOLEAN InUse;
  374. } NOTIFYCOOKIE, *PNOTIFYCOOKIE;
  375. typedef struct
  376. {
  377. LIST_ENTRY Next; // Next cookie chunk
  378. ULONG BaseSlot; // Index of first slot number
  379. USHORT FreeSlot; // Index to a free cookie
  380. BOOLEAN Full; // TRUE if this chunk is full
  381. NOTIFYCOOKIE Cookies[NOTIFYCOOKIESPERCHUNK];
  382. } NOTIFYCOOKIECHUNK, *PNOTIFYCOOKIECHUNK;
  383. */
  384. //
  385. // Useful macro to establish a WNODE_HEADER quickly
  386. #ifdef _WIN64
  387. #define EtwpBuildWnodeHeader(Wnode, WnodeSize, FlagsUlong, Handle) { \
  388. (Wnode)->Flags = FlagsUlong; \
  389. (Wnode)->KernelHandle = Handle; \
  390. (Wnode)->BufferSize = WnodeSize; \
  391. (Wnode)->Linkage = 0; \
  392. }
  393. #else
  394. #define EtwpBuildWnodeHeader(Wnode, WnodeSize, FlagsUlong, Handle) { \
  395. (Wnode)->Flags = FlagsUlong; \
  396. *((PULONG64)(&((Wnode)->TimeStamp))) = (ULONG64)(IntToPtr(PtrToInt(Handle))); \
  397. (Wnode)->BufferSize = WnodeSize; \
  398. (Wnode)->Linkage = 0; \
  399. }
  400. #endif
  401. #ifdef MEMPHIS
  402. extern HANDLE PMMutex;
  403. #define EtwpEnterPMCritSection() WaitForSingleObject(PMMutex, INFINITE)
  404. #define EtwpLeavePMCritSection() ReleaseMutex(PMMutex)
  405. #else
  406. extern RTL_CRITICAL_SECTION PMCritSect;
  407. extern HANDLE EtwpCBInProgressEvent;
  408. #if DBG
  409. #define EtwpEnterPMCritSection() \
  410. EtwpAssert(NT_SUCCESS(RtlEnterCriticalSection(&PMCritSect)));
  411. #define EtwpLeavePMCritSection() { \
  412. EtwpAssert(PMCritSect.LockCount >= 0); \
  413. EtwpAssert(NT_SUCCESS(RtlLeaveCriticalSection(&PMCritSect))); }
  414. //
  415. // Assumptions about EtwpLockCB and EtwpUnlockCB:
  416. // 1. Called only by the Pump Thread
  417. // 2. There can be only one callback in progress at any time with the
  418. // Global event EtwpCBInProgressEvent unset and the corresponding GNEntry
  419. // marked as InProgress.
  420. // 3. Once the callback completes (successfully or not), the event is set
  421. // and the GNEntry unlocked.
  422. // 4. Unregistering threads remove the GNEntry first and then check to see
  423. // whether to block for the PumpThread based on InProgressFlag.
  424. // 5. No callbacks are permitted if the GNEntry is not found in the GNList.
  425. //
  426. #define EtwpLockCB(GNEntry) { \
  427. EtwpDebugPrint(("WMI: Locking GNEntry 0x%x %s %d\n", GNEntry, __FILE__, __LINE__)); \
  428. EtwpAssert( GNEntry->bInProgress == FALSE); \
  429. GNEntry->bInProgress = TRUE; \
  430. NtClearEvent (EtwpCBInProgressEvent); }
  431. #define EtwpUnlockCB(GNEntry) { \
  432. EtwpDebugPrint(("WMI: Unlocking GNEntry 0x%x %s %d\n", GNEntry, __FILE__, __LINE__)); \
  433. EtwpAssert( GNEntry->bInProgress == TRUE); \
  434. NtSetEvent(EtwpCBInProgressEvent, NULL); \
  435. GNEntry->bInProgress = FALSE;}
  436. #else
  437. #define EtwpEnterPMCritSection() RtlEnterCriticalSection(&PMCritSect)
  438. #define EtwpLeavePMCritSection() RtlLeaveCriticalSection(&PMCritSect)
  439. #define EtwpLockCB(GNEntry) {\
  440. GNEntry->bInProgress = TRUE; \
  441. NtClearEvent (EtwpCBInProgressEvent);}
  442. #define EtwpUnlockCB(GNEntry) { \
  443. NtSetEvent(EtwpCBInProgressEvent, NULL); \
  444. GNEntry->bInProgress = FALSE; }
  445. #endif // DBG
  446. #endif // MEMPHIS
  447. typedef struct
  448. {
  449. NOTIFICATIONCALLBACK Callback;
  450. ULONG_PTR Context;
  451. PWNODE_HEADER Wnode;
  452. BYTE WnodeBuffer[1];
  453. } NOTIFDELIVERYCTX, *PNOTIFDELIVERYCTX;
  454. // from handle.c
  455. #define EtwpVerifyToken() \
  456. { \
  457. ULONG VerifyStatus; \
  458. VerifyStatus = EtwpCheckImpersonationTokenType(); \
  459. if (VerifyStatus != ERROR_SUCCESS) \
  460. { \
  461. SetLastError(VerifyStatus); \
  462. return(VerifyStatus); \
  463. } \
  464. }
  465. ULONG EtwpCheckImpersonationTokenType(
  466. void
  467. );
  468. ULONG EtwpCopyStringToCountedUnicode(
  469. LPCWSTR String,
  470. PWCHAR CountedString,
  471. ULONG *BytesUsed,
  472. BOOLEAN ConvertFromAnsi
  473. );
  474. ULONG EtwpCountedAnsiToCountedUnicode(
  475. PCHAR Ansi,
  476. PWCHAR Unicode
  477. );
  478. ULONG EtwpCountedUnicodeToCountedAnsi(
  479. PWCHAR Unicode,
  480. PCHAR Ansi
  481. );
  482. #ifndef MEMPHIS
  483. ULONG EtwpCheckGuidAccess(
  484. LPGUID Guid,
  485. ACCESS_MASK DesiredAccess
  486. );
  487. ULONG EtwpOpenKernelGuid(
  488. LPGUID Guid,
  489. ACCESS_MASK DesiredAccess,
  490. PHANDLE Handle,
  491. ULONG Ioctl
  492. );
  493. #endif
  494. /*
  495. ULONG EtwpAllocateCookie(
  496. PVOID DeliveryInfo,
  497. PVOID DeliveryContext,
  498. LPGUID Guid
  499. );
  500. BOOLEAN EtwpLookupCookie(
  501. ULONG CookieSlot,
  502. LPGUID Guid,
  503. PVOID *DeliveryInfo,
  504. PVOID *DeliveryContext
  505. );
  506. void EtwpGetGuidInCookie(
  507. ULONG CookieSlot,
  508. LPGUID Guid
  509. );
  510. void EtwpFreeCookie(
  511. ULONG CookieSlot
  512. );
  513. */
  514. PGUIDNOTIFICATION
  515. EtwpFindAndLockGuidNotification(
  516. LPGUID Guid,
  517. BOOLEAN bLock
  518. );
  519. ULONG
  520. EtwpAddToGNList(
  521. LPGUID Guid,
  522. PVOID DeliveryInfo,
  523. ULONG_PTR DeliveryContext,
  524. ULONG Flags,
  525. HANDLE GuidHandle
  526. );
  527. ULONG
  528. EtwpRemoveFromGNList(
  529. LPGUID Guid,
  530. PVOID DeliveryInfo
  531. );
  532. BOOLEAN
  533. EtwpDereferenceGNEntry(
  534. PGUIDNOTIFICATION GNEntry
  535. );
  536. //PTCHAR GuidToString(
  537. // PTCHAR s,
  538. // LPGUID piid
  539. // );
  540. PCHAR GuidToStringA(
  541. PCHAR s,
  542. ULONG szBuf,
  543. LPGUID piid
  544. );
  545. // from request.c
  546. ULONG EtwpSendWmiRequest(
  547. ULONG ActionCode,
  548. PWNODE_HEADER Wnode,
  549. ULONG WnodeSize,
  550. PVOID OutBuffer,
  551. ULONG MaxBufferSize,
  552. ULONG *RetSize
  553. );
  554. ULONG EtwpSendWmiKMRequest(
  555. HANDLE Handle,
  556. ULONG Ioctl,
  557. PVOID InBuffer,
  558. ULONG InBufferSize,
  559. PVOID OutBuffer,
  560. ULONG MaxBufferSize,
  561. ULONG *ReturnSize,
  562. LPOVERLAPPED Overlapped
  563. );
  564. ULONG EtwpSendRegisterKMRequest(
  565. HANDLE DeviceHandle,
  566. ULONG Ioctl,
  567. PVOID InBuffer,
  568. ULONG InBufferSize,
  569. PVOID OutBuffer,
  570. ULONG MaxBufferSize,
  571. ULONG *ReturnSize,
  572. LPOVERLAPPED Overlapped
  573. );
  574. ULONG EtwpConvertWADToAnsi(
  575. PWNODE_ALL_DATA Wnode
  576. );
  577. ULONG EtwpConvertWADToUnicode(
  578. PWNODE_ALL_DATA WnodeAllData,
  579. ULONG *BufferSize
  580. );
  581. ULONG EtwpRegisterGuids(
  582. IN LPGUID MasterGuid,
  583. IN LPGUID ControlGuid,
  584. IN LPCWSTR MofImagePath,
  585. IN LPCWSTR MofResourceName,
  586. OUT ULONG64 *LoggerContext,
  587. OUT HANDLE *RegistrationHandle
  588. );
  589. //
  590. // from intrnldp.c
  591. ULONG EtwpInternalProvider(
  592. ULONG ActionCode,
  593. PWNODE_HEADER Wnode,
  594. ULONG MaxWnodeSize,
  595. PVOID OutBuffer,
  596. ULONG *RetSize
  597. );
  598. ULONG
  599. EtwpEnumRegGuids(
  600. PWMIGUIDLISTINFO *pGuidInfo
  601. );
  602. //
  603. // from dcapi.c
  604. ULONG
  605. EtwpNotificationRegistration(
  606. IN LPGUID InGuid,
  607. IN BOOLEAN Enable,
  608. IN PVOID DeliveryInfo,
  609. IN ULONG_PTR DeliveryContext,
  610. IN ULONG64 LoggerContext,
  611. IN ULONG Flags,
  612. IN BOOLEAN IsAnsi
  613. );
  614. //
  615. // from mofapi.c
  616. //
  617. void EtwpProcessLanguageAddRemoveEvent(
  618. IN PWNODE_SINGLE_INSTANCE WnodeSI,
  619. IN NOTIFICATIONCALLBACK Callback,
  620. IN ULONG_PTR DeliveryContext,
  621. IN BOOLEAN IsAnsi
  622. );
  623. void EtwpProcessMofAddRemoveEvent(
  624. IN PWNODE_SINGLE_INSTANCE WnodeSI,
  625. IN NOTIFICATIONCALLBACK Callback,
  626. IN ULONG_PTR DeliveryContext,
  627. IN BOOLEAN IsAnsi
  628. );
  629. //
  630. // from notify.c
  631. extern ULONG EtwpNotificationSinkIndex;
  632. #ifndef MEMPHIS
  633. ULONG EtwpProcessUMRequest(
  634. PWMI_LOGGER_INFORMATION LoggerInfo,
  635. PVOID DeliveryContext,
  636. ULONG ReplyIndex
  637. );
  638. #endif
  639. ULONG EtwpAddHandleToEventPump(
  640. LPGUID Guid,
  641. PVOID DeliveryInfo,
  642. ULONG_PTR DeliveryContext,
  643. ULONG NotificationFlags,
  644. HANDLE GuidHandle
  645. );
  646. void EtwpMakeEventCallbacks(
  647. IN PWNODE_HEADER Wnode,
  648. IN NOTIFICATIONCALLBACK Callback,
  649. IN ULONG_PTR DeliveryContext,
  650. IN BOOLEAN IsAnsi
  651. );
  652. ULONG
  653. EtwpReceiveNotifications(
  654. IN ULONG HandleCount,
  655. IN HANDLE *HandleList,
  656. IN NOTIFICATIONCALLBACK Callback,
  657. IN ULONG_PTR DeliveryContext,
  658. IN BOOLEAN IsAnsi,
  659. IN ULONG Action,
  660. IN PUSER_THREAD_START_ROUTINE UserModeCallback,
  661. IN HANDLE ProcessHandle
  662. );
  663. ULONG EtwpEventPump(
  664. PVOID Param
  665. );
  666. void
  667. EtwpEnableDisableGuid(
  668. PWNODE_HEADER Wnode,
  669. ULONG RequestCode,
  670. BOOLEAN bDelayEnable
  671. );
  672. //
  673. // from main.c
  674. VOID
  675. EtwpCreateHeap(
  676. VOID
  677. );
  678. #ifndef IsEqualGUID
  679. #define IsEqualGUID(guid1, guid2) \
  680. (!memcmp((guid1), (guid2), sizeof(GUID)))
  681. #endif
  682. //
  683. // These define the dll and mof resource name for all of the builtin mof
  684. // resources
  685. #define WMICOREDLLNAME L"wmicore.dll"
  686. #define WMICOREMOFRESOURCENAME L"MofResource"
  687. //
  688. // This defines the registry key under which security descriptors associated
  689. // with the guids are stored.
  690. #ifndef MEMPHIS
  691. #define WMISECURITYREGISTRYKEY TEXT("System\\CurrentControlSet\\Control\\Wmi\\Security")
  692. #endif
  693. //
  694. // This defines the initial value of the buffer passed to each data provider
  695. // to retrieve the registration information
  696. #if DBG
  697. #define INITIALREGINFOSIZE sizeof(WNODE_TOO_SMALL)
  698. #else
  699. #define INITIALREGINFOSIZE 8192
  700. #endif
  701. //
  702. // Chunk Management definitions
  703. // All structures that rely upon the chunk allocator must be defined so that
  704. // their members match that of ENTRYHEADER. These include DATASOURCE,
  705. // GUIDENTRY, INSTANCESET, DCENTRY, NOTIFICATIONENTRY, MOFCLASS, MOFRESOURCE
  706. // Also ENTRYHEADER reserves 0x80000000 for its own flag.
  707. struct _CHUNKINFO;
  708. struct _ENTRYHEADER;
  709. typedef void (*ENTRYCLEANUP)(
  710. struct _CHUNKINFO *,
  711. struct _ENTRYHEADER *
  712. );
  713. typedef struct _CHUNKINFO
  714. {
  715. LIST_ENTRY ChunkHead; // Head of list of chunks
  716. ULONG EntrySize; // Size of a single entry
  717. ULONG EntriesPerChunk; // Number of entries per chunk allocation
  718. ENTRYCLEANUP EntryCleanup; // Entry cleanup routine
  719. ULONG InitialFlags; // Initial flags for all entries
  720. ULONG Signature;
  721. #if DBG
  722. ULONG AllocCount;
  723. ULONG FreeCount;
  724. #endif
  725. } CHUNKINFO, *PCHUNKINFO;
  726. typedef struct
  727. {
  728. LIST_ENTRY ChunkList; // Node in list of chunks
  729. LIST_ENTRY FreeEntryHead; // Head of list of free entries in chunk
  730. ULONG EntriesInUse; // Count of entries being used
  731. } CHUNKHEADER, *PCHUNKHEADER;
  732. typedef struct _ENTRYHEADER
  733. {
  734. union
  735. {
  736. LIST_ENTRY FreeEntryList; // Node in list of free entries
  737. LIST_ENTRY InUseEntryList; // Node in list ofin use entries
  738. };
  739. PCHUNKHEADER Chunk; // Chunk in which entry is located
  740. ULONG Flags; // Flags
  741. ULONG RefCount; // Reference Count
  742. ULONG Signature;
  743. } ENTRYHEADER, *PENTRYHEADER;
  744. // Set if the entry is free
  745. #define FLAG_ENTRY_ON_FREE_LIST 0x80000000
  746. #define FLAG_ENTRY_ON_INUSE_LIST 0x40000000
  747. #define FLAG_ENTRY_INVALID 0x20000000
  748. #define FLAG_ENTRY_REMOVE_LIST 0x10000000
  749. #define EtwpReferenceEntry(Entry) \
  750. InterlockedIncrement(&((PENTRYHEADER)(Entry))->RefCount)
  751. // chunk.c
  752. #ifndef MEMPHIS
  753. ULONG EtwpBuildGuidObjectAttributes(
  754. IN LPGUID Guid,
  755. OUT POBJECT_ATTRIBUTES ObjectAttributes,
  756. OUT PUNICODE_STRING GuidString,
  757. OUT PWCHAR GuidObjectName
  758. );
  759. #endif
  760. ULONG EtwpUnreferenceEntry(
  761. PCHUNKINFO ChunkInfo,
  762. PENTRYHEADER Entry);
  763. PENTRYHEADER EtwpAllocEntry(
  764. PCHUNKINFO ChunkInfo
  765. );
  766. void EtwpFreeEntry(
  767. PCHUNKINFO ChunkInfo,
  768. PENTRYHEADER Entry
  769. );
  770. //
  771. // This is the guid that denotes non event notifications. WMICore
  772. // automatically registers anyone opening a guid to
  773. extern GUID RegChangeNotificationGuid;
  774. extern CHUNKINFO DSChunkInfo;
  775. extern CHUNKINFO GEChunkInfo;
  776. extern CHUNKINFO ISChunkInfo;
  777. extern CHUNKINFO DCChunkInfo;
  778. extern CHUNKINFO NEChunkInfo;
  779. extern CHUNKINFO MRChunkInfo;
  780. struct tagGUIDENTRY;
  781. typedef struct tagGUIDENTRY GUIDENTRY, *PGUIDENTRY, *PBGUIDENTRY;
  782. struct tagDATASOURCE;
  783. //
  784. // An INSTANCESET contains the information a set of instances that is provided
  785. // by a single data source. An instance set is part of two lists. One list is
  786. // the set of instance sets for a particular guid. The other list is the list
  787. // of instance sets supported by a data source.
  788. //
  789. //
  790. // Instance names for an instance set registered with a base name and count
  791. // are stored in a ISBASENAME structure. This structure is tracked by
  792. // PDFISBASENAME in wmicore.idl.
  793. typedef struct
  794. {
  795. ULONG BaseIndex; // First index to append to base name
  796. WCHAR BaseName[1]; // Actual base name
  797. } ISBASENAME, *PISBASENAME, *PBISBASENAME;
  798. //
  799. // This defines the maximum number of characters that can be part of a suffix
  800. // to a basename. The current value of 6 will allow up to 999999 instances
  801. // of a guid with a static base name
  802. #define MAXBASENAMESUFFIXSIZE 6
  803. //
  804. // Instance names for an instance set registerd with a set of static names
  805. // are kept in a ISSTATICNAMES structure. This structure is tracked by
  806. // PDFISSTATICNAMES defined in wmicore.idl
  807. typedef struct
  808. {
  809. PWCHAR StaticNamePtr[1]; // pointers to static names
  810. // WCHAR StaticNames[1];
  811. } ISSTATICENAMES, *PISSTATICNAMES, *PBISSTATICNAMES;
  812. typedef struct tagInstanceSet
  813. {
  814. union
  815. {
  816. // Entry in list of instances within a guid
  817. LIST_ENTRY GuidISList;
  818. // Entry in main list of free instances
  819. LIST_ENTRY FreeISList;
  820. };
  821. PCHUNKHEADER Chunk; // Chunk in which entry is located
  822. ULONG Flags;
  823. // Reference count of number of guids using this instance set
  824. ULONG RefCount;
  825. // Signature to identify entry
  826. ULONG Signature;
  827. // Entry in list of instances within a data source
  828. LIST_ENTRY DSISList;
  829. // Back link to guid that this instance set is a member
  830. PBGUIDENTRY GuidEntry;
  831. // Back link to data source that this instance set is a member
  832. struct tagDATASOURCE *DataSource;
  833. // Count of instances in instance set
  834. ULONG Count;
  835. //
  836. // If IS_INSTANCE_BASENAME is set then IsBaseName pointe at instance base
  837. // name structure. Else if IS_INSTANCE_STATICNAME is set then
  838. // IsStaticNames points to static instance name list. If
  839. union
  840. {
  841. PBISBASENAME IsBaseName;
  842. PBISSTATICNAMES IsStaticNames;
  843. };
  844. } INSTANCESET, *PINSTANCESET, *PBINSTANCESET;
  845. #define IS_SIGNATURE 'nalA'
  846. //
  847. // Guid Map Entry List maintains the list of Guid and their maps.
  848. // Only those Guids that are Unregistered while a logger session is in
  849. // progress is kept in this list.
  850. // It is also used as a placeholder for InstanceIds. Trace Guid Registration
  851. // calls return a handle to a GUIDMAPENTRY which maintains the map and the
  852. // Instance Ids.
  853. //
  854. typedef struct tagTRACE_REG_INFO
  855. {
  856. BOOLEAN EnabledState; // Indicates if this GUID is Enabled or not.
  857. PVOID NotifyRoutine;
  858. PVOID TraceCtxHandle;
  859. PVOID NotifyContext;
  860. ULONG64 LoggerContext;
  861. } TRACE_REG_INFO, *PTRACE_REG_INFO;
  862. typedef struct
  863. {
  864. ULONG InstanceId;
  865. ULONG Reserved;
  866. GUID Guid;
  867. } GUIDMAPENTRY, *PGUIDMAPENTRY;
  868. #define IS_INSTANCE_BASENAME 0x00000001
  869. #define IS_INSTANCE_STATICNAMES 0x00000002
  870. #define IS_EXPENSIVE 0x00000004 // set if collection must be enabled
  871. #define IS_COLLECTING 0x00000008 // set when collecting
  872. #define IS_KM_PROVIDER 0x00000080 // KM data provider
  873. #define IS_SM_PROVIDER 0x00000100 // Shared memory provider
  874. #define IS_UM_PROVIDER 0x00000200 // User mode provider
  875. #define IS_NEWLY_REGISTERED 0x00000800 // set if IS is registering
  876. //
  877. // Any traced guids are used for trace logging and not querying
  878. #define IS_TRACED 0x00001000
  879. // Set when events are enabled for instance set
  880. #define IS_ENABLE_EVENT 0x00002000
  881. // Set when events are enabled for instance set
  882. #define IS_ENABLE_COLLECTION 0x00004000
  883. // Set if guid is used only for firing events and not querying
  884. #define IS_EVENT_ONLY 0x00008000
  885. // Set if data provider for instance set is expecting ansi instsance names
  886. #define IS_ANSI_INSTANCENAMES 0x00010000
  887. // Set if instance names are originated from a PDO
  888. #define IS_PDO_INSTANCENAME 0x00020000
  889. // If set the data provider for the InstanceSet is internal to wmi.dll
  890. #define IS_INTERNAL_PROVIDER 0x00040000
  891. // Set if a Traced Guid is also a Trace Control Guid
  892. #define IS_CONTROL_GUID 0x00080000
  893. #define IS_ON_FREE_LIST 0x80000000
  894. typedef struct tagGUIDENTRY
  895. {
  896. union
  897. {
  898. // Entry in list of all guids registered with WMI
  899. LIST_ENTRY MainGEList;
  900. // Entry in list of free guid entry blocks
  901. LIST_ENTRY FreeGEList;
  902. };
  903. PCHUNKHEADER Chunk; // Chunk in which entry is located
  904. ULONG Flags;
  905. // Count of number of data sources using this guid
  906. ULONG RefCount;
  907. // Signature to identify entry
  908. ULONG Signature;
  909. // Count of InstanceSets headed by this guid
  910. ULONG ISCount;
  911. // Head of list of all instances for guid
  912. LIST_ENTRY ISHead;
  913. // Guid that represents data block
  914. GUID Guid;
  915. } GUIDENTRY, *PGUIDENTRY, *PBGUIDENTRY;
  916. #define GE_SIGNATURE 'diuG'
  917. #define GE_ON_FREE_LIST 0x80000000
  918. //
  919. // When set this guid is an internally defined guid that has no data source
  920. // attached to it.
  921. #define GE_FLAG_INTERNAL 0x00000001
  922. typedef struct
  923. {
  924. union
  925. {
  926. // Entry in list of all DS
  927. LIST_ENTRY MainMRList;
  928. // Entry in list of free DS
  929. LIST_ENTRY FreeMRList;
  930. };
  931. PCHUNKHEADER Chunk; // Chunk in which entry is located
  932. ULONG Flags;
  933. ULONG RefCount;
  934. // Signature to identify entry
  935. ULONG Signature;
  936. PWCHAR MofImagePath; // Path to image file with resource
  937. PWCHAR MofResourceName; // Name of resource containing mof data
  938. #ifdef WMI_USER_MODE
  939. LIST_ENTRY MRMCHead;
  940. #endif
  941. } MOFRESOURCE, *PMOFRESOURCE;
  942. #define MR_SIGNATURE 'yhsA'
  943. #if DBG
  944. #define AVGMOFRESOURCECOUNT 1
  945. #else
  946. #define AVGMOFRESOURCECOUNT 4
  947. #endif
  948. typedef struct tagDATASOURCE
  949. {
  950. union
  951. {
  952. // Entry in list of all DS
  953. LIST_ENTRY MainDSList;
  954. // Entry in list of free DS
  955. LIST_ENTRY FreeDSList;
  956. };
  957. PCHUNKHEADER Chunk; // Chunk in which entry is located
  958. ULONG Flags;
  959. ULONG RefCount;
  960. ULONG Signature;
  961. // Head of list of instances for this DS
  962. LIST_ENTRY ISHead;
  963. // Binding string and callback address for DS rpc server
  964. PTCHAR BindingString;
  965. RPC_BINDING_HANDLE RpcBindingHandle;
  966. ULONG RequestAddress;
  967. ULONG RequestContext;
  968. // Provider id of kernel mode driver
  969. ULONG_PTR ProviderId;
  970. // Path to registry holding ACLs
  971. PTCHAR RegistryPath;
  972. // Head of list of MofResources attached to data source
  973. ULONG MofResourceCount;
  974. PMOFRESOURCE *MofResources;
  975. PMOFRESOURCE StaticMofResources[AVGMOFRESOURCECOUNT];
  976. };
  977. #define DS_SIGNATURE ' naD'
  978. #define VERIFY_DPCTXHANDLE(DsCtxHandle) \
  979. ( ((DsCtxHandle) == NULL) || \
  980. (((PBDATASOURCE)(DsCtxHandle))->Signature == DS_SIGNATURE) )
  981. typedef struct tagDATASOURCE DATASOURCE, *PDATASOURCE, *PBDATASOURCE;
  982. #define DS_ALLOW_ALL_ACCESS 0x00000001
  983. #define DS_KERNEL_MODE 0x00000002
  984. //
  985. // Set in the Internal WMI data source
  986. #define DS_INTERNAL 0x00000004
  987. #define DS_ON_FREE_LIST 0x80000000
  988. //
  989. // A list of enabled notifications is maintained by the wmi service to mange
  990. // delivering events and to know when to send enable and disable event
  991. // wmi requests to the data providers. Each NOTIFICATIONENTRY has an array of
  992. // DCREF which is a reference to the data consumer who is interested in the
  993. // event.
  994. #define RPCOUTSTANDINGCALLLIMIT 128
  995. typedef struct
  996. {
  997. LIST_ENTRY MainDCList; // Node on global data consumer list
  998. PCHUNKHEADER Chunk; // Chunk in which entry is located
  999. ULONG Flags;
  1000. ULONG RefCount;
  1001. ULONG Signature;
  1002. // Actual RPC binding handle
  1003. RPC_BINDING_HANDLE RpcBindingHandle;
  1004. PUCHAR EventData; // Buffer to hold events to be sent
  1005. ULONG LastEventOffset; // Offset in EventData to previous event
  1006. ULONG NextEventOffset; // Offset in EventData to write next event
  1007. ULONG EventDataSizeLeft; // Number of bytes left to use in EventData
  1008. ULONG RpcCallsOutstanding; // Number of rpc calls outstanding
  1009. #if DBG
  1010. PTCHAR BindingString; // Binding string for consumer
  1011. #endif
  1012. } DCENTRY, *PDCENTRY;
  1013. #define DC_SIGNATURE 'cirE'
  1014. // If the data consumer has had its context rundown routine then this flag
  1015. // is set. This indicates that the data consumer has gone away and no more
  1016. // events should be sent to him.
  1017. #define DC_FLAG_RUNDOWN 0x00000001
  1018. #define VERIFY_DCCTXHANDLE(DcCtxHandle) \
  1019. ( ((DcCtxHandle) == NULL) || \
  1020. (((PDCENTRY)(DcCtxHandle))->Signature == DC_SIGNATURE) )
  1021. typedef struct
  1022. {
  1023. PDCENTRY DcEntry; // points at data consumer interested in notification
  1024. // Number of times collect has been enabled by
  1025. // this DC.
  1026. ULONG CollectRefCount;
  1027. // Number of times collect has been enabled by
  1028. // this DC.
  1029. ULONG EventRefCount;
  1030. ULONG Flags; // Flags
  1031. ULONG LostEventCount;
  1032. } DCREF, *PDCREF;
  1033. //
  1034. // _ENABLED flag set if DP already called to enable notification or collection
  1035. #define DCREF_FLAG_NOTIFICATION_ENABLED 0x00000001
  1036. #define DCREF_FLAG_COLLECTION_ENABLED 0x00000002
  1037. // if DCREF_FLAG_NO_EXTRA_THREAD set then WMI will not create a special thread
  1038. // to do the direct notification callback.
  1039. #define DCREF_FLAG_NO_EXTRA_THREAD 0x00000008
  1040. // If this flag is set then the notification callback is expecting an ANSI
  1041. // instance names.
  1042. #define DCREF_FLAG_ANSI 0x00000010
  1043. // NOTE: Other notification flags in wmium.h are:
  1044. // NOTIFICATION_TRACE_FLAG 0x00010000
  1045. //
  1046. // NOTIFICATION_FLAG_CALLBACK_DIRECT is set when NotifyAddress specifies
  1047. // a direct callback address for delivering the event.
  1048. //
  1049. // NOTIFICATION_FLAG_CALLBACK_DIRECT is set when NotifyAddress specifies
  1050. // a direct callback address for delivering the event.
  1051. //
  1052. #define NOTIFICATION_FLAG_CALLBACK_DIRECT 0x00020000
  1053. #define NOTIFICATION_FLAG_CALLBACK_QUEUED 0x00040000
  1054. #define NOTIFICATION_FLAG_WINDOW 0x00080000
  1055. #define NOTIFICATION_FLAG_BATCHED 0x00100000
  1056. //
  1057. // This flag is set for those guid handles that may be duplicated in
  1058. // the list. All Notifyee slots that have this flag are considered in a
  1059. // group and only one handle needs to be put on the list
  1060. //
  1061. #define NOTIFICATION_FLAG_GROUPED_EVENT 0x00200000
  1062. //
  1063. // This flag is set for those guid handles that are pending closure.
  1064. // Only the pump thread is allowed to close a handle; the main threads
  1065. // will set this flag to indicate that the handle should no longer be
  1066. // used. When the pump thread builds the list of handles and notices
  1067. // the flag it will close the handle.
  1068. //
  1069. #define NOTIFICATION_FLAG_PENDING_CLOSE 0x00400000
  1070. #define EtwpIsNotifyeePendingClose(Notifyee) \
  1071. (((Notifyee)->Flags & NOTIFICATION_FLAG_PENDING_CLOSE) == NOTIFICATION_FLAG_PENDING_CLOSE)
  1072. //
  1073. // These are the flags contained in DcRef->Flags that pertain to Notifications
  1074. #define NOTIFICATION_MASK_EVENT_FLAGS \
  1075. (NOTIFICATION_FLAG_CALLBACK_DIRECT | \
  1076. NOTIFICATION_FLAG_CALLBACK_QUEUED | \
  1077. NOTIFICATION_FLAG_WINDOW | \
  1078. DCREF_FLAG_NO_EXTRA_THREAD | \
  1079. DCREF_FLAG_ANSI)
  1080. //
  1081. // This defines the number of DC references a NOTIFICATIONENTRY can have
  1082. // in a single entry
  1083. // CONSIDER: Merging NOTIFICATIONENTRY with GUIDENTRY
  1084. #define DCREFPERNOTIFICATION 16
  1085. typedef struct _notificationentry
  1086. {
  1087. LIST_ENTRY MainNotificationList; // Node in main notifications list
  1088. PCHUNKHEADER Chunk; // Chunk in which entry is located
  1089. ULONG Flags; // flags
  1090. ULONG RefCount;
  1091. // Signature to identify entry
  1092. ULONG Signature;
  1093. GUID Guid; // guid representing notification
  1094. // If > DCREFPERNOTIFICATION DC have
  1095. // enabled this event then this points
  1096. // to another NOTIFICATIONENTRY which
  1097. // has another DCREF array
  1098. struct _notificationentry *Continuation;
  1099. ULONG EventRefCount; // Global count of event enables
  1100. ULONG CollectRefCount; // Global count of collection enables
  1101. ULONG64 LoggerContext; // Logger context handle
  1102. HANDLE CollectInProgress; // Event set when all collect complete
  1103. DCREF DcRef[DCREFPERNOTIFICATION]; // DC that have enabled this event
  1104. } NOTIFICATIONENTRY, *PNOTIFICATIONENTRY;
  1105. #define NE_SIGNATURE 'eluJ'
  1106. // Set when a notification request is being processed by the data providers
  1107. #define NE_FLAG_NOTIFICATION_IN_PROGRESS 0x00000001
  1108. // Set when a collection request is being processed by the data providers
  1109. #define NE_FLAG_COLLECTION_IN_PROGRESS 0x00000002
  1110. // Set when a trace disable is being processed by a worker thread
  1111. #define NE_FLAG_TRACEDISABLE_IN_PROGRESS 0x00000004
  1112. #ifdef WMI_USER_MODE
  1113. //
  1114. // Valid MOF data types for qualifiers and properties (data items)
  1115. typedef enum
  1116. {
  1117. MOFInt32 = 0, // 32bit integer
  1118. MOFUInt32 = 1, // 32bit unsigned integer
  1119. MOFInt64 = 2, // 64bit integer
  1120. MOFUInt64 = 3, // 32bit unsigned integer
  1121. MOFInt16 = 4, // 16bit integer
  1122. MOFUInt16 = 5, // 16bit unsigned integer
  1123. MOFChar = 6, // 8bit integer
  1124. MOFByte = 7, // 8bit unsigned integer
  1125. MOFWChar = 8, // Wide (16bit) character
  1126. MOFDate = 9, // Date field
  1127. MOFBoolean = 10, // 8bit Boolean value
  1128. MOFEmbedded = 11, // Embedded class
  1129. MOFString = 12, // Counted String type
  1130. MOFZTString = 13, // NULL terminated unicode string
  1131. MOFAnsiString = 14, // NULL terminated ansi string
  1132. MOFUnknown = 0xffffffff // Data type is not known
  1133. } MOFDATATYPE, *PMOFDATATYPE;
  1134. // Data items that are of type MOFString are stored in the data block as a
  1135. // counted unicode string. The text of the string is always preceeded by
  1136. // a USHORT which contains the count of bytes following that composes the
  1137. // string. The string may be NULL terminated and in that case the count must
  1138. // include the null termination bytes.
  1139. // Data items that are of type MOFDate are fixed length Unicode strings and
  1140. // not preceeded by a count value. It is in the following fixed format:
  1141. //
  1142. // yyyymmddhhmmss.mmmmmmsutc
  1143. //
  1144. // Where yyyy is a 4 digit year, mm is the month, dd is the day, hh is
  1145. // the hour (24-hour clock), mm is the minute, ss is the second, the
  1146. // mmmmmm is the number of microseconds (typically all zeros) and s is a
  1147. // "+" or "-" indicating the sign of the UTC (correction field, and utc
  1148. // is the offset from UTC in minutes (using the sign indicated by s).
  1149. // For example, Wednesday, May 25, 1994, at 1:30:15 PM EDT would be
  1150. // represented as:
  1151. //
  1152. // 19940525133015.0000000-300
  1153. //
  1154. // Values MUST be zero-padded so that the entire string is always the
  1155. // same 25-character length. Fields which are not significant MUST be
  1156. // replaced with asterisk characters. Similarly, intervals use the
  1157. // same format, except that the interpretation of the fields is based
  1158. // on elapsed time. For example, an elapsed time of 1 day, 13 hours,
  1159. // 23 minutes, and 12 seconds would be:
  1160. //
  1161. // 00000001132312.000000+000
  1162. //
  1163. // A UTC offset of zero is always used for interval properties.
  1164. struct _MOFCLASSINFOW;
  1165. struct _MOFCLASSINFOA;
  1166. //
  1167. // Each class has one or more data items that are described by a MOFDATAITEM
  1168. // structure.
  1169. typedef struct
  1170. {
  1171. #ifdef MIDL_PASS
  1172. [string] PDFWCHAR
  1173. #else
  1174. LPWSTR
  1175. #endif
  1176. Name; // Text name of data item
  1177. #ifdef MIDL_PASS
  1178. [string] PDFWCHAR
  1179. #else
  1180. LPWSTR
  1181. #endif
  1182. Description; // Text description of data item
  1183. MOFDATATYPE DataType; // MOF data type
  1184. ULONG Version; // Version that this MOF is part of
  1185. ULONG SizeInBytes; // Size of data item in Blob
  1186. ULONG Flags; // Flags, See MOFDI_FLAG_*
  1187. GUID EmbeddedClassGuid; // Guid of data item's embedded class
  1188. ULONG FixedArrayElements; // Number of elements in fixed sized array
  1189. // Used when MOF_FLAG_FIXED_ARRAY is set
  1190. ULONG VariableArraySizeId; // MOF_FLAG_VARIABLE_ARRAY, Data id of
  1191. // variable containing number of elements
  1192. // in array
  1193. PVOID VarArrayTempPtr;
  1194. PVOID EcTempPtr;
  1195. ULONG_PTR PropertyQualifierHandle;
  1196. ULONG MethodId;
  1197. LPWSTR HeaderName;// Name of structure in generated header
  1198. struct _MOFCLASSINFOW *MethodClassInfo;
  1199. ULONG MaxLen;
  1200. } MOFDATAITEMW, *PMOFDATAITEMW;
  1201. typedef struct
  1202. {
  1203. LPSTR
  1204. Name; // Text name of data item
  1205. LPSTR
  1206. Description; // Text description of data item
  1207. MOFDATATYPE DataType; // MOF data type
  1208. ULONG Version; // Version that this MOF is part of
  1209. ULONG SizeInBytes; // Size of data item in Blob
  1210. ULONG Flags; // Flags, See MOFDI_FLAG_*
  1211. GUID EmbeddedClassGuid; // Guid of data item's embedded class
  1212. ULONG FixedArrayElements; // Number of elements in fixed sized array
  1213. // Used when MOF_FLAG_FIXED_ARRAY is set
  1214. ULONG VariableArraySizeId; // MOF_FLAG_VARIABLE_ARRAY, Data id of
  1215. // variable containing number of elements
  1216. // in array
  1217. PVOID VarArrayTempPtr;
  1218. PVOID EcTempPtr;
  1219. ULONG_PTR PropertyQualifierHandle;
  1220. ULONG MethodId;
  1221. LPSTR HeaderName; // Name of structure in generated header
  1222. struct _MOFCLASSINFOA *MethodClassInfo;
  1223. ULONG MaxLen;
  1224. } MOFDATAITEMA, *PMOFDATAITEMA;
  1225. #ifdef UNICODE
  1226. typedef MOFDATAITEMW MOFDATAITEM;
  1227. typedef PMOFDATAITEMW PMOFDATAITEM;
  1228. #else
  1229. typedef MOFDATAITEMA MOFDATAITEM;
  1230. typedef PMOFDATAITEMA PMOFDATAITEM;
  1231. #endif
  1232. // Data item is actually a fixed sized array
  1233. #define MOFDI_FLAG_FIXED_ARRAY 0x00000001
  1234. // Data item is actually a variable length array
  1235. #define MOFDI_FLAG_VARIABLE_ARRAY 0x00000002
  1236. // Data item is actually an embedded class
  1237. #define MOFDI_FLAG_EMBEDDED_CLASS 0x00000004
  1238. // Data item is readable
  1239. #define MOFDI_FLAG_READABLE 0x00000008
  1240. // Data item is writable
  1241. #define MOFDI_FLAG_WRITEABLE 0x00000010
  1242. // Data item is an event
  1243. #define MOFDI_FLAG_EVENT 0x00000020
  1244. // Embedded class Guid is not set
  1245. #define MOFDI_FLAG_EC_GUID_NOT_SET 0x00000040
  1246. // Data item is really a method
  1247. #define MOFDI_FLAG_METHOD 0x00000080
  1248. // Data item is an input method parameter
  1249. #define MOFDI_FLAG_INPUT_METHOD 0x00000100
  1250. // Data item is an output method parameter
  1251. #define MOFDI_FLAG_OUTPUT_METHOD 0x00000200
  1252. //
  1253. // The MOFCLASSINFO structure describes the format of a data block
  1254. typedef struct _MOFCLASSINFOW
  1255. {
  1256. GUID Guid; // Guid that represents class
  1257. #ifdef MIDL_PASS
  1258. [string] PDFWCHAR
  1259. #else
  1260. LPWSTR
  1261. #endif
  1262. Name; // Text name of class
  1263. #ifdef MIDL_PASS
  1264. [string] PDFWCHAR
  1265. #else
  1266. LPWSTR
  1267. #endif
  1268. Description;// Text description of class
  1269. #ifdef MIDL_PASS
  1270. [string] PDFWCHAR
  1271. #else
  1272. LPWSTR
  1273. #endif
  1274. HeaderName;// Name of structure in generated header
  1275. #ifdef MIDL_PASS
  1276. [string] PDFWCHAR
  1277. #else
  1278. LPWSTR
  1279. #endif
  1280. GuidName1;// Name of Guid in generated header
  1281. #ifdef MIDL_PASS
  1282. [string] PDFWCHAR
  1283. #else
  1284. LPWSTR
  1285. #endif
  1286. GuidName2;// Name of Guid in generated header
  1287. USHORT Language; // Language of MOF
  1288. USHORT Reserved;
  1289. ULONG Flags; // Flags, see MOFGI_FLAG_*
  1290. ULONG Version; // Version of Guid
  1291. ULONG_PTR ClassQualifierHandle; // CBMOFObj, BMOF class qualifier ptr
  1292. ULONG DataItemCount; // Number of wmi data items (properties)
  1293. ULONG MethodCount; // Number of wmi data items (properties)
  1294. // Array of Property info
  1295. #ifdef MIDL_PASS
  1296. [size_is(DataItemCount)]
  1297. #endif
  1298. MOFDATAITEMW *DataItems;
  1299. #ifndef MIDL_PASS
  1300. UCHAR Tail[1];
  1301. #endif
  1302. } MOFCLASSINFOW, *PMOFCLASSINFOW;
  1303. typedef struct _MOFCLASSINFOA
  1304. {
  1305. GUID Guid; // Guid that represents class
  1306. LPSTR
  1307. Name; // Text name of class
  1308. LPSTR
  1309. Description;// Text description of class
  1310. LPSTR
  1311. HeaderName;// Name of structure in generated header
  1312. LPSTR
  1313. GuidName1;// Name of Guid in generated header
  1314. LPSTR
  1315. GuidName2;// Name of Guid in generated header
  1316. USHORT Language; // Language of MOF
  1317. USHORT Reserved;
  1318. ULONG Flags; // Flags, see MOFGI_FLAG_*
  1319. ULONG Version; // Version of Guid
  1320. ULONG_PTR ClassQualifierHandle; // CBMOFObj, BMOF class qualifier ptr
  1321. ULONG DataItemCount; // Number of wmi data items (properties)
  1322. ULONG MethodCount; // Number of wmi data items (properties)
  1323. // Array of Property info
  1324. MOFDATAITEMA *DataItems;
  1325. UCHAR Tail[1];
  1326. } MOFCLASSINFOA, *PMOFCLASSINFOA;
  1327. #ifdef UNICODE
  1328. typedef MOFCLASSINFOW MOFCLASSINFO;
  1329. typedef PMOFCLASSINFOW PMOFCLASSINFO;
  1330. #else
  1331. typedef MOFCLASSINFOA MOFCLASSINFO;
  1332. typedef PMOFCLASSINFOA PMOFCLASSINFO;
  1333. #endif
  1334. // 0x00000001 to 0x00000004 are not available
  1335. #define MOFCI_FLAG_EVENT 0x10000000
  1336. #define MOFCI_FLAG_EMBEDDED_CLASS 0x20000000
  1337. #define MOFCI_FLAG_READONLY 0x40000000
  1338. #define MOFCI_FLAG_METHOD_PARAMS 0x80000000
  1339. typedef struct
  1340. {
  1341. union
  1342. {
  1343. // Entry in list of all DS
  1344. LIST_ENTRY MainMCList;
  1345. // Entry in list of free DS
  1346. LIST_ENTRY FreeMCList;
  1347. };
  1348. PCHUNKHEADER Chunk; // Chunk in which entry is located
  1349. ULONG Flags;
  1350. ULONG RefCount;
  1351. PMOFCLASSINFOW MofClassInfo; // Actual class info data
  1352. LIST_ENTRY MCMRList; // Entry in list of MCs in a MR
  1353. LIST_ENTRY MCVersionList; // Head or entry in list of MCs with
  1354. // same guid, but possibly different versions
  1355. ULONG_PTR ClassObjectHandle; // CBMOFObj, BMOF class object ptr
  1356. PMOFRESOURCE MofResource; // Resource holding class info
  1357. } MOFCLASS, *PMOFCLASS;
  1358. // If this is set then the MOF class can never be replaced with a later version
  1359. #define MC_FLAG_NEVER_REPLACE 0x00000001
  1360. #endif
  1361. //
  1362. // AVGGUIDSPERDS defines a guess as to the number of guids that get registered
  1363. // by any data provider. It is used to allocate the buffer used to deliver
  1364. // registration change notifications.
  1365. #if DBG
  1366. #define AVGGUIDSPERDS 2
  1367. #else
  1368. #define AVGGUIDSPERDS 256
  1369. #endif
  1370. #define OffsetToPtr(Base, Offset) ((PBYTE)((PBYTE)(Base) + (Offset)))
  1371. //
  1372. // Guid and InstanceSet cache
  1373. #if DBG
  1374. #define PTRCACHEGROWSIZE 2
  1375. #else
  1376. #define PTRCACHEGROWSIZE 64
  1377. #endif
  1378. typedef struct
  1379. {
  1380. LPGUID Guid;
  1381. PBINSTANCESET InstanceSet;
  1382. } PTRCACHE;
  1383. //
  1384. // Registration data structures
  1385. //
  1386. #ifdef MEMPHIS
  1387. extern HANDLE SMMutex;
  1388. #define EtwpEnterSMCritSection() WaitForSingleObject(SMMutex, INFINITE)
  1389. #define EtwpLeaveSMCritSection() ReleaseMutex(SMMutex)
  1390. #else
  1391. extern RTL_CRITICAL_SECTION SMCritSect;
  1392. #if DBG
  1393. #ifdef CRITSECTTRACE
  1394. #define EtwpEnterSMCritSection() { \
  1395. EtwpDebugPrint(("WMI: Enter SM Crit %s %d\n", __FILE__, __LINE__)); \
  1396. RtlEnterCriticalSection(&SMCritSect); }
  1397. #define EtwpLeaveSMCritSection() { \
  1398. EtwpDebugPrint(("WMI: Leave SM Crit %s %d\n", __FILE__, __LINE__)); \
  1399. RtlLeaveCriticalSection(&SMCritSect); }
  1400. #else
  1401. #define EtwpEnterSMCritSection() \
  1402. EtwpAssert(NT_SUCCESS(RtlEnterCriticalSection(&SMCritSect)));
  1403. #define EtwpLeaveSMCritSection() { \
  1404. EtwpAssert(SMCritSect.LockCount >= 0); \
  1405. EtwpAssert(NT_SUCCESS(RtlLeaveCriticalSection(&SMCritSect))); }
  1406. #endif // CRITSECTTRACE
  1407. #else
  1408. #define EtwpEnterSMCritSection() RtlEnterCriticalSection(&SMCritSect)
  1409. #define EtwpLeaveSMCritSection() RtlLeaveCriticalSection(&SMCritSect)
  1410. #endif // DBG
  1411. #endif // MEMPHIS
  1412. #ifndef IsEqualGUID
  1413. #define IsEqualGUID(guid1, guid2) \
  1414. (!memcmp((guid1), (guid2), sizeof(GUID)))
  1415. #endif
  1416. //
  1417. // WMI MOF result codes. Since they are never given to the caller they are
  1418. // defined in here
  1419. #define ERROR_WMIMOF_INCORRECT_DATA_TYPE -1 /* 0xffffffff */
  1420. #define ERROR_WMIMOF_NO_DATA -2 /* 0xfffffffe */
  1421. #define ERROR_WMIMOF_NOT_FOUND -3 /* 0xfffffffd */
  1422. #define ERROR_WMIMOF_UNUSED -4 /* 0xfffffffc */
  1423. // Property %ws in class %ws has no embedded class name
  1424. #define ERROR_WMIMOF_NO_EMBEDDED_CLASS_NAME -5 /* 0xfffffffb */
  1425. // Property %ws in class %ws has an unknown data type
  1426. #define ERROR_WMIMOF_UNKNOWN_DATA_TYPE -6 /* 0xfffffffa */
  1427. // Property %ws in class %ws has no syntax qualifier
  1428. #define ERROR_WMIMOF_NO_SYNTAX_QUALIFIER -7 /* 0xfffffff9 */
  1429. #define ERROR_WMIMOF_NO_CLASS_NAME -8 /* 0xfffffff8 */
  1430. #define ERROR_WMIMOF_BAD_DATA_FORMAT -9 /* 0xfffffff7 */
  1431. // Property %ws in class %ws has the same WmiDataId %d as property %ws
  1432. #define ERROR_WMIMOF_DUPLICATE_ID -10 /* 0xfffffff6 */
  1433. // Property %ws in class %ws has a WmiDataId of %d which is out of range
  1434. #define ERROR_WMIMOF_BAD_DATAITEM_ID -11 /* 0xfffffff5 */
  1435. #define ERROR_WMIMOF_MISSING_DATAITEM -12 /* 0xfffffff4 */
  1436. // Property for WmiDataId %d is not defined in class %ws
  1437. #define ERROR_WMIMOF_DATAITEM_NOT_FOUND -13 /* 0xfffffff3 */
  1438. // Embedded class %ws not defined for Property %ws in Class %ws
  1439. #define ERROR_WMIMOF_EMBEDDED_CLASS_NOT_FOUND -14 /* 0xfffffff2 */
  1440. // Property %ws in class %ws has an incorrect [WmiVersion] qualifier
  1441. #define ERROR_WMIMOF_INCONSISTENT_VERSIONING -15 /* 0xfffffff1 */
  1442. #define ERROR_WMIMOF_NO_PROPERTY_QUALIFERS -16 /* 0xfffffff0 */
  1443. // Class %ws has a badly formed or missing [guid] qualifier
  1444. #define ERROR_WMIMOF_BAD_OR_MISSING_GUID -17 /* 0xffffffef */
  1445. // Could not find property %ws which is the array size for property %ws in class %ws
  1446. #define ERROR_WMIMOF_VL_ARRAY_SIZE_NOT_FOUND -18 /* 0xffffffee */
  1447. // A class could not be parsed properly
  1448. #define ERROR_WMIMOF_CLASS_NOT_PARSED -19 /* 0xffffffed */
  1449. // Wmi class %ws requires the qualifiers [Dynamic, Provider("WmiProv")]
  1450. #define ERROR_WMIMOF_MISSING_HMOM_QUALIFIERS -20 /* 0xffffffec */
  1451. // Error accessing binary mof file %s
  1452. #define ERROR_WMIMOF_CANT_ACCESS_FILE -21 /* 0xffffffeb */
  1453. // Property InstanceName in class %ws must be type string and not %ws
  1454. #define ERROR_WMIMOF_INSTANCENAME_BAD_TYPE -22 /* 0xffffffea */
  1455. // Property Active in class %ws must be type bool and not %ws
  1456. #define ERROR_WMIMOF_ACTIVE_BAD_TYPE -23 /* 0xffffffe9 */
  1457. // Property %ws in class %ws does not have [WmiDataId()] qualifier
  1458. #define ERROR_WMIMOF_NO_WMIDATAID -24 /* 0xffffffe8 */
  1459. // Property InstanceName in class %ws must have [key] qualifier
  1460. #define ERROR_WMIMOF_INSTANCENAME_NOT_KEY -25 /* 0xffffffe7 */
  1461. // Class %ws does not have an InstanceName qualifier
  1462. #define ERROR_WMIMOF_NO_INSTANCENAME -26 /* 0xffffffe6 */
  1463. // Class %ws does not have an Active qualifier
  1464. #define ERROR_WMIMOF_NO_ACTIVE -27 /* 0xffffffe5 */
  1465. // Property %ws in class %ws is an array, but doesn't specify a dimension
  1466. #define ERROR_WMIMOF_MUST_DIM_ARRAY -28 /* 0xffffffe4 */
  1467. // The element count property %ws for the variable length array %ws in class %ws is not an integral type
  1468. #define ERROR_WMIMOF_BAD_VL_ARRAY_SIZE_TYPE -29 /* 0xdddddde4 */
  1469. // Property %ws in class %ws is both a fixed and variable length array
  1470. #define ERROR_WMIMOF_BOTH_FIXED_AND_VARIABLE_ARRAY -30 /* 0xffffffe3 */
  1471. // Embedded class %ws should not have InstaneName or Active properties
  1472. #define ERROR_WMIMOF_EMBEDDED_CLASS -31 /* 0xffffffe2 */
  1473. #define ERROR_WMIMOF_IMPLEMENTED_REQUIRED -32 /* 0xffffffe1 */
  1474. // TEXT("WmiMethodId for method %ws in class %ws must be unique")
  1475. #define ERROR_WMIMOF_DUPLICATE_METHODID -33 /* 0xffffffe0 */
  1476. // TEXT("WmiMethodId for method %ws in class %ws must be specified")
  1477. #define ERROR_WMIMOF_MISSING_METHODID -34 /* 0xffffffdf */
  1478. // TEXT("WmiMethodId for method %ws in class %ws must not be 0")
  1479. #define ERROR_WMIMOF_METHODID_ZERO -35 /* 0xffffffde */
  1480. // TEXT("Class %ws is derived from WmiEvent and may not be [abstract]")
  1481. #define ERROR_WMIMOF_WMIEVENT_ABSTRACT -36 /* 0xffffffdd */
  1482. // TEXT("The element count property for the variable length array
  1483. // %ws in class %ws is not a property of the class"),
  1484. #define ERROR_WMIMOF_VL_ARRAY_NOT_FOUND -37 /* 0xffffffdc */
  1485. // TEXT("An error occured resolving the variable length array
  1486. // property %ws in class %ws to element count property")
  1487. #define ERROR_WMIMOF_VL_ARRAY_NOT_RESOLVED -38 /* 0xffffffdb */
  1488. // TEXT("Method %ws in class %ws must return void\n")
  1489. #define ERROR_WMIMOF_METHOD_RETURN_NOT_VOID -39 /* 0xffffffda */
  1490. // TEXT("Embedded class %ws should not have any methods\n")
  1491. #define ERROR_WMIMOF_EMBEDDED_CLASS_HAS_METHODS -40 /* 0xffffffd9 */
  1492. #define ERROR_WMIMOF_COUNT 40
  1493. // This file is not a valid binary mof file
  1494. // ERROR_WMI_INVALID_MOF
  1495. // There was not enough memory to complete an operation
  1496. // ERROR_NOT_ENOUGH_MEMORY
  1497. //
  1498. // Function prototypes for private functions
  1499. //
  1500. // sharemem.c
  1501. ULONG EtwpEstablishSharedMemory(
  1502. PBDATASOURCE DataSource,
  1503. LPCTSTR SectionName,
  1504. ULONG SectionSize
  1505. );
  1506. //
  1507. // validate.c
  1508. BOOLEAN EtwpValidateCountedString(
  1509. WCHAR *String
  1510. );
  1511. BOOLEAN EtwpValidateGuid(
  1512. LPGUID Guid
  1513. );
  1514. BOOLEAN EtwpProbeForRead(
  1515. PUCHAR Buffer,
  1516. ULONG BufferSize
  1517. );
  1518. //
  1519. // alloc.c
  1520. extern LIST_ENTRY GEHead;
  1521. extern PLIST_ENTRY GEHeadPtr;
  1522. extern CHUNKINFO GEChunkInfo;
  1523. extern LIST_ENTRY NEHead;
  1524. extern PLIST_ENTRY NEHeadPtr;
  1525. extern CHUNKINFO NEChunkInfo;
  1526. extern LIST_ENTRY DSHead;
  1527. extern PLIST_ENTRY DSHeadPtr;
  1528. extern CHUNKINFO DSChunkInfo;
  1529. extern LIST_ENTRY DCHead;
  1530. extern PLIST_ENTRY DCHeadPtr;
  1531. extern CHUNKINFO DCChunkInfo;
  1532. extern LIST_ENTRY MRHead;
  1533. extern PLIST_ENTRY MRHeadPtr;
  1534. extern CHUNKINFO MRChunkInfo;
  1535. extern CHUNKINFO ISChunkInfo;
  1536. extern LIST_ENTRY GMHead;
  1537. extern PLIST_ENTRY GMHeadPtr;
  1538. #ifdef WMI_USER_MODE
  1539. extern LIST_ENTRY MCHead;
  1540. extern PLIST_ENTRY MCHeadPtr;
  1541. extern CHUNKINFO MCChunkInfo;
  1542. #endif
  1543. #ifdef TRACK_REFERNECES
  1544. #define EtwpUnreferenceDS(DataSource) \
  1545. { \
  1546. EtwpDebugPrint(("WMI: Unref DS %x at %s %d\n", DataSource, __FILE__, __LINE__)); \
  1547. EtwpUnreferenceEntry(&DSChunkInfo, (PENTRYHEADER)DataSource); \
  1548. }
  1549. #define EtwpReferenceDS(DataSource) \
  1550. { \
  1551. EtwpDebugPrint(("WMI: Ref DS %x at %s %d\n", DataSource, __FILE__, __LINE__)); \
  1552. EtwpReferenceEntry((PENTRYHEADER)DataSource); \
  1553. }
  1554. #define EtwpUnreferenceGE(GuidEntry) \
  1555. { \
  1556. EtwpDebugPrint(("WMI: Unref GE %x at %s %d\n", GuidEntry, __FILE__, __LINE__)); \
  1557. EtwpUnreferenceEntry(&GEChunkInfo, (PENTRYHEADER)GuidEntry); \
  1558. }
  1559. #define EtwpReferenceGE(GuidEntry) \
  1560. { \
  1561. EtwpDebugPrint(("WMI: Ref GE %x at %s %d\n", GuidEntry, __FILE__, __LINE__)); \
  1562. EtwpReferenceEntry((PENTRYHEADER)GuidEntry); \
  1563. }
  1564. #define EtwpUnreferenceIS(InstanceSet) \
  1565. { \
  1566. EtwpDebugPrint(("WMI: Unref IS %x at %s %d\n", InstanceSet, __FILE__, __LINE__)); \
  1567. EtwpUnreferenceEntry(&ISChunkInfo, (PENTRYHEADER)InstanceSet); \
  1568. }
  1569. #define EtwpReferenceIS(InstanceSet) \
  1570. { \
  1571. EtwpDebugPrint(("WMI: Ref IS %x at %s %d\n", InstanceSet, __FILE__, __LINE__)); \
  1572. EtwpReferenceEntry((PENTRYHEADER)InstanceSet); \
  1573. }
  1574. #define EtwpUnreferenceDC(DataConsumer) \
  1575. { \
  1576. EtwpDebugPrint(("WMI: Unref DC %x at %s %d\n", DataConsumer, __FILE__, __LINE__)); \
  1577. EtwpUnreferenceEntry(&DCChunkInfo, (PENTRYHEADER)DataConsumer); \
  1578. }
  1579. #define EtwpReferenceDC(DataConsumer) \
  1580. { \
  1581. EtwpDebugPrint(("WMI: Ref DC %x at %s %d\n", DataConsumer, __FILE__, __LINE__)); \
  1582. EtwpReferenceEntry((PENTRYHEADER)DataConsumer); \
  1583. }
  1584. #define EtwpUnreferenceNE(NotificationEntry) \
  1585. { \
  1586. EtwpDebugPrint(("WMI: Unref NE %x at %s %d\n", NotificationEntry, __FILE__, __LINE__)); \
  1587. EtwpUnreferenceEntry(&NEChunkInfo, (PENTRYHEADER)NotificationEntry); \
  1588. }
  1589. #define EtwpReferenceNE(NotificationEntry) \
  1590. { \
  1591. EtwpDebugPrint(("WMI: Ref NE %x at %s %d\n", NotificationEntry, __FILE__, __LINE__)); \
  1592. EtwpReferenceEntry((PENTRYHEADER)NotificationEntry); \
  1593. }
  1594. #define WmippUnreferenceMR(MofResource) \
  1595. { \
  1596. EtwpDebugPrint(("WMI: Unref MR %x at %s %d\n", MofResource, __FILE__, __LINE__)); \
  1597. EtwpUnreferenceEntry(&MRChunkInfo, (PENTRYHEADER)MofResource); \
  1598. }
  1599. #define WmipReferenceMR(MofResource) \
  1600. { \
  1601. EtwpDebugPrint(("WMI: Ref MR %x at %s %d\n", MofResource, __FILE__, __LINE__)); \
  1602. EtwpReferenceEntry((PENTRYHEADER)MofResource); \
  1603. }
  1604. #ifdef WMI_USER_MODE
  1605. #define EtwpUnreferenceMC(MofClass) \
  1606. { \
  1607. EtwpDebugPrint(("WMI: Unref MC %x at %s %d\n", MofClass, __FILE__, __LINE__)); \
  1608. EtwpUnreferenceEntry(&MCChunkInfo, (PENTRYHEADER)MofClass); \
  1609. }
  1610. #define EtwpReferenceMC(MofClass) \
  1611. { \
  1612. EtwpDebugPrint(("WMI: Ref MC %x at %s %d\n", MofClass, __FILE__, __LINE__)); \
  1613. EtwpReferenceEntry((PENTRYHEADER)MofClass); \
  1614. }
  1615. #endif
  1616. #else
  1617. #define EtwpUnreferenceDS(DataSource) \
  1618. EtwpUnreferenceEntry(&DSChunkInfo, (PENTRYHEADER)DataSource)
  1619. #define EtwpReferenceDS(DataSource) \
  1620. EtwpReferenceEntry((PENTRYHEADER)DataSource)
  1621. #define EtwpUnreferenceGE(GuidEntry) \
  1622. EtwpUnreferenceEntry(&GEChunkInfo, (PENTRYHEADER)GuidEntry)
  1623. #define EtwpReferenceGE(GuidEntry) \
  1624. EtwpReferenceEntry((PENTRYHEADER)GuidEntry)
  1625. #define EtwpUnreferenceIS(InstanceSet) \
  1626. EtwpUnreferenceEntry(&ISChunkInfo, (PENTRYHEADER)InstanceSet)
  1627. #define EtwpReferenceIS(InstanceSet) \
  1628. EtwpReferenceEntry((PENTRYHEADER)InstanceSet)
  1629. #define EtwpUnreferenceDC(DataConsumer) \
  1630. EtwpUnreferenceEntry(&DCChunkInfo, (PENTRYHEADER)DataConsumer)
  1631. #define EtwpReferenceDC(DataConsumer) \
  1632. EtwpReferenceEntry((PENTRYHEADER)DataConsumer)
  1633. #define EtwpUnreferenceNE(NotificationEntry) \
  1634. EtwpUnreferenceEntry(&NEChunkInfo, (PENTRYHEADER)NotificationEntry)
  1635. #define EtwpReferenceNE(NotificationEntry) \
  1636. EtwpReferenceEntry((PENTRYHEADER)NotificationEntry)
  1637. #define WmipUnreferenceMR(MofResource) \
  1638. EtwpUnreferenceEntry(&MRChunkInfo, (PENTRYHEADER)MofResource)
  1639. #define WmipReferenceMR(MofResource) \
  1640. EtwpReferenceEntry((PENTRYHEADER)MofResource)
  1641. #ifdef WMI_USER_MODE
  1642. #define EtwpUnreferenceMC(MofClass) \
  1643. EtwpUnreferenceEntry(&MCChunkInfo, (PENTRYHEADER)MofClass)
  1644. #define EtwpReferenceMC(MofClass) \
  1645. EtwpReferenceEntry((PENTRYHEADER)MofClass)
  1646. #endif
  1647. #endif
  1648. PBDATASOURCE EtwpAllocDataSource(
  1649. void
  1650. );
  1651. PBGUIDENTRY EtwpAllocGuidEntry(
  1652. void
  1653. );
  1654. #define EtwpAllocInstanceSet() ((PBINSTANCESET)EtwpAllocEntry(&ISChunkInfo))
  1655. #define EtwpAllocDataConsumer() ((PDCENTRY)EtwpAllocEntry(&DCChunkInfo))
  1656. #define EtwpAllocNotificationEntry() ((PNOTIFICATIONENTRY)EtwpAllocEntry(&NEChunkInfo))
  1657. #define EtwpAllocMofResource() ((PMOFRESOURCE)EtwpAllocEntry(&MRChunkInfo))
  1658. #define WmipDebugPrint EtwpDebugPrint
  1659. #define WmipAlloc EtwpAlloc
  1660. #define WmipAssert EtwpAssert
  1661. #define WmipFree EtwpFree
  1662. #ifdef WMI_USER_MODE
  1663. #define EtwpAllocMofClass() ((PMOFCLASS)EtwpAllocEntry(&MCChunkInfo))
  1664. #endif
  1665. #define EtwpAllocString(Size) \
  1666. EtwpAlloc((Size)*sizeof(WCHAR))
  1667. #define EtwpFreeString(Ptr) \
  1668. EtwpFree(Ptr)
  1669. #ifdef MEMPHIS
  1670. #define EtwpAlloc(Size) \
  1671. malloc(Size)
  1672. #define EtwpFree(Ptr) \
  1673. free(Ptr)
  1674. #define EtwpInitProcessHeap()
  1675. #else
  1676. //
  1677. // Reserve 1MB for WMI.DLL, but only commit 16K initially
  1678. #define DLLRESERVEDHEAPSIZE 1024 * 1024
  1679. #define DLLCOMMITHEAPSIZE 0 * 1024
  1680. //
  1681. // Reserve 1MB for WMI service, but only commit 16K initially
  1682. #define CORERESERVEDHEAPSIZE 1024 * 1024
  1683. #define CORECOMMITHEAPSIZE 16 * 1024
  1684. extern PVOID EtwpProcessHeap;
  1685. #define EtwpInitProcessHeap() \
  1686. { \
  1687. if (EtwpProcessHeap == NULL) \
  1688. { \
  1689. EtwpCreateHeap(); \
  1690. } \
  1691. }
  1692. #ifdef HEAPVALIDATION
  1693. PVOID EtwpAlloc(
  1694. ULONG Size
  1695. );
  1696. void EtwpFree(
  1697. PVOID p
  1698. );
  1699. #else
  1700. #if DBG
  1701. _inline PVOID EtwpAlloc(ULONG Size)
  1702. {
  1703. EtwpAssert(EtwpProcessHeap != NULL);
  1704. return(RtlAllocateHeap(EtwpProcessHeap, 0, Size));
  1705. }
  1706. _inline void EtwpFree(PVOID Ptr)
  1707. {
  1708. RtlFreeHeap(EtwpProcessHeap, 0, Ptr);
  1709. }
  1710. #else
  1711. #define EtwpAlloc(Size) \
  1712. RtlAllocateHeap(EtwpProcessHeap, 0, Size)
  1713. #define EtwpFree(Ptr) \
  1714. RtlFreeHeap(EtwpProcessHeap, 0, Ptr)
  1715. #endif
  1716. #endif
  1717. #endif
  1718. BOOLEAN EtwpRealloc(
  1719. PVOID *Buffer,
  1720. ULONG CurrentSize,
  1721. ULONG NewSize,
  1722. BOOLEAN FreeOriginalBuffer
  1723. );
  1724. //
  1725. // datastr.c
  1726. extern GUID EtwpBinaryMofGuid;
  1727. void EtwpGenerateBinaryMofNotification(
  1728. PBINSTANCESET BianryMofInstanceSet,
  1729. LPCGUID Guid
  1730. );
  1731. BOOLEAN EtwpEstablishInstanceSetRef(
  1732. PBDATASOURCE DataSourceRef,
  1733. LPGUID Guid,
  1734. PBINSTANCESET InstanceSet
  1735. );
  1736. ULONG EtwpAddDataSource(
  1737. PTCHAR QueryBinding,
  1738. ULONG RequestAddress,
  1739. ULONG RequestContext,
  1740. LPCTSTR ImagePath,
  1741. PWMIREGINFOW RegistrationInfo,
  1742. ULONG RegistrationInfoSize,
  1743. ULONG_PTR *ProviderId,
  1744. BOOLEAN IsAnsi
  1745. );
  1746. ULONG EtwpUpdateAddGuid(
  1747. PBDATASOURCE DataSource,
  1748. PWMIREGGUID RegGuid,
  1749. PWMIREGINFO RegistrationInfo,
  1750. PBINSTANCESET *AddModInstanceSet
  1751. );
  1752. ULONG EtwpUpdateModifyGuid(
  1753. PBDATASOURCE DataSource,
  1754. PWMIREGGUID RegGuid,
  1755. PWMIREGINFO RegistrationInfo,
  1756. PBINSTANCESET *AddModInstanceSet
  1757. );
  1758. BOOLEAN EtwpUpdateRemoveGuid(
  1759. PBDATASOURCE DataSource,
  1760. PWMIREGGUID RegGuid,
  1761. PBINSTANCESET *AddModInstanceSet
  1762. );
  1763. void EtwpUpdateDataSource(
  1764. ULONG_PTR ProviderId,
  1765. PWMIREGINFOW RegistrationInfo,
  1766. ULONG RetSize
  1767. );
  1768. void EtwpRemoveDataSource(
  1769. ULONG_PTR ProviderId
  1770. );
  1771. void EtwpRemoveDataSourceByDS(
  1772. PBDATASOURCE DataSource
  1773. );
  1774. ULONG EtwpRegisterInternalDataSource(
  1775. void
  1776. );
  1777. PBGUIDENTRY EtwpFindGEByGuid(
  1778. LPGUID Guid,
  1779. BOOLEAN MakeTopOfList
  1780. );
  1781. PBINSTANCESET EtwpFindISInDSByGuid(
  1782. PBDATASOURCE DataSource,
  1783. LPGUID Guid
  1784. );
  1785. PNOTIFICATIONENTRY EtwpFindNEByGuid(
  1786. GUID UNALIGNED *Guid,
  1787. BOOLEAN MakeTopOfList
  1788. );
  1789. PDCREF EtwpFindExistingAndFreeDCRefInNE(
  1790. PNOTIFICATIONENTRY NotificationEntry,
  1791. PDCENTRY DataConsumer,
  1792. PDCREF *FreeDcRef
  1793. );
  1794. PDCREF EtwpFindDCRefInNE(
  1795. PNOTIFICATIONENTRY NotificationEntry,
  1796. PDCENTRY DataConsumer
  1797. );
  1798. PBDATASOURCE EtwpFindDSByProviderId(
  1799. ULONG_PTR ProviderId
  1800. );
  1801. PBINSTANCESET EtwpFindISByGuid(
  1802. PBDATASOURCE DataSource,
  1803. GUID UNALIGNED *Guid
  1804. );
  1805. PMOFRESOURCE EtwpFindMRByNames(
  1806. LPCWSTR ImagePath,
  1807. LPCWSTR MofResourceName
  1808. );
  1809. #ifdef WMI_USER_MODE
  1810. PMOFCLASS EtwpFindMCByGuid(
  1811. LPGUID Guid
  1812. );
  1813. PMOFCLASS EtwpFindMCByGuidAndBestLanguage(
  1814. LPGUID Guid,
  1815. WORD Language
  1816. );
  1817. PMOFCLASS EtwpFindMCByGuidAndLanguage(
  1818. LPGUID Guid,
  1819. WORD Language
  1820. );
  1821. #endif
  1822. PBINSTANCESET EtwpFindISinGEbyName(
  1823. PBGUIDENTRY GuidEntry,
  1824. PWCHAR InstanceName,
  1825. PULONG InstanceIndex
  1826. );
  1827. PWNODE_HEADER EtwpGenerateRegistrationNotification(
  1828. PBDATASOURCE DataSource,
  1829. PWNODE_HEADER Wnode,
  1830. ULONG GuidMax,
  1831. ULONG NotificationCode
  1832. );
  1833. BOOLEAN
  1834. EtwpIsControlGuid(
  1835. PBGUIDENTRY GuidEntry
  1836. );
  1837. void EtwpGenerateMofResourceNotification(
  1838. LPWSTR ImagePath,
  1839. LPWSTR ResourceName,
  1840. LPCGUID Guid
  1841. );
  1842. //
  1843. // wbem.c
  1844. ULONG EtwpBuildMofClassInfo(
  1845. PBDATASOURCE DataSource,
  1846. LPWSTR ImagePath,
  1847. LPWSTR MofResourceName,
  1848. PBOOLEAN NewMofResource
  1849. );
  1850. ULONG EtwpReadBuiltinMof(
  1851. void
  1852. );
  1853. //
  1854. // from krnlmode.c
  1855. ULONG EtwpInitializeKM(
  1856. HANDLE *WmiKMHandle
  1857. );
  1858. void EtwpKMNonEventNotification(
  1859. HANDLE WmiKMHandle,
  1860. PWNODE_HEADER Wnode
  1861. );
  1862. //
  1863. // main.c
  1864. extern HANDLE EtwpRestrictedToken;
  1865. NTSTATUS EtwpGetRegistryValue(
  1866. TCHAR *ValueName,
  1867. PULONG Value
  1868. );
  1869. ULONG WmiRunService(
  1870. ULONG Context
  1871. #ifdef MEMPHIS
  1872. , HINSTANCE InstanceHandle
  1873. #endif
  1874. );
  1875. ULONG EtwpInitializeAccess(
  1876. PTCHAR *RpcStringBinding
  1877. );
  1878. void WmiTerminateService(
  1879. void
  1880. );
  1881. ULONG WmiInitializeService(
  1882. void
  1883. );
  1884. void WmiDeinitializeService(
  1885. void
  1886. );
  1887. void EtwpEventNotification(
  1888. PWNODE_HEADER Wnode,
  1889. BOOLEAN SingleEvent,
  1890. ULONG EventSizeGuess
  1891. );
  1892. #define EtwpBuildRegistrationNotification(Wnode, WnodeSize, NotificationCode, GuidCount) { \
  1893. memset(Wnode, 0, sizeof(WNODE_HEADER)); \
  1894. memcpy(&Wnode->Guid, &RegChangeNotificationGuid, sizeof(GUID)); \
  1895. Wnode->BufferSize = WnodeSize; \
  1896. Wnode->Linkage = NotificationCode; \
  1897. Wnode->Version = GuidCount; \
  1898. Wnode->Flags = WNODE_FLAG_INTERNAL; \
  1899. }
  1900. void EtwpSendQueuedEvents(
  1901. void
  1902. );
  1903. ULONG EtwpCleanupDataConsumer(
  1904. PDCENTRY DataConsumer
  1905. #if DBG
  1906. ,BOOLEAN *NotificationsEnabled,
  1907. BOOLEAN *CollectionsEnabled
  1908. #endif
  1909. );
  1910. //
  1911. // This defines the maximum number of replacement strings over all of the
  1912. // event messages.
  1913. #define MAX_MESSAGE_STRINGS 2
  1914. void __cdecl EtwpReportEventLog(
  1915. ULONG MessageCode,
  1916. WORD MessageType,
  1917. WORD MessageCategory,
  1918. DWORD RawDataSize,
  1919. PVOID RawData,
  1920. WORD StringCount,
  1921. ...
  1922. );
  1923. #ifdef MEMPHIS
  1924. long WINAPI
  1925. DeviceNotificationWndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
  1926. void EtwpDestroyDeviceNotificationWindow(
  1927. HINSTANCE InstanceHandle,
  1928. HWND WindowHandle
  1929. );
  1930. ULONG EtwpCreateDeviceNotificationWindow(
  1931. HINSTANCE InstanceHandle,
  1932. HWND *DeviceNotificationWindow
  1933. );
  1934. #endif
  1935. //
  1936. // server.c
  1937. void EtwpRpcServerDeinitialize(
  1938. void
  1939. );
  1940. ULONG EtwpRpcServerInitialize(
  1941. void
  1942. );
  1943. ULONG EtwpDeliverWnodeToDS(
  1944. ULONG ActionCode,
  1945. PBDATASOURCE DataSource,
  1946. PWNODE_HEADER Wnode
  1947. );
  1948. ULONG EtwpDoDisableRequest(
  1949. PNOTIFICATIONENTRY NotificationEntry,
  1950. PBGUIDENTRY GuidEntry,
  1951. BOOLEAN IsEvent,
  1952. BOOLEAN IsTraceLog,
  1953. ULONG64 LoggerContext,
  1954. ULONG InProgressFlag
  1955. );
  1956. ULONG CollectOrEventWorker(
  1957. PDCENTRY DataConsumer,
  1958. LPGUID Guid,
  1959. BOOLEAN Enable,
  1960. BOOLEAN IsEvent,
  1961. ULONG *NotificationCookie,
  1962. ULONG64 LoggerContext,
  1963. ULONG NotificationFlags
  1964. );
  1965. ULONG EtwpCreateRestrictedToken(
  1966. HANDLE *RestrictedToken
  1967. );
  1968. void EtwpShowPrivs(
  1969. HANDLE TokenHandle
  1970. );
  1971. #ifdef MEMPHIS
  1972. #define EtwpRestrictToken(Token) (ERROR_SUCCESS)
  1973. #define EtwpUnrestrictToken() (ERROR_SUCCESS)
  1974. #else
  1975. ULONG EtwpRestrictToken(
  1976. HANDLE RestrictedToken
  1977. );
  1978. ULONG EtwpUnrestrictToken(
  1979. void
  1980. );
  1981. ULONG EtwpServiceDisableTraceProviders(
  1982. PWNODE_HEADER Wnode
  1983. );
  1984. #endif
  1985. void EtwpReleaseCollectionEnabled(
  1986. PNOTIFICATIONENTRY NotificationEntry
  1987. );
  1988. //
  1989. // chunk.c
  1990. ULONG UnicodeToAnsi(
  1991. LPCWSTR pszW,
  1992. LPSTR * ppszA,
  1993. ULONG *AnsiSizeInBytes OPTIONAL
  1994. );
  1995. ULONG AnsiToUnicode(
  1996. LPCSTR pszA,
  1997. LPWSTR * ppszW
  1998. );
  1999. ULONG AnsiSizeForUnicodeString(
  2000. PWCHAR UnicodeString,
  2001. ULONG *AnsiSizeInBytes
  2002. );
  2003. ULONG UnicodeSizeForAnsiString(
  2004. LPCSTR AnsiString,
  2005. ULONG *UnicodeSizeInBytes
  2006. );
  2007. //
  2008. // debug.c
  2009. #if DBG
  2010. void EtwpDumpIS(
  2011. PBINSTANCESET IS,
  2012. BOOLEAN RecurseGE,
  2013. BOOLEAN RecurseDS
  2014. );
  2015. void EtwpDumpGE(
  2016. PBGUIDENTRY GE,
  2017. BOOLEAN RecurseIS
  2018. );
  2019. void EtwpDumpDS(
  2020. PBDATASOURCE DS,
  2021. BOOLEAN RecurseIS
  2022. );
  2023. void EtwpDumpAllDS(
  2024. void
  2025. );
  2026. #endif
  2027. #ifndef MEMPHIS
  2028. typedef enum
  2029. {
  2030. TRACELOG_START = 0,
  2031. TRACELOG_STOP = 1,
  2032. TRACELOG_QUERY = 2,
  2033. TRACELOG_QUERYALL = 3,
  2034. TRACELOG_QUERYENABLED = 4,
  2035. TRACELOG_UPDATE = 5,
  2036. TRACELOG_FLUSH = 6
  2037. } TRACEREQUESTCODE;
  2038. typedef struct _WMI_REF_CLOCK {
  2039. LARGE_INTEGER StartTime;
  2040. LARGE_INTEGER StartPerfClock;
  2041. } WMI_REF_CLOCK, *PWMI_REF_CLOCK;
  2042. //
  2043. // logsup.c
  2044. ULONG
  2045. WmiUnregisterGuids(
  2046. IN WMIHANDLE WMIHandle,
  2047. IN LPGUID Guid,
  2048. OUT ULONG64 *LoggerContext
  2049. );
  2050. ULONG
  2051. EtwpAddLogHeaderToLogFile(
  2052. IN OUT PWMI_LOGGER_INFORMATION LoggerInfo,
  2053. IN PWMI_REF_CLOCK RefClock,
  2054. IN ULONG Update
  2055. );
  2056. ULONG
  2057. EtwpStartLogger(
  2058. IN OUT PWMI_LOGGER_INFORMATION LoggerInfo
  2059. );
  2060. ULONG
  2061. EtwpStopLogger(
  2062. IN OUT PWMI_LOGGER_INFORMATION LoggerInfo
  2063. );
  2064. ULONG
  2065. EtwpQueryLogger(
  2066. IN OUT PWMI_LOGGER_INFORMATION LoggerInfo,
  2067. IN ULONG Update
  2068. );
  2069. ULONG
  2070. EtwpFlushLogger(
  2071. IN OUT PWMI_LOGGER_INFORMATION LoggerInfo
  2072. );
  2073. VOID
  2074. EtwpInitString(
  2075. IN PVOID Destination,
  2076. IN PVOID Buffer,
  2077. IN ULONG Size
  2078. );
  2079. ULONG
  2080. EtwpGetTraceRegKeys(
  2081. );
  2082. ULONG
  2083. EtwpFinalizeLogFileHeader(
  2084. IN PWMI_LOGGER_INFORMATION LoggerInfo
  2085. );
  2086. ULONG
  2087. EtwpRelogHeaderToLogFile(
  2088. IN OUT PWMI_LOGGER_INFORMATION LoggerInfo ,
  2089. IN PSYSTEM_TRACE_HEADER RelogProp
  2090. );
  2091. //
  2092. // umlog.c
  2093. BOOLEAN
  2094. FASTCALL
  2095. EtwpIsPrivateLoggerOn();
  2096. ULONG
  2097. EtwpSendUmLogRequest(
  2098. IN WMITRACECODE RequestCode,
  2099. IN OUT PWMI_LOGGER_INFORMATION LoggerInfo
  2100. );
  2101. ULONG
  2102. FASTCALL
  2103. EtwpTraceUmEvent(
  2104. IN PWNODE_HEADER Wnode
  2105. );
  2106. NTSTATUS
  2107. EtwpTraceUmMessage(
  2108. IN ULONG Size,
  2109. IN ULONG64 LoggerHandle,
  2110. IN ULONG MessageFlags,
  2111. IN LPGUID MessageGuid,
  2112. IN USHORT MessageNumber,
  2113. va_list MessageArgList
  2114. );
  2115. #endif