summaryrefslogtreecommitdiff
path: root/wmi/wmisamp/wmisamp.h
blob: ed066bcde6cd0423768de4ed42a6c2ea4208e80d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*++

Copyright (c) Microsoft Corporation.  All rights reserved.

    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
    EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
    WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

Module Name:

    WmiSamp.h

Abstract:

    --

Environment:

    Kernel mode

--*/

#include <ntddk.h>
#include <wdf.h>

#include <initguid.h>   // required for GUID definitions
#include <wdmguid.h>    // required for WMILIB_CONTEXT
#include <wmistr.h>
#include <wmilib.h>
#include "WmiData.h"


//
// A macro for Pointer addition.
//
#define Add2Ptr(P,I)    ((PVOID)((PUCHAR)(P) + (I)))


//
// Define DebugPrint for sending messages to the debugger in checked builds.
//
#if DBG
#define DebugPrint      KdPrint
#else
#define DebugPrint
#endif

#define POOL_ZERO_DOWN_LEVEL_SUPPORT

typedef struct _WMI_SAMPLE_INSTANCE_CONFIG {

    GUID Guid;
    ULONG MinSize;
    PFN_WDF_WMI_INSTANCE_QUERY_INSTANCE EvtWmiInstanceQueryInstance;
    PFN_WDF_WMI_INSTANCE_SET_INSTANCE EvtWmiInstanceSetInstance;
    PFN_WDF_WMI_INSTANCE_SET_ITEM EvtWmiInstanceSetItem;
    PFN_WDF_WMI_INSTANCE_EXECUTE_METHOD EvtWmiInstanceExecuteMethod;

} WMI_SAMPLE_INSTANCE_CONFIG, *PWMI_SAMPLE_INSTANCE_CONFIG;


#define EC1_COUNT       4
#define EC2_COUNT       4

//
// Data storage for WMI data blocks.
//
typedef struct _WMI_SAMPLE_DEVICE_DATA {

    ULONG Ec1Count;
    ULONG Ec1Length[EC1_COUNT];
    ULONG Ec1ActualLength[EC1_COUNT];
    PEC1 Ec1[EC1_COUNT];
    WDFSPINLOCK Ec1Lock;

    ULONG Ec2Count;
    ULONG Ec2Length[EC2_COUNT];
    ULONG Ec2ActualLength[EC2_COUNT];
    PEC2 Ec2[EC2_COUNT];
    WDFSPINLOCK Ec2Lock;

    WDFWMIINSTANCE DynamicInstance;
    ULONG CreateCount;

} WMI_SAMPLE_DEVICE_DATA, *PWMI_SAMPLE_DEVICE_DATA;


//
// Specify an accessor method for the WMI_SAMPLE_DEVICE_DATA structure.
//
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(WMI_SAMPLE_DEVICE_DATA, GetWmiSampleDeviceData)


DRIVER_INITIALIZE DriverEntry;

EVT_WDF_DRIVER_DEVICE_ADD WmiSampEvtDeviceAdd;
EVT_WDF_DEVICE_CONTEXT_DESTROY WmiSampDeviceEvtDestroyCallback;

NTSTATUS
WmiSampWmiRegistration(
    _In_ WDFDEVICE Device
    );

NTSTATUS
WmiSampDynamicWmiRegistration(
    _In_ WDFDEVICE Device
    );

_Success_(return > 0)
ULONG
WmiSampGetEc1(
    _In_    PWMI_SAMPLE_DEVICE_DATA WmiDeviceData,
    _Out_ PVOID Buffer,
    _In_    ULONG Index
    );

VOID
WmiSampSetEc1(
    _In_ PWMI_SAMPLE_DEVICE_DATA WmiDeviceData,
    _In_ PVOID Buffer,
    _In_ ULONG Length,
    _In_ ULONG Index
    );

_Success_(return > 0)
ULONG
WmiSampGetEc2(
    _In_    PWMI_SAMPLE_DEVICE_DATA WmiDeviceData,
    _Out_ PVOID Buffer,
    _In_    ULONG Index
    );

VOID
WmiSampSetEc2(
    _In_ PWMI_SAMPLE_DEVICE_DATA WmiDeviceData,
    _In_ PVOID Buffer,
    _In_ ULONG Length,
    _In_ ULONG Index
    );