Compare commits
1 commit
master
...
revert-85-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60e00cf1d6 |
10 changed files with 16 additions and 79 deletions
|
|
@ -3,7 +3,8 @@ image: Visual Studio 2015
|
|||
version: build-{build}-{branch}
|
||||
|
||||
before_build:
|
||||
- tools\AppVeyor\before-build.cmd
|
||||
- ren "C:\Program Files (x86)\Windows Kits\10\include\00wdf" "wdf"
|
||||
- ren "C:\Program Files (x86)\WiX Toolset v3.11" "WiX Toolset v3.8"
|
||||
|
||||
build_script: buildAll.bat
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[](https://ci.appveyor.com/api/projects/status/p3s6bdbx8mq8o0hu?svg=true)
|
||||
[](https://ci.appveyor.com/project/daynix/usbdk)
|
||||
|
||||
# UsbDk
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
@echo off
|
||||
pushd "%~dp0"
|
||||
curl -L -s https://drive.google.com/uc?id=17ZK6a1kxhTR-YOkWpAOqNJZA7UBUGkmu --output Microsoft.DriverKit.Build.Tasks.14.0.dll
|
||||
copy /y Microsoft.DriverKit.Build.Tasks.14.0.dll "C:\Program Files (x86)\Windows Kits\10\build\bin"
|
||||
popd
|
||||
|
|
@ -451,7 +451,7 @@ PDEVICE_OBJECT CUsbDkControlDevice::GetPDOByDeviceID(const USB_DK_DEVICE_ID &Dev
|
|||
return PDO;
|
||||
}
|
||||
|
||||
NTSTATUS CUsbDkControlDevice::ResetUsbDevice(const USB_DK_DEVICE_ID &DeviceID, bool ForceD0)
|
||||
NTSTATUS CUsbDkControlDevice::ResetUsbDevice(const USB_DK_DEVICE_ID &DeviceID)
|
||||
{
|
||||
PDEVICE_OBJECT PDO = GetPDOByDeviceID(DeviceID);
|
||||
if (PDO == nullptr)
|
||||
|
|
@ -460,7 +460,7 @@ NTSTATUS CUsbDkControlDevice::ResetUsbDevice(const USB_DK_DEVICE_ID &DeviceID, b
|
|||
}
|
||||
|
||||
CWdmUsbDeviceAccess pdoAccess(PDO);
|
||||
auto status = pdoAccess.Reset(ForceD0);
|
||||
auto status = pdoAccess.Reset();
|
||||
ObDereferenceObject(PDO);
|
||||
|
||||
return status;
|
||||
|
|
@ -707,7 +707,7 @@ void CUsbDkControlDevice::AddRedirectRollBack(const USB_DK_DEVICE_ID &DeviceId,
|
|||
return;
|
||||
}
|
||||
|
||||
auto resetRes = ResetUsbDevice(DeviceId, false);
|
||||
auto resetRes = ResetUsbDevice(DeviceId);
|
||||
if (!NT_SUCCESS(resetRes))
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_ERROR, TRACE_CONTROLDEVICE, "%!FUNC! Roll-back reset failed. %!STATUS!", resetRes);
|
||||
|
|
@ -737,7 +737,7 @@ NTSTATUS CUsbDkControlDevice::AddRedirect(const USB_DK_DEVICE_ID &DeviceId, HAND
|
|||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_CONTROLDEVICE, "%!FUNC! Success. New redirections list:");
|
||||
m_Redirections.Dump();
|
||||
|
||||
auto resetRes = ResetUsbDevice(DeviceId, true);
|
||||
auto resetRes = ResetUsbDevice(DeviceId);
|
||||
if (!NT_SUCCESS(resetRes))
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_ERROR, TRACE_CONTROLDEVICE, "%!FUNC! Reset after start redirection failed. %!STATUS!", resetRes);
|
||||
|
|
@ -1029,7 +1029,7 @@ NTSTATUS CUsbDkControlDevice::RemoveRedirect(const USB_DK_DEVICE_ID &DeviceId)
|
|||
{
|
||||
if (NotifyRedirectorRemovalStarted(DeviceId))
|
||||
{
|
||||
auto res = ResetUsbDevice(DeviceId, false);
|
||||
auto res = ResetUsbDevice(DeviceId);
|
||||
if (NT_SUCCESS(res))
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_CONTROLDEVICE,
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ public:
|
|||
{ return ReloadPersistentHideRules(); }
|
||||
|
||||
bool EnumerateDevices(USB_DK_DEVICE_INFO *outBuff, size_t numberAllocatedDevices, size_t &numberExistingDevices);
|
||||
NTSTATUS ResetUsbDevice(const USB_DK_DEVICE_ID &DeviceId, bool ForceD0);
|
||||
NTSTATUS ResetUsbDevice(const USB_DK_DEVICE_ID &DeviceId);
|
||||
NTSTATUS AddRedirect(const USB_DK_DEVICE_ID &DeviceId, HANDLE RequestorProcess, PHANDLE ObjectHandle);
|
||||
|
||||
NTSTATUS AddHideRule(const USB_DK_HIDE_RULE &UsbDkRule);
|
||||
|
|
|
|||
|
|
@ -168,41 +168,6 @@ 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
|
||||
}
|
||||
|
||||
static void PowerRequestCompletion(
|
||||
_In_ PDEVICE_OBJECT DeviceObject,
|
||||
_In_ UCHAR MinorFunction,
|
||||
_In_ POWER_STATE PowerState,
|
||||
_In_opt_ PVOID Context,
|
||||
_In_ PIO_STATUS_BLOCK IoStatus
|
||||
)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(DeviceObject);
|
||||
UNREFERENCED_PARAMETER(MinorFunction);
|
||||
UNREFERENCED_PARAMETER(PowerState);
|
||||
UNREFERENCED_PARAMETER(IoStatus);
|
||||
CWdmEvent *pev = (CWdmEvent *)Context;
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DEVACCESS, "%!FUNC! -> D%d", PowerState.DeviceState - 1);
|
||||
pev->Set();
|
||||
}
|
||||
|
||||
PWCHAR CWdmDeviceAccess::MakeNonPagedDuplicate(BUS_QUERY_ID_TYPE idType, PWCHAR idData)
|
||||
{
|
||||
auto bufferLength = GetIdBufferLength(idType, idData);
|
||||
|
|
@ -250,23 +215,9 @@ NTSTATUS CWdmDeviceAccess::QueryForInterface(const GUID &guid, __out INTERFACE &
|
|||
return status;
|
||||
}
|
||||
|
||||
NTSTATUS CWdmUsbDeviceAccess::Reset(bool ForceD0)
|
||||
NTSTATUS CWdmUsbDeviceAccess::Reset()
|
||||
{
|
||||
CIoControlIrp Irp;
|
||||
CM_POWER_DATA powerData;
|
||||
if (ForceD0 && QueryPowerData(powerData) && powerData.PD_MostRecentPowerState != PowerDeviceD0)
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DEVACCESS, "%!FUNC! device power state D%d", powerData.PD_MostRecentPowerState - 1);
|
||||
POWER_STATE PowerState;
|
||||
CWdmEvent Event;
|
||||
PowerState.DeviceState = PowerDeviceD0;
|
||||
auto status = PoRequestPowerIrp(m_DevObj, IRP_MN_SET_POWER, PowerState, PowerRequestCompletion, &Event, NULL);
|
||||
if (NT_SUCCESS(status))
|
||||
{
|
||||
Event.Wait();
|
||||
}
|
||||
}
|
||||
|
||||
auto status = Irp.Create(m_DevObj, IOCTL_INTERNAL_USB_CYCLE_PORT);
|
||||
|
||||
if (!NT_SUCCESS(status))
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ public:
|
|||
: CWdmDeviceAccess(WdmDevice)
|
||||
{ }
|
||||
|
||||
NTSTATUS Reset(bool ForceD0);
|
||||
NTSTATUS Reset();
|
||||
NTSTATUS GetDeviceDescriptor(USB_DEVICE_DESCRIPTOR &Descriptor);
|
||||
NTSTATUS GetConfigurationDescriptor(UCHAR Index, USB_CONFIGURATION_DESCRIPTOR &Descriptor, size_t Length);
|
||||
|
||||
|
|
|
|||
|
|
@ -481,19 +481,11 @@ bool CUsbDkChildDevice::AttachToDeviceStack()
|
|||
|
||||
void CUsbDkFilterDevice::OnFileCreate(WDFREQUEST Request)
|
||||
{
|
||||
CWdfRequest r(Request);
|
||||
WdfRequestFormatRequestUsingCurrentType(Request);
|
||||
WDF_REQUEST_SEND_OPTIONS options;
|
||||
WDF_REQUEST_SEND_OPTIONS_INIT(&options, WDF_REQUEST_SEND_OPTION_SEND_AND_FORGET);
|
||||
// in the log we'll see which process created the file
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC!");
|
||||
r.SendWithCompletion(IOTarget(), [](WDFREQUEST Request, WDFIOTARGET Target, PWDF_REQUEST_COMPLETION_PARAMS Params, WDFCONTEXT Context)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(Target);
|
||||
CWdfRequest r(Request);
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%s: completed", (LPCSTR)Context);
|
||||
r.SetStatus(Params->IoStatus.Status);
|
||||
r.SetBytesWritten(Params->IoStatus.Information);
|
||||
},
|
||||
__FUNCTION__);
|
||||
WdfRequestSend(Request, IOTarget(), &options);
|
||||
}
|
||||
|
||||
NTSTATUS CUsbDkFilterDevice::AttachToStack(WDFDRIVER Driver)
|
||||
|
|
|
|||
|
|
@ -16,9 +16,7 @@ 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
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ if !ERRORLEVEL! NEQ 0 exit /B 1
|
|||
popd
|
||||
|
||||
pushd Install_Debug
|
||||
call :maketmf %DEBUG_CFG%
|
||||
call :maketmf Debug
|
||||
if !ERRORLEVEL! NEQ 0 exit /B 1
|
||||
popd
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue