summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Benditovich <yuri.benditovich@daynix.com>2020-01-26 10:24:27 +0200
committerYan Vugenfirer <yan@daynix.com>2020-01-27 19:49:45 +0200
commitc565bd513ef3c15ca49942a7e8ef964787b337a9 (patch)
tree7092341ac9e3d92e99674ab89bfabd63086e028e
parentc736f5d8be38d1a6ccc24dfbc21eeffc89dadc88 (diff)
driver: add procedure for getting power data by PDO
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
-rw-r--r--UsbDk/DeviceAccess.cpp18
-rw-r--r--UsbDk/DeviceAccess.h2
-rw-r--r--UsbDk/stdafx.h2
3 files changed, 21 insertions, 1 deletions
diff --git a/UsbDk/DeviceAccess.cpp b/UsbDk/DeviceAccess.cpp
index 657c0b9..58d28cd 100644
--- a/UsbDk/DeviceAccess.cpp
+++ b/UsbDk/DeviceAccess.cpp
@@ -168,6 +168,24 @@ SIZE_T CWdmDeviceAccess::GetIdBufferLength(BUS_QUERY_ID_TYPE idType, PWCHAR idDa
}
}
+bool CWdmDeviceAccess::QueryPowerData(CM_POWER_DATA& powerData)
+{
+ powerData.PD_Size = sizeof(powerData);
+#if !TARGET_OS_WIN_XP
+ ULONG dummy;
+ DEVPROPTYPE propType;
+ auto status = IoGetDevicePropertyData(m_DevObj, &DEVPKEY_Device_PowerData, LOCALE_NEUTRAL, 0,
+ sizeof(powerData), &powerData, &dummy, &propType);
+ if (!NT_SUCCESS(status))
+ {
+ TraceEvents(TRACE_LEVEL_ERROR, TRACE_DEVACCESS, "%!FUNC! Error %!STATUS!", status);
+ }
+ return NT_SUCCESS(status);
+#else
+ return false;
+#endif
+}
+
PWCHAR CWdmDeviceAccess::MakeNonPagedDuplicate(BUS_QUERY_ID_TYPE idType, PWCHAR idData)
{
auto bufferLength = GetIdBufferLength(idType, idData);
diff --git a/UsbDk/DeviceAccess.h b/UsbDk/DeviceAccess.h
index 5520210..d107cee 100644
--- a/UsbDk/DeviceAccess.h
+++ b/UsbDk/DeviceAccess.h
@@ -52,7 +52,7 @@ public:
ULONG GetAddress();
CRegText *GetDeviceID() { return new CRegSz(QueryBusID(BusQueryDeviceID)); }
CRegText *GetInstanceID() { return new CRegSz(QueryBusID(BusQueryInstanceID)); }
-
+ bool QueryPowerData(CM_POWER_DATA& powerData);
protected:
PDEVICE_OBJECT m_DevObj;
diff --git a/UsbDk/stdafx.h b/UsbDk/stdafx.h
index fccb90e..dc32ba2 100644
--- a/UsbDk/stdafx.h
+++ b/UsbDk/stdafx.h
@@ -16,7 +16,9 @@ extern "C"
#include <usb.h>
#if !TARGET_OS_WIN_XP
+#include <initguid.h>
#include <UsbSpec.h>
+#include <devpkey.h>
#else
#define USB_DEVICE_CLASS_AUDIO 0x01
#define USB_DEVICE_CLASS_COMMUNICATIONS 0x02