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.

1578 lines
41 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. wmikmp.h
  5. Abstract:
  6. Private header for WMI kernel mode component
  7. Author:
  8. AlanWar
  9. Environment:
  10. Revision History:
  11. --*/
  12. #ifndef _WMIKMP_
  13. #define _WMIKMP_
  14. #pragma warning(disable:4214) // bit field types other than int
  15. #pragma warning(disable:4201) // nameless struct/union
  16. #pragma warning(disable:4324) // alignment sensitive to declspec
  17. #pragma warning(disable:4127) // condition expression is constant
  18. #pragma warning(disable:4115) // named type definition in parentheses
  19. #pragma warning(disable:4706) // assignment inside conditional
  20. #pragma warning(disable:4327) // LHS indirection alignment is greater
  21. #pragma warning(disable:4328) // parameter alignment is greater
  22. //
  23. // Define this to cause no security descriptor to be placed on the service
  24. // device. This should never be defined for released builds; it is only
  25. // needed when debugging the service startup code.
  26. //#define NO_SERVICE_DEVICE_SECURITY
  27. //
  28. // define this to get allocation debug info
  29. //#define DEBUG_ALLOCS
  30. #ifdef MEMPHIS
  31. //
  32. // In building for memphis we include WDM.h which defines the WMI apis as
  33. // DECLSPEC_IMPORT which we don't want. So we redefine the api names around
  34. // the inclusion of WDM.h.
  35. //
  36. #define IoWMIRegistrationControl IoWMIRegistrationControlImport
  37. #define IoWMIAllocateInstanceIds IoWMIAllocateInstanceIdsImport
  38. #define IoWMISuggestInstanceName IoWMISuggestInstanceNameImport
  39. #define IoWMIWriteEvent IoWMIWriteEventImport
  40. #endif
  41. #ifdef MEMPHIS
  42. #define UNICODE
  43. #define WANTVXDWRAPS
  44. #include <wdm.h>
  45. #include <poclass.h>
  46. #include <basedef.h>
  47. #include <regstr.h>
  48. #include <vmm.h>
  49. #include <vmmreg.h>
  50. #include <shell.h>
  51. #include <vpicd.h>
  52. #include <vxdldr.h>
  53. #include <ntkern.h>
  54. #include <vpowerd.h>
  55. #include <vxdwraps.h>
  56. #include <configmg.h>
  57. #include <devinfo.h>
  58. #include <stdarg.h>
  59. #else
  60. #include "ntos.h"
  61. #include "zwapi.h"
  62. #ifndef IsEqualGUID
  63. #define IsEqualGUID(guid1, guid2) \
  64. (!memcmp((guid1), (guid2), sizeof(GUID)))
  65. #endif
  66. #if DBG
  67. //
  68. // Debug levels are bit masks and are not cumulative. So if you want to see
  69. // All errors and warnings you need to have bits 0 and 1 set.
  70. //
  71. // Mask for WMICORE is in variable nt!Kd_WMICORE_Mask
  72. //
  73. // Registry can be setup with initial mask value for nt!Kd_WMICORE_Mask by
  74. // setting up a DWORD value named WMICORE under key
  75. // HKLM\System\CurrnetControlSet\Control\Session Manager\Debug Print Filter
  76. //
  77. // Standard levels are
  78. // DPFLTR_ERROR_LEVEL 0 0x00000001
  79. // DPFLTR_WARNING_LEVEL 1 0x00000002
  80. // DPFLTR_TRACE_LEVEL 2 0x00000004
  81. // DPFLTR_INFO_LEVEL 3 0x00000008
  82. //
  83. // Custom debug print levels are 4 through 31
  84. //
  85. #define DPFLTR_MCA_LEVEL 4 // 0x00000010
  86. #define DPFLTR_OBJECT_LEVEL 5 // 0x00000020
  87. #define DPFLTR_API_INFO_LEVEL 6 // 0x00000040
  88. #define DPFLTR_EVENT_INFO_LEVEL 7 // 0x00000080
  89. #define DPFLTR_REGISTRATION_LEVEL 8 // 0x00000100
  90. #define WMICORE_INFO DPFLTR_WMICORE_ID, DPFLTR_INFO_LEVEL
  91. #define WmipDebugPrintEx(_x_) DbgPrintEx _x_
  92. #else
  93. #define WmipDebugPrintEx(_x_)
  94. #endif // if DBG
  95. #endif // ifdef MEMPHIS
  96. #include "wmiguid.h"
  97. #include "wmidata.h"
  98. #include <stdio.h>
  99. #ifndef MEMPHIS
  100. extern POBJECT_TYPE IoFileObjectType;
  101. #endif
  102. #ifdef MEMPHIS
  103. #undef IoWMIRegistrationControl
  104. #undef IoWMIAllocateInstanceIds
  105. #undef IoWMISuggestInstanceName
  106. #undef IoWMIWriteEvent
  107. #endif
  108. #include "wmistr.h"
  109. #include "wmiumkm.h"
  110. #include <wmi.h>
  111. NTSTATUS IoWMIAllocateInstanceIds(
  112. IN GUID *Guid,
  113. IN ULONG InstanceCount,
  114. OUT ULONG *FirstInstanceId
  115. );
  116. NTKERNELAPI
  117. NTSTATUS
  118. IoCreateDriver (
  119. IN PUNICODE_STRING DriverName, OPTIONAL
  120. IN PDRIVER_INITIALIZE InitializationFunction
  121. );
  122. #define WmipAssert ASSERT
  123. #define WMIPOOLTAG 'pimW'
  124. #define WMINCPOOLTAG 'nimW'
  125. #define WMINPPOOLTAG 'NimW'
  126. #define WMINWPOOLTAG 'wimW'
  127. #define WMIMSGPOOLTAG 'mimW'
  128. #define WMIIIPOOLTAG 'iimW'
  129. #define WMIREGPOOLTAG 'RimW'
  130. #define WMISYSIDPOOLTAG 'simW'
  131. #define WmipRegisterDSPoolTag 'DimW'
  132. #define WMIPSCHEDPOOLTAG 'gaiD'
  133. #define WmipMCAPoolTag 'acMW'
  134. #define WmipInstanceNameTag 'IimW'
  135. #define WMI_GM_POOLTAG 'jimW'
  136. #define WMIPCREATETHREADTAG 'CimW'
  137. #define OffsetToPtr(Base, Offset) ((PUCHAR)((PUCHAR)(Base) + (Offset)))
  138. //
  139. // Maximum size allowed for any WNODE_EVENT_ITEM
  140. #define DEFAULTMAXKMWNODEEVENTSIZE 0x80000
  141. #define LARGEKMWNODEEVENTSIZE 512
  142. typedef struct
  143. {
  144. ULONG BufferSize;
  145. PUCHAR Buffer;
  146. } REGQUERYBUFFERXFER, *PREGQUERYBUFFERXFER;
  147. //
  148. // We have got a single Mutex/Critical Section for the entire WMI KM code
  149. // It is used anytime that access needs to be serialized. Typically it is
  150. // used in the following cases:
  151. //
  152. // 1. Access to the internal data structures that contain the registration
  153. // list, guid entries, data sources, etc.
  154. //
  155. // 2. Synchronize collecting SMBIOS information
  156. //
  157. // 3. Tracelog purposes
  158. //
  159. // 4. Updating the device stack size
  160. //
  161. extern KMUTEX WmipSMMutex;
  162. _inline NTSTATUS WmipEnterCritSection(
  163. BOOLEAN AllowAPC
  164. )
  165. {
  166. NTSTATUS status;
  167. do
  168. {
  169. status = KeWaitForMutexObject(&WmipSMMutex,
  170. Executive,
  171. KernelMode,
  172. AllowAPC,
  173. NULL);
  174. } while((status == STATUS_ALERTED) ||
  175. (status == STATUS_USER_APC));
  176. return(status);
  177. }
  178. _inline void WmipLeaveCritSection(
  179. )
  180. {
  181. KeReleaseMutex(&WmipSMMutex,
  182. FALSE);
  183. }
  184. //
  185. // SMCritSection does not allows APCs to occur while the mutex is held.
  186. //
  187. #define WmipEnterSMCritSection() WmipEnterCritSection(FALSE)
  188. #define WmipLeaveSMCritSection() WmipLeaveCritSection()
  189. //
  190. // Tracelog Critical section is to serialize the Enabling and disabling
  191. // of trace control guids. Since we want to allow Updates (enable a
  192. // a Guid with a different set of flags and levels), we serialize this
  193. // operation to reduce complexity of code.
  194. //
  195. // NOTE: TraceCritSection must not be taken with SMCritSection held.
  196. // Bad Deadlocks will result if that happens.
  197. //
  198. extern KMUTEX WmipTLMutex;
  199. _inline NTSTATUS WmipEnterTraceCritSection(
  200. BOOLEAN AllowAPC
  201. )
  202. {
  203. NTSTATUS status;
  204. do
  205. {
  206. status = KeWaitForMutexObject(&WmipTLMutex,
  207. Executive,
  208. KernelMode,
  209. AllowAPC,
  210. NULL);
  211. } while((status == STATUS_ALERTED) ||
  212. (status == STATUS_USER_APC));
  213. return(status);
  214. }
  215. _inline void WmipLeaveTraceCritSection(
  216. )
  217. {
  218. KeReleaseMutex(&WmipTLMutex,
  219. FALSE);
  220. }
  221. //
  222. // TLCritSection does not allows APCs to occur while the mutex is held.
  223. //
  224. #define WmipEnterTLCritSection() WmipEnterTraceCritSection(FALSE);
  225. #define WmipLeaveTLCritSection() WmipLeaveTraceCritSection();
  226. //
  227. // This defines the stack size that the WMI device starts with. Since
  228. // WMI irps will be forwarded any WMI data provider the WMI device must have
  229. // more stack locations than the largest driver to which it forwards irps.
  230. #define WmiDeviceStackSize 2
  231. /////////////////////////////////////////////////////////////////////////////
  232. // Device Registration Data structures
  233. //
  234. // Each WMI providing device object and callback is maintained in a REGENTRY
  235. // structure which is allocated in chunks. Each entry is referenced by the
  236. // Device object or the callback address. The WMI user mode service is given
  237. // info from RegEntry structure, and is generally only interested in the
  238. // DeviceObject (or WmiEntry) and flags. The user mode side uses the device
  239. // object (or WmiEntry) as its "handle" to the data provider and is referred
  240. // to as ProviderId in the user mode code.
  241. //
  242. struct tagDATASOURCE;
  243. typedef struct _REGENTRY
  244. {
  245. LIST_ENTRY InUseEntryList; // Node in list of in use entries
  246. union
  247. {
  248. PDEVICE_OBJECT DeviceObject; // Device object of registered device
  249. #ifndef MEMPHIS
  250. WMIENTRY * WmiEntry; // Pointer to a pointer to Callback function
  251. #endif
  252. };
  253. LONG RefCount; // Reference Count
  254. LONG Flags; // Registration flags
  255. PDEVICE_OBJECT PDO; // PDO associated with device
  256. ULONG MaxInstanceNames; // # instance names for device
  257. LONG IrpCount; // Count of IRPs currently active
  258. ULONG ProviderId; // Provider Id
  259. struct tagDATASOURCE *DataSource; // Datasource associated with regentry
  260. KEVENT Event; // Event used to synchronize unloading
  261. } REGENTRY, *PREGENTRY;
  262. #define REGENTRY_FLAG_INUSE 0x00000001 // Entry is in use (not free)
  263. #define REGENTRY_FLAG_CALLBACK 0x00000002 // Entry represents a callback
  264. #define REGENTRY_FLAG_NEWREGINFO 0x00000004 // Entry has new registration info
  265. #define REGENTRY_FLAG_UPDREGINFO 0x00000008 // Entry has updated registration info
  266. // When set do not forward irps to the device
  267. #define REGENTRY_FLAG_NOT_ACCEPTING_IRPS 0x00000010
  268. #define REGENTRY_FLAG_TOO_SMALL 0x00000020
  269. #define REGENTRY_FLAG_TRACED 0x00000040 // Entry represents traced device
  270. // When set device is being rundown.
  271. #define REGENTRY_FLAG_RUNDOWN 0x00000080
  272. // Entry is in process of registering
  273. #define REGENTRY_FLAG_REG_IN_PROGRESS 0x00000100
  274. // Entry is UM data provider
  275. #define REGENTRY_FLAG_UM_PROVIDER 0x00000200
  276. #define REGENTRY_FLAG_TRACE_NOTIFY_MASK 0x000F0000 // Reserved for callouts
  277. #define WmipSetKmRegInfo(KmRegInfoPtr, RegEntryPtr) \
  278. { \
  279. (KmRegInfoPtr)->ProviderId = (RegEntryPtr)->ProviderId; \
  280. (KmRegInfoPtr)->Flags = (RegEntryPtr)->Flags; \
  281. }
  282. typedef enum _REGOPERATION
  283. {
  284. RegisterAllDrivers,
  285. RegisterSingleDriver,
  286. RegisterUpdateSingleDriver,
  287. RegisterDeleteSingleDriver
  288. } REGOPERATION, *PREGOPERATION;
  289. typedef struct _REGISTRATIONWORKITEM
  290. {
  291. LIST_ENTRY ListEntry;
  292. REGOPERATION RegOperation;
  293. PREGENTRY RegEntry;
  294. } REGISTRATIONWORKITEM, *PREGISTRATIONWORKITEM;
  295. typedef struct
  296. {
  297. LIST_ENTRY ListEntry;
  298. PREGENTRY RegEntry;
  299. PWNODE_HEADER Wnode;
  300. } EVENTWORKCONTEXT, *PEVENTWORKCONTEXT;
  301. typedef struct
  302. {
  303. WORK_QUEUE_ITEM WorkItem;
  304. PVOID Object;
  305. } CREATETHREADWORKITEM, *PCREATETHREADWORKITEM;
  306. /////////////////////////////////////////////////////////////////////////////
  307. // InstanceId management data structures
  308. //
  309. // This defines the number of INSTID structures in a chunk
  310. #define INSTIDSPERCHUNK 8
  311. typedef struct
  312. {
  313. GUID Guid; // Guid
  314. ULONG BaseId; // Next instance id for guid
  315. } INSTID, *PINSTID;
  316. typedef struct tagINSTIDCHUNK
  317. {
  318. struct tagINSTIDCHUNK *Next; // Next chunk of INSTIDS
  319. INSTID InstId[INSTIDSPERCHUNK];
  320. } INSTIDCHUNK, *PINSTIDCHUNK;
  321. //
  322. // TODO: Move from separate header into here
  323. #include "wmiumds.h"
  324. #define WmipBuildWnodeTooSmall(Wnode, BufferSizeNeeded) \
  325. ((PWNODE_TOO_SMALL)Wnode)->WnodeHeader.BufferSize = sizeof(WNODE_TOO_SMALL);\
  326. ((PWNODE_TOO_SMALL)Wnode)->WnodeHeader.Flags = WNODE_FLAG_TOO_SMALL; \
  327. ((PWNODE_TOO_SMALL)Wnode)->SizeNeeded = BufferSizeNeeded;
  328. typedef struct
  329. {
  330. BOOLEAN Used20CallingMethod;
  331. UCHAR SMBiosMajorVersion;
  332. UCHAR SMBiosMinorVersion;
  333. UCHAR DMIBiosRevision;
  334. } SMBIOSVERSIONINFO, *PSMBIOSVERSIONINFO;
  335. //
  336. // See smbios spec for System Event Log (Type 15) for detailed information
  337. // on the contents of this structurre. The layout from element LogAreaLength
  338. // to VariableData must match the layout of the SMBIOS System Eventlog
  339. // structure as defined in the smbios spec and smbios.h.
  340. //
  341. typedef struct
  342. {
  343. USHORT LogTypeDescLength;
  344. UCHAR LogHeaderDescExists;
  345. UCHAR Reserved;
  346. USHORT LogAreaLength;
  347. USHORT LogHeaderStart;
  348. USHORT LogDataStart;
  349. UCHAR AccessMethod;
  350. UCHAR LogStatus;
  351. ULONG LogChangeToken;
  352. ULONG AccessMethodAddress;
  353. //
  354. // LogHeaderFormat, NumberLogTypeDesc, LengthEachLogTypeDesc and
  355. // ListLogTypeDesc are only valid if LogHeaderDescExists is TRUE.
  356. // This means that SMBIOS is revision 2.1
  357. //
  358. UCHAR LogHeaderFormat;
  359. UCHAR NumberLogTypeDesc;
  360. UCHAR LengthEachLogTypeDesc;
  361. //
  362. // Within the variable data is the Log Type descriptors immediately
  363. // followed by the Eventlog area. The size of the Log Type Descriptors
  364. // is LogTypeDescLength bytes and the size of the Eventlog area is
  365. // LogAreaLength
  366. //
  367. UCHAR VariableData[1];
  368. } SMBIOS_EVENTLOG_INFO, *PSMBIOS_EVENTLOG_INFO;
  369. //
  370. // WMI service device extension
  371. extern PDEVICE_OBJECT WmipServiceDeviceObject;
  372. #define WmipIsWmiNotSetupProperly() (WmipServiceDeviceObject == NULL)
  373. typedef struct
  374. {
  375. PREGENTRY RegEntry;
  376. KEVENT Event;
  377. } IRPCOMPCTX, *PIRPCOMPCTX;
  378. //
  379. // This defines the WMI Guid object. There are really 5 different type of
  380. // objects that are created from this data structure:
  381. //
  382. // QuerySet Object returned to the data consumer to allow them to
  383. // send queries and sets to a particular set of providers. It
  384. // does not use a flag.
  385. //
  386. // Notification Object is used by data consumers to receive events. It
  387. // is created when a data consumer wants to receive an event for a
  388. // particular guid and queues up the received events until they are
  389. // retrieved by the consumer. When the object is deleted it is
  390. // removed from the list of objects maintianed by a GuidEntry and
  391. // a event disable request is sent to the devices that expose
  392. // the events if this is the last object open to the event.
  393. // These have no flag set
  394. //
  395. // Request Object is created on behalf of a user mode data provider
  396. // when it registers its guids with WMI. It acts like a Notification
  397. // object in that requests (in the form of events) are received
  398. // by it and then can be picked up by the user mode creator. It uses
  399. // the WMIGUID_FLAG_REQUEST_OBJECT flag. When a Request Object is
  400. // being deleted it will clean up any guids registered for it and
  401. // send a reply message to any reply objects waiting to receive
  402. // a message from it.
  403. //
  404. // Reply Object is created as a product of Creating a user mode logger.
  405. // This object acts as a notification object to deliver replies
  406. // sent by request objects. When it is closed it will remove itself
  407. // from any request list that it may be part of and clear the
  408. // reference to it in any request objects and deref itself to account
  409. // for that. These use the WMIGUID_FLAG_REPLY_OBJECT flag
  410. //
  411. // Security Objects are created so that the security apis can have
  412. // a mechanism to change the security descriptors for the guids
  413. // These have the WMIGUID_FLAG_SECURITY_OBJECT
  414. // This defines the maximum number of outstanding requests that can
  415. // be sent to a request object
  416. #define MAXREQREPLYSLOTS 4
  417. typedef struct
  418. {
  419. struct _WMIGUIDOBJECT *ReplyObject;
  420. LIST_ENTRY RequestListEntry;
  421. } MBREQUESTS, *PMBREQUESTS;
  422. //
  423. // This data structure is used to maintain a fixed sized queue of events
  424. // waiting to be delivered to a user mdoe consumer.
  425. //
  426. typedef struct
  427. {
  428. PUCHAR Buffer; // Buffer that holds events waiting
  429. PWNODE_HEADER LastWnode; // Last event so we can link to next
  430. ULONG MaxBufferSize; // Max size of events that can be held
  431. ULONG NextOffset; // Offset in buffer to next place to store
  432. ULONG EventsLost; // # events lost
  433. } WMIEVENTQUEUE, *PWMIEVENTQUEUE;
  434. typedef struct _WMIGUIDOBJECT
  435. {
  436. KEVENT Event;
  437. union
  438. {
  439. GUID Guid;
  440. PREGENTRY RegEntry;
  441. };
  442. // Entry in linked list of objects for this guid
  443. LIST_ENTRY GEObjectList;
  444. PBGUIDENTRY GuidEntry;
  445. ULONG Type; // Type of object
  446. union
  447. {
  448. //
  449. // Kernel mode event receiver - all we need is a callback &
  450. // context
  451. //
  452. struct
  453. {
  454. WMI_NOTIFICATION_CALLBACK Callback;
  455. PVOID CallbackContext;
  456. };
  457. struct
  458. {
  459. //
  460. // User mode Queued up event management
  461. //
  462. //
  463. // Info on how to startup a new pump thread
  464. //
  465. LIST_ENTRY ThreadObjectList;
  466. HANDLE UserModeProcess;
  467. PUSER_THREAD_START_ROUTINE UserModeCallback;
  468. SIZE_T StackSize;
  469. SIZE_T StackCommit;
  470. //
  471. // Info for request waiting to be completed
  472. //
  473. PIRP Irp; // Irp waiting for event from this object
  474. // Entry in list objects associated with an irp
  475. LIST_ENTRY IrpObjectList;
  476. // What to do when an event is queued
  477. ULONG EventQueueAction;
  478. WMIEVENTQUEUE HiPriority;// Hi priority event queue
  479. WMIEVENTQUEUE LoPriority;// Lo priority event queue
  480. };
  481. };
  482. BOOLEAN EnableRequestSent;
  483. //
  484. // MB management
  485. //
  486. union
  487. {
  488. LIST_ENTRY RequestListHead; // Head of request list (reply object)
  489. // (request object)
  490. MBREQUESTS MBRequests[MAXREQREPLYSLOTS];
  491. };
  492. ULONG Cookie;
  493. ULONG Flags;
  494. } WMIGUIDOBJECT, *PWMIGUIDOBJECT;
  495. // Set if the guid is a request object, that is receives requests
  496. #define WMIGUID_FLAG_REQUEST_OBJECT 0x00000001
  497. // Set if the guid is a reply object, that is receives replies
  498. #define WMIGUID_FLAG_REPLY_OBJECT 0x00000002
  499. // Set if the guid is a security object
  500. #define WMIGUID_FLAG_SECURITY_OBJECT 0x00000004
  501. // Set if the guid is a kernel mode notification object, that is there
  502. // is kernel mode code that wants a callback when an event is received
  503. #define WMIGUID_FLAG_KERNEL_NOTIFICATION 0x00000008
  504. // Set if the guid object is marked for pending closure, so no events
  505. // should be queued to it
  506. #define WMIGUID_FLAG_RECEIVE_NO_EVENTS 0x00000010
  507. typedef struct
  508. {
  509. PWMIGUIDOBJECT GuidObject;
  510. PWNODE_HEADER NextWnode;
  511. } OBJECT_EVENT_INFO, *POBJECT_EVENT_INFO;
  512. // NTSTATUS ValidateWnodeHeader(
  513. // PWNODE_HEADER Wnode,
  514. // ULONG BufSize,
  515. // ULONG BufferSizeMin,
  516. // ULONG RequiredFlags,
  517. // ULONG ProhibitedFlags
  518. // );
  519. #define WmipValidateWnodeHeader( \
  520. Wnode, \
  521. BufSize, \
  522. BufferSizeMin, \
  523. RequiredFlags, \
  524. ProhibitedFlags \
  525. ) \
  526. (( (BufSize < BufferSizeMin) || \
  527. ( (Wnode->Flags & RequiredFlags) != RequiredFlags) || \
  528. (BufSize != Wnode->BufferSize) || \
  529. ( (Wnode->Flags & ProhibitedFlags) != 0)) ? \
  530. STATUS_UNSUCCESSFUL : STATUS_SUCCESS)
  531. #define WmipIsAligned( Value, Alignment ) \
  532. ( ( (((ULONG_PTR)Value)+(Alignment-1)) & ~(Alignment-1) ) == ((ULONG_PTR)Value) )
  533. typedef struct
  534. {
  535. GUID Guid; // Guid to registered
  536. ULONG InstanceCount; // Count of Instances of Datablock
  537. ULONG Flags; // Additional flags (see WMIREGINFO in wmistr.h)
  538. } GUIDREGINFO, *PGUIDREGINFO;
  539. typedef
  540. NTSTATUS
  541. (*PQUERY_WMI_REGINFO) (
  542. IN PDEVICE_OBJECT DeviceObject,
  543. OUT PULONG RegFlags,
  544. OUT PUNICODE_STRING Name,
  545. OUT PUNICODE_STRING *RegistryPath
  546. );
  547. /*++
  548. Routine Description:
  549. This routine is a callback into the driver to retrieve information about
  550. the guids being registered.
  551. Arguments:
  552. DeviceObject is the device whose registration information is needed
  553. *RegFlags returns with a set of flags that describe the guids being
  554. registered for this device. If the device wants enable and disable
  555. collection callbacks before receiving queries for the registered
  556. guids then it should return the WMIREG_FLAG_EXPENSIVE flag. Also the
  557. returned flags may specify WMIREG_FLAG_INSTANCE_PDO in which case
  558. the instance name is determined from the PDO associated with the
  559. device object. Note that the PDO must have an associated devnode. If
  560. WMIREG_FLAG_INSTANCE_PDO is not set then Name must return a unique
  561. name for the device.
  562. Name returns with the instance name for the guids if
  563. WMIREG_FLAG_INSTANCE_PDO is not set in the returned *RegFlags. The
  564. caller will call ExFreePool with the buffer returned.
  565. *RegistryPath returns with the registry path of the driver
  566. Return Value:
  567. status
  568. --*/
  569. typedef
  570. NTSTATUS
  571. (*PQUERY_WMI_DATABLOCK) (
  572. IN PDEVICE_OBJECT DeviceObject,
  573. IN PIRP Irp,
  574. IN ULONG GuidIndex,
  575. IN ULONG InstanceIndex,
  576. IN ULONG InstanceCount,
  577. IN OUT PULONG InstanceLengthArray,
  578. IN ULONG BufferAvail,
  579. OUT PUCHAR Buffer
  580. );
  581. /*++
  582. Routine Description:
  583. This routine is a callback into the driver to query for the contents of
  584. all instances of a data block. When the driver has finished filling the
  585. data block it must call IoWMICompleteRequest to complete the irp. The
  586. driver can return STATUS_PENDING if the irp cannot be completed
  587. immediately.
  588. Arguments:
  589. DeviceObject is the device whose data block is being queried
  590. Irp is the Irp that makes this request
  591. GuidIndex is the index into the list of guids provided when the
  592. device registered
  593. InstanceIndex is the index that denotes which instance of the data block
  594. is being queried.
  595. InstanceCount is the number of instnaces expected to be returned for
  596. the data block.
  597. InstanceLengthArray is a pointer to an array of ULONG that returns the
  598. lengths of each instance of the data block. If this is NULL then
  599. there was not enough space in the output buffer to fufill the request
  600. so the irp should be completed with the buffer needed.
  601. BufferAvail on entry has the maximum size available to write the data
  602. blocks.
  603. Buffer on return is filled with the returned data blocks. Note that each
  604. instance of the data block must be aligned on a 8 byte boundry. If
  605. this is NULL then there was not enough space in the output buffer
  606. to fufill the request so the irp should be completed with the buffer
  607. needed.
  608. Return Value:
  609. status
  610. --*/
  611. typedef
  612. NTSTATUS
  613. (*PSET_WMI_DATABLOCK) (
  614. IN PDEVICE_OBJECT DeviceObject,
  615. IN PIRP Irp,
  616. IN ULONG GuidIndex,
  617. IN ULONG InstanceIndex,
  618. IN ULONG BufferSize,
  619. IN PUCHAR Buffer
  620. );
  621. /*++
  622. Routine Description:
  623. This routine is a callback into the driver to query for the contents of
  624. a data block. When the driver has finished filling the data block it
  625. must call IoWMICompleteRequest to complete the irp. The driver can
  626. return STATUS_PENDING if the irp cannot be completed immediately.
  627. Arguments:
  628. DeviceObject is the device whose data block is being queried
  629. Irp is the Irp that makes this request
  630. GuidIndex is the index into the list of guids provided when the
  631. device registered
  632. InstanceIndex is the index that denotes which instance of the data block
  633. is being set.
  634. BufferSize has the size of the data block passed
  635. Buffer has the new values for the data block
  636. Return Value:
  637. status
  638. --*/
  639. typedef
  640. NTSTATUS
  641. (*PSET_WMI_DATAITEM) (
  642. IN PDEVICE_OBJECT DeviceObject,
  643. IN PIRP Irp,
  644. IN ULONG GuidIndex,
  645. IN ULONG InstanceIndex,
  646. IN ULONG DataItemId,
  647. IN ULONG BufferSize,
  648. IN PUCHAR Buffer
  649. );
  650. /*++
  651. Routine Description:
  652. This routine is a callback into the driver to query for the contents of
  653. a data block. When the driver has finished filling the data block it
  654. must call IoWMICompleteRequest to complete the irp. The driver can
  655. return STATUS_PENDING if the irp cannot be completed immediately.
  656. Arguments:
  657. DeviceObject is the device whose data block is being queried
  658. Irp is the Irp that makes this request
  659. GuidIndex is the index into the list of guids provided when the
  660. device registered
  661. InstanceIndex is the index that denotes which instance of the data block
  662. is being set.
  663. DataItemId has the id of the data item being set
  664. BufferSize has the size of the data item passed
  665. Buffer has the new values for the data item
  666. Return Value:
  667. status
  668. --*/
  669. typedef
  670. NTSTATUS
  671. (*PEXECUTE_WMI_METHOD) (
  672. IN PDEVICE_OBJECT DeviceObject,
  673. IN PIRP Irp,
  674. IN ULONG GuidIndex,
  675. IN ULONG InstanceIndex,
  676. IN ULONG MethodId,
  677. IN ULONG InBufferSize,
  678. IN ULONG OutBufferSize,
  679. IN OUT PUCHAR Buffer
  680. );
  681. /*++
  682. Routine Description:
  683. This routine is a callback into the driver to execute a method. When the
  684. driver has finished filling the data block it must call
  685. IoWMICompleteRequest to complete the irp. The driver can
  686. return STATUS_PENDING if the irp cannot be completed immediately.
  687. Arguments:
  688. DeviceObject is the device whose data block is being queried
  689. Irp is the Irp that makes this request
  690. GuidIndex is the index into the list of guids provided when the
  691. device registered
  692. InstanceIndex is the index that denotes which instance of the data block
  693. is being called.
  694. MethodId has the id of the method being called
  695. InBufferSize has the size of the data block passed in as the input to
  696. the method.
  697. OutBufferSize on entry has the maximum size available to write the
  698. returned data block.
  699. Buffer on entry has the input data block and on return has the output
  700. output data block.
  701. Return Value:
  702. status
  703. --*/
  704. typedef enum
  705. {
  706. WmiEventGeneration,
  707. WmiDataBlockCollection
  708. } WMIENABLEDISABLEFUNCTION;
  709. typedef
  710. NTSTATUS
  711. (*PWMI_FUNCTION_CONTROL) (
  712. IN PDEVICE_OBJECT DeviceObject,
  713. IN PIRP Irp,
  714. IN ULONG GuidIndex,
  715. IN WMIENABLEDISABLEFUNCTION Function,
  716. IN BOOLEAN Enable
  717. );
  718. /*++
  719. Routine Description:
  720. This routine is a callback into the driver to enabled or disable event
  721. generation or data block collection. A device should only expect a
  722. single enable when the first event or data consumer enables events or
  723. data collection and a single disable when the last event or data
  724. consumer disables events or data collection. Data blocks will only
  725. receive collection enable/disable if they were registered as requiring
  726. it.
  727. Arguments:
  728. DeviceObject is the device whose data block is being queried
  729. GuidIndex is the index into the list of guids provided when the
  730. device registered
  731. Function specifies which functionality is being enabled or disabled
  732. Enable is TRUE then the function is being enabled else disabled
  733. Return Value:
  734. status
  735. --*/
  736. typedef struct _WMILIB_INFO
  737. {
  738. //
  739. // Next device lower in the stack
  740. PDEVICE_OBJECT LowerDeviceObject;
  741. //
  742. // PDO associated with device
  743. PDEVICE_OBJECT LowerPDO;
  744. //
  745. // WMI data block guid registration info
  746. ULONG GuidCount;
  747. PGUIDREGINFO GuidList;
  748. //
  749. // WMI functionality callbacks
  750. PQUERY_WMI_REGINFO QueryWmiRegInfo;
  751. PQUERY_WMI_DATABLOCK QueryWmiDataBlock;
  752. PSET_WMI_DATABLOCK SetWmiDataBlock;
  753. PSET_WMI_DATAITEM SetWmiDataItem;
  754. PEXECUTE_WMI_METHOD ExecuteWmiMethod;
  755. PWMI_FUNCTION_CONTROL WmiFunctionControl;
  756. } WMILIB_INFO, *PWMILIB_INFO;
  757. NTSTATUS
  758. IoWMICompleteRequest(
  759. IN PWMILIB_INFO WmiLibInfo,
  760. IN PDEVICE_OBJECT DeviceObject,
  761. IN PIRP Irp,
  762. IN NTSTATUS Status,
  763. IN ULONG BufferUsed,
  764. IN CCHAR PriorityBoost
  765. );
  766. NTSTATUS
  767. IoWMISystemControl(
  768. IN PWMILIB_INFO WmiLibInfo,
  769. IN PDEVICE_OBJECT DeviceObject,
  770. IN PIRP Irp
  771. );
  772. NTSTATUS
  773. IoWMIFireEvent(
  774. IN PWMILIB_INFO WmiLibInfo,
  775. IN PDEVICE_OBJECT DeviceObject,
  776. IN ULONG GuidIndex,
  777. IN ULONG EventDataSize,
  778. IN PVOID EventData
  779. );
  780. NTSTATUS IoWMIRegistrationControl(
  781. IN PDEVICE_OBJECT DeviceObject,
  782. IN ULONG Action
  783. );
  784. NTSTATUS IoWMIWriteEvent(
  785. IN PVOID WnodeEventItem
  786. );
  787. // ds.c
  788. extern GUID GUID_REGISTRATION_CHANGE_NOTIFICATION;
  789. extern GUID GUID_MOF_RESOURCE_ADDED_NOTIFICATION;
  790. extern GUID GUID_MOF_RESOURCE_REMOVED_NOTIFICATION;
  791. NTSTATUS WmipEnumerateMofResources(
  792. PWMIMOFLIST MofList,
  793. ULONG BufferSize,
  794. ULONG *RetSize
  795. );
  796. NTSTATUS WmipInitializeDataStructs(
  797. void
  798. );
  799. NTSTATUS WmipRemoveDataSource(
  800. PREGENTRY RegEntry
  801. );
  802. NTSTATUS WmipUpdateDataSource(
  803. PREGENTRY RegEntry,
  804. PWMIREGINFOW RegistrationInfo,
  805. ULONG RetSize
  806. );
  807. NTSTATUS WmipAddDataSource(
  808. IN PREGENTRY RegEntry,
  809. IN PWMIREGINFOW WmiRegInfo,
  810. IN ULONG BufferSize,
  811. IN PWCHAR RegPath,
  812. IN PWCHAR ResourceName,
  813. IN PWMIGUIDOBJECT RequestObject,
  814. IN BOOLEAN IsUserMode
  815. );
  816. #define WmiInsertTimestamp(WnodeHeader) KeQuerySystemTime(&(WnodeHeader)->TimeStamp)
  817. // consumer.c
  818. NTSTATUS WmipMarkHandleAsClosed(
  819. HANDLE Handle
  820. );
  821. NTSTATUS WmipUMProviderCallback(
  822. IN WMIACTIONCODE ActionCode,
  823. IN PVOID DataPath,
  824. IN ULONG BufferSize,
  825. IN OUT PVOID Buffer
  826. );
  827. NTSTATUS WmipOpenBlock(
  828. IN ULONG Ioctl,
  829. IN KPROCESSOR_MODE AccessMode,
  830. IN POBJECT_ATTRIBUTES ObjectAttributes,
  831. IN ULONG DesiredAccess,
  832. OUT PHANDLE Handle
  833. );
  834. NTSTATUS WmipQueryAllData(
  835. IN PWMIGUIDOBJECT GuidObject,
  836. IN PIRP Irp,
  837. IN KPROCESSOR_MODE AccessMode,
  838. IN PWNODE_ALL_DATA Wnode,
  839. IN ULONG OutBufferLen,
  840. OUT PULONG RetSize
  841. );
  842. NTSTATUS WmipQueryAllDataMultiple(
  843. IN ULONG ObjectCount,
  844. IN PWMIGUIDOBJECT *ObjectList,
  845. IN PIRP Irp,
  846. IN KPROCESSOR_MODE AccessMode,
  847. IN OUT PUCHAR BufferPtr,
  848. IN ULONG BufferSize,
  849. IN PWMIQADMULTIPLE QadMultiple,
  850. OUT ULONG *ReturnSize
  851. );
  852. NTSTATUS WmipQuerySingleMultiple(
  853. IN PIRP Irp,
  854. IN KPROCESSOR_MODE AccessMode,
  855. IN OUT PUCHAR BufferPtr,
  856. IN ULONG BufferSize,
  857. IN PWMIQSIMULTIPLE QsiMultiple,
  858. IN ULONG QueryCount,
  859. IN PWMIGUIDOBJECT *ObjectList,
  860. IN PUNICODE_STRING InstanceNames,
  861. OUT ULONG *ReturnSize
  862. );
  863. NTSTATUS WmipQuerySetExecuteSI(
  864. IN PWMIGUIDOBJECT GuidObject,
  865. IN PIRP Irp,
  866. IN KPROCESSOR_MODE AccessMode,
  867. IN UCHAR MinorFunction,
  868. IN OUT PWNODE_HEADER Wnode,
  869. IN ULONG OutBufferSize,
  870. OUT PULONG RetSize
  871. );
  872. NTSTATUS WmipEnumerateGuids(
  873. ULONG Ioctl,
  874. PWMIGUIDLISTINFO GuidList,
  875. ULONG MaxBufferSize,
  876. ULONG *OutBufferSize
  877. );
  878. NTSTATUS WmipProcessEvent(
  879. PWNODE_HEADER Wnode,
  880. BOOLEAN IsHiPriority,
  881. BOOLEAN FreeBuffer
  882. );
  883. NTSTATUS WmipQueryGuidInfo(
  884. IN OUT PWMIQUERYGUIDINFO QueryGuidInfo
  885. );
  886. NTSTATUS WmipReceiveNotifications(
  887. PWMIRECEIVENOTIFICATION ReceiveNotification,
  888. PULONG OutBufferSize,
  889. PIRP Irp
  890. );
  891. void WmipClearIrpObjectList(
  892. PIRP Irp
  893. );
  894. NTSTATUS WmipWriteWnodeToObject(
  895. PWMIGUIDOBJECT Object,
  896. PWNODE_HEADER Wnode,
  897. BOOLEAN IsHighPriority
  898. );
  899. NTSTATUS WmipRegisterUMGuids(
  900. IN POBJECT_ATTRIBUTES ObjectAttributes,
  901. IN ULONG Cookie,
  902. IN PWMIREGINFO RegInfo,
  903. IN ULONG RegInfoSize,
  904. OUT HANDLE *RequestHandle,
  905. OUT ULONG64 *LoggerContext
  906. );
  907. NTSTATUS WmipUnregisterGuids(
  908. PWMIUNREGGUIDS UnregGuids
  909. );
  910. NTSTATUS WmipCreateUMLogger(
  911. IN OUT PWMICREATEUMLOGGER CreateInfo
  912. );
  913. NTSTATUS WmipMBReply(
  914. IN HANDLE RequestHandle,
  915. IN ULONG ReplyIndex,
  916. IN PUCHAR Message,
  917. IN ULONG MessageSize
  918. );
  919. void WmipClearObjectFromThreadList(
  920. PWMIGUIDOBJECT Object
  921. );
  922. // enabdisa.c
  923. #define WmipIsControlGuid(GuidEntry) WmipIsISFlagsSet(GuidEntry, (IS_TRACED | IS_CONTROL_GUID))
  924. #define WmipIsTraceGuid(GuidEntry) WmipIsISFlagsSet(GuidEntry, IS_TRACED)
  925. BOOLEAN
  926. WmipIsISFlagsSet(
  927. PBGUIDENTRY GuidEntry,
  928. ULONG Flags
  929. );
  930. NTSTATUS WmipDisableCollectOrEvent(
  931. PBGUIDENTRY GuidEntry,
  932. ULONG Ioctl,
  933. ULONG64 LoggerContext
  934. );
  935. NTSTATUS WmipEnableCollectOrEvent(
  936. PBGUIDENTRY GuidEntry,
  937. ULONG Ioctl,
  938. BOOLEAN *RequestSent,
  939. ULONG64 LoggerContext
  940. );
  941. NTSTATUS WmipEnableDisableTrace(
  942. ULONG Ioctl,
  943. PWMITRACEENABLEDISABLEINFO TraceEnableInfo
  944. );
  945. NTSTATUS WmipDeliverWnodeToDS(
  946. CHAR ActionCode,
  947. PBDATASOURCE DataSource,
  948. PWNODE_HEADER Wnode,
  949. ULONG BufferSize
  950. );
  951. ULONG WmipDoDisableRequest(
  952. PBGUIDENTRY GuidEntry,
  953. BOOLEAN IsEvent,
  954. BOOLEAN IsTraceLog,
  955. ULONG64 LoggerContext,
  956. ULONG InProgressFlag
  957. );
  958. void WmipReleaseCollectionEnabled(
  959. PBGUIDENTRY GuidEntry
  960. );
  961. NTSTATUS
  962. WmipDisableTraceProviders (
  963. ULONG StopLoggerId
  964. );
  965. // register.c
  966. extern KSPIN_LOCK WmipRegistrationSpinLock;
  967. extern LIST_ENTRY WmipInUseRegEntryHead;
  968. extern LONG WmipInUseRegEntryCount;
  969. extern KMUTEX WmipRegistrationMutex;
  970. extern const GUID WmipDataProviderPnpidGuid;
  971. extern const GUID WmipDataProviderPnPIdInstanceNamesGuid;
  972. #if DBG
  973. #define WmipReferenceRegEntry(RegEntry) { \
  974. InterlockedIncrement(&(RegEntry)->RefCount); \
  975. WmipDebugPrintEx((DPFLTR_WMICORE_ID, DPFLTR_INFO_LEVEL, \
  976. "WMI: Ref RegEntry %p -> 0x%x in %s line %d\n", \
  977. (RegEntry), (RegEntry)->RefCount, __FILE__, __LINE__)); \
  978. }
  979. #else
  980. #define WmipReferenceRegEntry(RegEntry) InterlockedIncrement(&(RegEntry)->RefCount)
  981. #endif
  982. PREGENTRY WmipAllocRegEntry(
  983. PDEVICE_OBJECT DeviceObject,
  984. ULONG Flags
  985. );
  986. void WmipTranslatePDOInstanceNames(
  987. IN OUT PIRP Irp,
  988. IN UCHAR MinorFunction,
  989. IN ULONG BufferSize,
  990. IN OUT PREGENTRY RegEntry
  991. );
  992. void WmipInitializeRegistration(
  993. ULONG Phase
  994. );
  995. NTSTATUS WmipRegisterDevice(
  996. PDEVICE_OBJECT DeviceObject,
  997. ULONG RegistrationFlag
  998. );
  999. NTSTATUS WmipDeregisterDevice(
  1000. PDEVICE_OBJECT DeviceObject
  1001. );
  1002. NTSTATUS WmipUpdateRegistration(
  1003. PDEVICE_OBJECT DeviceObject
  1004. );
  1005. #if DBG
  1006. #define WmipUnreferenceRegEntry(RegEntry) { \
  1007. WmipDebugPrintEx((DPFLTR_WMICORE_ID, DPFLTR_INFO_LEVEL, \
  1008. "WMI: UnRef RegEntry %p -> 0x%x in %s line %d\n", \
  1009. (RegEntry), (RegEntry)->RefCount, __FILE__, __LINE__)); \
  1010. WmipDoUnreferenceRegEntry(RegEntry); \
  1011. }
  1012. #else
  1013. #define WmipUnreferenceRegEntry WmipDoUnreferenceRegEntry
  1014. #endif
  1015. BOOLEAN WmipDoUnreferenceRegEntry(
  1016. PREGENTRY RegEntry
  1017. );
  1018. PREGENTRY WmipFindRegEntryByDevice(
  1019. PDEVICE_OBJECT DeviceObject,
  1020. BOOLEAN ReferenceIrp
  1021. );
  1022. PREGENTRY WmipDoFindRegEntryByDevice(
  1023. PDEVICE_OBJECT DeviceObject,
  1024. ULONG InvalidFlags
  1025. );
  1026. #if defined(_WIN64)
  1027. PREGENTRY WmipDoFindRegEntryByProviderId(
  1028. ULONG ProviderId,
  1029. ULONG InvalidFlags
  1030. );
  1031. PREGENTRY WmipFindRegEntryByProviderId(
  1032. ULONG ProviderId,
  1033. BOOLEAN ReferenceIrp
  1034. );
  1035. #else
  1036. #define WmipFindRegEntryByProviderId(ProviderId, ReferenceIrp) \
  1037. WmipFindRegEntryByDevice( (PDEVICE_OBJECT)(ProviderId) , (ReferenceIrp) )
  1038. #define WmipDeviceObjectToProviderId(DeviceObject) ((ULONG)(DeviceObject))
  1039. #define WmipDoFindRegEntryByProviderId(ProviderId, InvalidFlags) \
  1040. WmipDoFindRegEntryByDevice((PDEVICE_OBJECT)(ProviderId), InvalidFlags)
  1041. #endif
  1042. void WmipDecrementIrpCount(
  1043. IN PREGENTRY RegEntry
  1044. );
  1045. NTSTATUS WmipPDOToDeviceInstanceName(
  1046. IN PDEVICE_OBJECT PDO,
  1047. OUT PUNICODE_STRING DeviceInstanceName
  1048. );
  1049. NTSTATUS WmipValidateWmiRegInfoString(
  1050. PWMIREGINFO WmiRegInfo,
  1051. ULONG BufferSize,
  1052. ULONG Offset,
  1053. PWCHAR *String
  1054. );
  1055. NTSTATUS WmipProcessWmiRegInfo(
  1056. IN PREGENTRY RegEntry,
  1057. IN PWMIREGINFO WmiRegInfo,
  1058. IN ULONG BufferSize,
  1059. IN PWMIGUIDOBJECT RequestObject,
  1060. IN BOOLEAN Update,
  1061. IN BOOLEAN IsUserMode
  1062. );
  1063. //
  1064. // from notify.c
  1065. extern WORK_QUEUE_ITEM WmipEventWorkQueueItem;
  1066. extern LIST_ENTRY WmipNPEvent;
  1067. extern KSPIN_LOCK WmipNPNotificationSpinlock;
  1068. extern LONG WmipEventWorkItems;
  1069. extern ULONG WmipNSAllocCount, WmipNSAllocMax;
  1070. #if DBG
  1071. extern ULONG WmipNPAllocFail;
  1072. #endif
  1073. void WmipInitializeNotifications(
  1074. void
  1075. );
  1076. void WmipEventNotification(
  1077. PVOID Context
  1078. );
  1079. BOOLEAN WmipIsValidRegEntry(
  1080. PREGENTRY CheckRegEntry
  1081. );
  1082. //
  1083. // from wmi.c
  1084. extern ULONG WmipMaxKmWnodeEventSize;
  1085. extern UNICODE_STRING WmipRegistryPath;
  1086. NTSTATUS
  1087. WmipDriverEntry(
  1088. IN PDRIVER_OBJECT DriverObject,
  1089. IN PUNICODE_STRING RegistryPath
  1090. );
  1091. void WmipUpdateDeviceStackSize(
  1092. CCHAR NewStackSize
  1093. );
  1094. NTSTATUS WmipForwardWmiIrp(
  1095. PIRP Irp,
  1096. UCHAR MinorFunction,
  1097. ULONG ProviderId,
  1098. PVOID DataPath,
  1099. ULONG BufferLength,
  1100. PVOID Buffer
  1101. );
  1102. NTSTATUS WmipSendWmiIrp(
  1103. UCHAR MinorFunction,
  1104. ULONG ProviderId,
  1105. PVOID DataPath,
  1106. ULONG BufferLength,
  1107. PVOID Buffer,
  1108. PIO_STATUS_BLOCK Iosb
  1109. );
  1110. NTSTATUS WmipGetDevicePDO(
  1111. PDEVICE_OBJECT DeviceObject,
  1112. PDEVICE_OBJECT *PDO
  1113. );
  1114. NTSTATUS WmipProbeWmiOpenGuidBlock(
  1115. POBJECT_ATTRIBUTES CapturedObjectAttributes,
  1116. PUNICODE_STRING CapturedGuidString,
  1117. PWCHAR CapturedGuidBuffer,
  1118. PULONG DesiredAccess,
  1119. PWMIOPENGUIDBLOCK InBlock,
  1120. ULONG InBufferLen,
  1121. ULONG OutBufferLen
  1122. );
  1123. NTSTATUS WmipProbeAndCaptureGuidObjectAttributes(
  1124. POBJECT_ATTRIBUTES CapturedObjectAttributes,
  1125. PUNICODE_STRING CapturedGuidString,
  1126. PWCHAR CapturedGuidBuffer,
  1127. POBJECT_ATTRIBUTES ObjectAttributes
  1128. );
  1129. NTSTATUS WmipTranslateFileHandle(
  1130. IN OUT PWMIFHTOINSTANCENAME FhToInstanceName,
  1131. IN OUT PULONG OutBufferLen,
  1132. IN HANDLE FileHandle,
  1133. IN PDEVICE_OBJECT DeviceObject,
  1134. IN PWMIGUIDOBJECT GuidObject,
  1135. OUT PUNICODE_STRING InstanceNameString
  1136. );
  1137. //
  1138. // from smbios.c
  1139. BOOLEAN WmipFindSMBiosTable(
  1140. PPHYSICAL_ADDRESS SMBiosTablePhysicalAddress,
  1141. PUCHAR *SMBiosTableVirtualAddress,
  1142. PULONG SMBiosTableLength,
  1143. PSMBIOSVERSIONINFO SMBiosVersionInfo
  1144. );
  1145. NTSTATUS WmipGetSMBiosTableData(
  1146. PUCHAR Buffer,
  1147. PULONG BufferSize,
  1148. OUT PSMBIOSVERSIONINFO SMBiosVersionInfo
  1149. );
  1150. NTSTATUS
  1151. WmipDockUndockEventCallback(
  1152. IN PVOID NoificationStructure,
  1153. IN PVOID Context
  1154. );
  1155. NTSTATUS WmipGetSysIds(
  1156. PSYSID_UUID *SysIdUuid,
  1157. ULONG *SysIdUuidCount,
  1158. PSYSID_1394 *SysId1394,
  1159. ULONG *SysId1394Count
  1160. );
  1161. NTSTATUS WmipGetSMBiosEventlog(
  1162. PUCHAR Buffer,
  1163. PULONG BufferSize
  1164. );
  1165. void WmipGetSMBiosFromLoaderBlock(
  1166. PVOID LoaderBlockPtr
  1167. );
  1168. extern PHYSICAL_ADDRESS WmipSMBiosTablePhysicalAddress;
  1169. extern PUCHAR WmipSMBiosTableVirtualAddress;
  1170. extern ULONG WmipSMBiosTableLength;
  1171. //
  1172. // from dataprov.c
  1173. extern const WMILIB_INFO WmipWmiLibInfo;
  1174. // from secure.c
  1175. #ifndef MEMPHIS
  1176. extern POBJECT_TYPE WmipGuidObjectType;
  1177. NTSTATUS WmipCreateAdminSD(
  1178. PSECURITY_DESCRIPTOR *Sd
  1179. );
  1180. NTSTATUS WmipInitializeSecurity(
  1181. void
  1182. );
  1183. NTSTATUS WmipOpenGuidObject(
  1184. IN POBJECT_ATTRIBUTES ObjectAttributes,
  1185. IN ACCESS_MASK DesiredAccess,
  1186. IN KPROCESSOR_MODE AccessMode,
  1187. OUT PHANDLE Handle,
  1188. OUT PWMIGUIDOBJECT *ObjectPtr
  1189. );
  1190. NTSTATUS
  1191. WmipCheckGuidAccess(
  1192. IN LPGUID Guid,
  1193. IN ACCESS_MASK DesiredAccess,
  1194. IN PSECURITY_DESCRIPTOR SecurityDescriptor
  1195. );
  1196. NTSTATUS
  1197. WmipGetGuidSecurityDescriptor(
  1198. IN PUNICODE_STRING GuidName,
  1199. IN PSECURITY_DESCRIPTOR *SecurityDescriptor,
  1200. IN PSECURITY_DESCRIPTOR UserDefaultSecurity
  1201. );
  1202. // from mca.c
  1203. extern ULONG WmipCpePollInterval;
  1204. NTSTATUS WmipRegisterMcaHandler(
  1205. ULONG Phase
  1206. );
  1207. NTSTATUS WmipGetRawMCAInfo(
  1208. OUT PUCHAR Buffer,
  1209. IN OUT PULONG BufferSize
  1210. );
  1211. void WmipGenerateMCAEventlog(
  1212. PUCHAR ErrorLog,
  1213. ULONG ErrorLogSize,
  1214. BOOLEAN IsFatal
  1215. );
  1216. #ifdef CPE_CONTROL
  1217. NTSTATUS WmipSetCPEPolling(
  1218. IN BOOLEAN Enabled,
  1219. IN ULONG Interval
  1220. );
  1221. #endif
  1222. //
  1223. // From tracelog
  1224. //
  1225. typedef struct _tagWMI_Event {
  1226. WNODE_HEADER Wnode;
  1227. NTSTATUS Status;
  1228. ULONG TraceErrorFlag;
  1229. } WMI_TRACE_EVENT, *PWMI_TRACE_EVENT;
  1230. // From Traceapi.c, the Ioctl interface to TraceMessage
  1231. NTSTATUS
  1232. FASTCALL
  1233. WmiTraceUserMessage(
  1234. IN PMESSAGE_TRACE_USER pMessage,
  1235. IN ULONG MessageSize
  1236. );
  1237. #endif
  1238. #endif // _WMIKMP_