Open crazyboy01crazy opened 1 year ago
PS:on windows10
@crazyboy01crazy If you replug the device - does it solve the problem?
@crazyboy01crazy If you replug the device - does it solve the problem?
Replug it can resolve the problem as I remember.
But , I need to use it without replug it. I try to find it why `NTSTATUS CUsbDkControlDevice::AddRedirect(const USB_DK_DEVICE_ID &DeviceId, HANDLE RequestorProcess, PHANDLE RedirectorDevice) { CUsbDkRedirection *Redirection; auto addRes = AddRedirectionToSet(DeviceId, &Redirection); if (!NT_SUCCESS(addRes)) { return addRes; } Redirection->AddRef(); CObjHolder<CUsbDkRedirection, CRefCountingDeleter> dereferencer(Redirection);
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_CONTROLDEVICE, "%!FUNC! Success. New redirections list:");
m_Redirections.Dump();
auto resetRes = ResetUsbDevice(DeviceId, true);
if (!NT_SUCCESS(resetRes))
{
TraceEvents(TRACE_LEVEL_ERROR, TRACE_CONTROLDEVICE, "%!FUNC! Reset after start redirection failed. %!STATUS!", resetRes);
AddRedirectRollBack(DeviceId, false);
return resetRes;
}
auto waitRes = Redirection->WaitForAttachment();
if ((waitRes == STATUS_TIMEOUT) || !NT_SUCCESS(waitRes))
{
TraceEvents(TRACE_LEVEL_ERROR, TRACE_CONTROLDEVICE, "%!FUNC! Wait for redirector attachment failed. %!STATUS!", waitRes);
AddRedirectRollBack(DeviceId, true);
return (waitRes == STATUS_TIMEOUT) ? STATUS_DEVICE_NOT_CONNECTED : waitRes;
}
auto status = Redirection->CreateRedirectorHandle(RequestorProcess, RedirectorDevice);
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR, TRACE_CONTROLDEVICE, "%!FUNC! CreateRedirectorHandle() failed. %!STATUS!", status);
AddRedirectRollBack(DeviceId, true);
return STATUS_DEVICE_NOT_CONNECTED;
}
return STATUS_SUCCESS;
}`
After debugging, I find that the corresponding event such as WaitForAttachment cannot be detected after executing the ResetUsbDevice operation
@crazyboy01crazy If you replug the device - does it solve the problem?
Replug it can resolve the problem as I remember.
But , I need to use it without replug it. I try to find it why `NTSTATUS CUsbDkControlDevice::AddRedirect(const USB_DK_DEVICE_ID &DeviceId, HANDLE RequestorProcess, PHANDLE RedirectorDevice) { CUsbDkRedirection *Redirection; auto addRes = AddRedirectionToSet(DeviceId, &Redirection); if (!NT_SUCCESS(addRes)) { return addRes; } Redirection->AddRef(); CObjHolder<CUsbDkRedirection, CRefCountingDeleter> dereferencer(Redirection);
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_CONTROLDEVICE, "%!FUNC! Success. New redirections list:");
m_Redirections.Dump();
auto resetRes = ResetUsbDevice(DeviceId, true);
if (!NT_SUCCESS(resetRes))
{
TraceEvents(TRACE_LEVEL_ERROR, TRACE_CONTROLDEVICE, "%!FUNC! Reset after start redirection failed. %!STATUS!", resetRes);
AddRedirectRollBack(DeviceId, false);
return resetRes;
}
auto waitRes = Redirection->WaitForAttachment();
if ((waitRes == STATUS_TIMEOUT) || !NT_SUCCESS(waitRes))
{
TraceEvents(TRACE_LEVEL_ERROR, TRACE_CONTROLDEVICE, "%!FUNC! Wait for redirector attachment failed. %!STATUS!", waitRes);
AddRedirectRollBack(DeviceId, true);
return (waitRes == STATUS_TIMEOUT) ? STATUS_DEVICE_NOT_CONNECTED : waitRes;
}
auto status = Redirection->CreateRedirectorHandle(RequestorProcess, RedirectorDevice);
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR, TRACE_CONTROLDEVICE, "%!FUNC! CreateRedirectorHandle() failed. %!STATUS!", status);
AddRedirectRollBack(DeviceId, true);
return STATUS_DEVICE_NOT_CONNECTED;
}
return STATUS_SUCCESS;
}`
After debugging, I find that the corresponding event such as WaitForAttachment cannot be detected after executing the ResetUsbDevice operation
when I use ”usbDkController -r“ to redir it first time, It's OK. but when I redir it again after stop the first time redir, Faild!