Skip to content

Commit

Permalink
driver: add procedure for getting power data by PDO
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Benditovich <[email protected]>
  • Loading branch information
ybendito authored and YanVugenfirer committed Jan 27, 2020
1 parent c736f5d commit c565bd5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions UsbDk/DeviceAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion UsbDk/DeviceAccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class CWdmDeviceAccess
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;

Expand Down
2 changes: 2 additions & 0 deletions UsbDk/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c565bd5

Please sign in to comment.