Skip to content

Commit

Permalink
HiderStrategy: Re-use serial numbers of UsbDk devices
Browse files Browse the repository at this point in the history
See log message of previous commit for rationale.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
  • Loading branch information
Dmitry Fleytman committed Feb 19, 2017
1 parent a4bf95a commit 1217ff2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
26 changes: 25 additions & 1 deletion UsbDk/HiderStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,32 @@
#include "trace.h"
#include "HiderStrategy.tmh"
#include "FilterDevice.h"
#include "ControlDevice.h"
#include "UsbDkNames.h"

NTSTATUS CUsbDkHiderStrategy::Create(CUsbDkFilterDevice *Owner)
{
auto status = CUsbDkNullFilterStrategy::Create(Owner);
if (NT_SUCCESS(status))
{
m_ControlDevice->RegisterHiddenDevice(*Owner);
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_HIDER, "%!FUNC! Serial number for this device is %lu", Owner->GetSerialNumber());

}

return status;
}

void CUsbDkHiderStrategy::Delete()
{
if (m_ControlDevice != nullptr)
{
m_ControlDevice->UnregisterHiddenDevice(*m_Owner);
}

CUsbDkNullFilterStrategy::Delete();
}

void CUsbDkHiderStrategy::PatchDeviceID(PIRP Irp)
{
static const WCHAR RedirectorDeviceId[] = L"USB\\Vid_2B23&Pid_CAFE&Rev_0001";
Expand All @@ -55,7 +79,7 @@ void CUsbDkHiderStrategy::PatchDeviceID(PIRP Irp)
case BusQueryInstanceID:
{
CString InstanceID;
auto status = InstanceID.Create(USBDK_DRIVER_NAME, m_Owner->GetInstanceNumber());
auto status = InstanceID.Create(USBDK_DRIVER_NAME, m_Owner->GetSerialNumber());
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR, TRACE_HIDER, "%!FUNC! Failed to create instance ID string %!STATUS!", status);
Expand Down
3 changes: 3 additions & 0 deletions UsbDk/HiderStrategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
class CUsbDkHiderStrategy : public CUsbDkNullFilterStrategy
{
public:
virtual NTSTATUS Create(CUsbDkFilterDevice *Owner) override;
virtual void Delete() override;

virtual NTSTATUS PNPPreProcess(PIRP Irp) override;
virtual NTSTATUS MakeAvailable() override
{
Expand Down

0 comments on commit 1217ff2

Please sign in to comment.