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
|
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
plclient.h
Abstract:
This is the header file for the simulated power limit client driver.
--*/
#pragma once
//-------------------------------------------------------------------- Includes
#include <ntddk.h>
#include <wdf.h>
#include <ntstrsafe.h>
#include <initguid.h>
#include <wdmguid.h>
#include <poclass.h>
#include <limits.h>
#include "powerlimitclient_drvinterface.h"
//----------------------------------------------------------------------- Types
typedef struct {
ULONG LimitCount;
PPOWER_LIMIT_ATTRIBUTES LimitAttributes;
PPOWER_LIMIT_VALUE LimitValues;
} FDO_DATA, *PFDO_DATA;
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(FDO_DATA, GetDeviceExtension);
//----------------------------------------------------------------------- Debug
#define DebugPrint(l, m, ...) DbgPrintEx(DPFLTR_POWER_ID, l, "[plclient]: "m, __VA_ARGS__)
#define DebugEnter() DebugPrint(PLCLIENT_PRINT_TRACE, "Entering %s", __FUNCTION__)
#define DebugExit() DebugPrint(PLCLIENT_PRINT_TRACE, "Leaving " __FUNCTION__ "\n")
#define DebugExitStatus(_status_) DebugPrint(PLCLIENT_PRINT_TRACE, "Leaving " __FUNCTION__ ": Status=0x%08x\n", _status_)
#define PLCLIENT_PRINT_ERROR DPFLTR_ERROR_LEVEL
#define PLCLIENT_PRINT_TRACE DPFLTR_TRACE_LEVEL
#define PLCLIENT_PRINT_INFO DPFLTR_INFO_LEVEL
#define PLCLIENT_TAG 'PLCL'
//--------------------------------------------------------------------- Globals
extern WDFWAITLOCK GlobalMutex;
//------------------------------------------------------------------ Prototypes
FORCEINLINE
VOID
AcquireGlobalMutex (
VOID
)
{
WdfWaitLockAcquire(GlobalMutex, 0);
return;
}
FORCEINLINE
VOID
ReleaseGlobalMutex (
VOID
)
{
WdfWaitLockRelease(GlobalMutex);
return;
}
//
// plclient.c
//
QUERY_POWER_LIMIT_ATTRIBUTES PLCQueryAttributes;
SET_POWER_LIMIT PLCSetLimits;
QUERY_POWER_LIMIT PLCQueryLimitValues;
NTSTATUS
InitPowerLimitValues (
_Inout_ PFDO_DATA DevExt
);
VOID
CleanupPowerLimitValues (
_Inout_opt_ PFDO_DATA DevExt
);
|