diff --git a/UsbDk/HiderStrategy.cpp b/UsbDk/HiderStrategy.cpp index eddecca..3ca738f 100644 --- a/UsbDk/HiderStrategy.cpp +++ b/UsbDk/HiderStrategy.cpp @@ -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"; @@ -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); diff --git a/UsbDk/HiderStrategy.h b/UsbDk/HiderStrategy.h index e025a72..bb6e59f 100644 --- a/UsbDk/HiderStrategy.h +++ b/UsbDk/HiderStrategy.h @@ -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 {