summaryrefslogtreecommitdiff
path: root/UsbDkHelper
diff options
context:
space:
mode:
authorPavel Gurvich <pavel@daynix.com>2014-05-26 11:18:04 +0300
committerDmitry Fleytman <dfleytma@redhat.com>2014-05-26 18:41:17 +0300
commit02076801c4cad19510928013e06e4095ee6ddbef (patch)
treed2d9877792e83d84af18d8531414e586a638c714 /UsbDkHelper
parent40154c5bab7485078f2cf2fc988ee9df60535ee1 (diff)
UsbDkHelper: Add UsbDk_SetAltsetting API
Signed-off-by: Pavel Gurvich <pavel@daynix.com> Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Diffstat (limited to 'UsbDkHelper')
-rw-r--r--UsbDkHelper/RedirectorAccess.cpp10
-rw-r--r--UsbDkHelper/RedirectorAccess.h1
-rw-r--r--UsbDkHelper/UsbDkHelper.cpp16
-rw-r--r--UsbDkHelper/UsbDkHelper.h1
4 files changed, 28 insertions, 0 deletions
diff --git a/UsbDkHelper/RedirectorAccess.cpp b/UsbDkHelper/RedirectorAccess.cpp
index 06e30c5..93a0ce4 100644
--- a/UsbDkHelper/RedirectorAccess.cpp
+++ b/UsbDkHelper/RedirectorAccess.cpp
@@ -31,6 +31,16 @@ void UsbDkRedirectorAccess::AbortPipe(ULONG64 PipeAddress)
}
//------------------------------------------------------------------------------------------------
+void UsbDkRedirectorAccess::SetAltsetting(ULONG64 InterfaceIdx, ULONG64 AltSettingIdx)
+{
+ USBDK_ALTSETTINGS_IDXS AltSetting;
+ AltSetting.InterfaceIdx = InterfaceIdx;
+ AltSetting.AltSettingIdx = AltSettingIdx;
+
+ IoctlSync(IOCTL_USBDK_DEVICE_SET_ALTSETTING, false, &AltSetting, sizeof(AltSetting));
+}
+//------------------------------------------------------------------------------------------------
+
bool UsbDkRedirectorAccess::IoctlSync(DWORD Code,
bool ShortBufferOk,
LPVOID InBuffer,
diff --git a/UsbDkHelper/RedirectorAccess.h b/UsbDkHelper/RedirectorAccess.h
index 3336a38..663b918 100644
--- a/UsbDkHelper/RedirectorAccess.h
+++ b/UsbDkHelper/RedirectorAccess.h
@@ -61,6 +61,7 @@ public:
}
void AbortPipe(ULONG64 PipeAddress);
+ void SetAltsetting(ULONG64 InterfaceIdx, ULONG64 AltSettingIdx);
HANDLE GetSystemHandle() const
{ return m_hDriver; }
diff --git a/UsbDkHelper/UsbDkHelper.cpp b/UsbDkHelper/UsbDkHelper.cpp
index 6acdee9..c59bd90 100644
--- a/UsbDkHelper/UsbDkHelper.cpp
+++ b/UsbDkHelper/UsbDkHelper.cpp
@@ -275,6 +275,22 @@ BOOL UsbDk_AbortPipe(HANDLE DeviceHandle, ULONG64 PipeAddress)
}
//-------------------------------------------------------------------------------------------
+BOOL UsbDk_SetAltsetting(HANDLE DeviceHandle, ULONG64 InterfaceIdx, ULONG64 AltSettingIdx)
+{
+ try
+ {
+ auto deviceHandle = reinterpret_cast<PREDIRECTED_DEVICE_HANDLE>(DeviceHandle);
+ deviceHandle->RedirectorAccess->SetAltsetting(InterfaceIdx, AltSettingIdx);
+ return TRUE;
+ }
+ catch (const exception &e)
+ {
+ printExceptionString(e.what());
+ return FALSE;
+ }
+}
+//-------------------------------------------------------------------------------------------
+
HANDLE UsbDk_GetRedirectorSystemHandle(HANDLE DeviceHandle)
{
auto deviceHandle = reinterpret_cast<PREDIRECTED_DEVICE_HANDLE>(DeviceHandle);
diff --git a/UsbDkHelper/UsbDkHelper.h b/UsbDkHelper/UsbDkHelper.h
index 86eefe7..65d2490 100644
--- a/UsbDkHelper/UsbDkHelper.h
+++ b/UsbDkHelper/UsbDkHelper.h
@@ -63,6 +63,7 @@ extern "C" {
DLL TransferResult UsbDk_ReadPipe(HANDLE DeviceHandle, PUSB_DK_TRANSFER_REQUEST Request, LPOVERLAPPED Overlapped);
DLL BOOL UsbDk_AbortPipe(HANDLE DeviceHandle, ULONG64 PipeAddress);
+ DLL BOOL UsbDk_SetAltsetting(HANDLE DeviceHandle, ULONG64 InterfaceIdx, ULONG64 AltSettingIdx);
DLL HANDLE UsbDk_GetRedirectorSystemHandle(HANDLE DeviceHandle);
#ifdef __cplusplus