Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- v5: - Remove ddk/winusbio.h dependent entries --- include/Makefile.in | 1 + include/winusb.h | 59 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 include/winusb.h
diff --git a/include/Makefile.in b/include/Makefile.in index 047e7ff9146..6654e877464 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -836,6 +836,7 @@ SOURCES = \ wintabx.h \ winternl.h \ wintrust.h \ + winusb.h \ winuser.h \ winuser.rh \ winver.h \ diff --git a/include/winusb.h b/include/winusb.h new file mode 100644 index 00000000000..e3c2cd366e6 --- /dev/null +++ b/include/winusb.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2022 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _WINUSB_H_ +#define _WINUSB_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef PVOID WINUSB_INTERFACE_HANDLE, *PWINUSB_INTERFACE_HANDLE; + +typedef struct _WINUSB_SETUP_PACKET { + UCHAR RequestType; + UCHAR Request; + USHORT Value; + USHORT Index; + USHORT Length; +} WINUSB_SETUP_PACKET, *PWINUSB_SETUP_PACKET; + +BOOL WINAPI WinUsb_AbortPipe(WINUSB_INTERFACE_HANDLE,UCHAR); +BOOL WINAPI WinUsb_ControlTransfer(WINUSB_INTERFACE_HANDLE,WINUSB_SETUP_PACKET,PUCHAR,ULONG,PULONG,LPOVERLAPPED); +BOOL WINAPI WinUsb_FlushPipe(WINUSB_INTERFACE_HANDLE,UCHAR); +BOOL WINAPI WinUsb_Free(WINUSB_INTERFACE_HANDLE); +BOOL WINAPI WinUsb_GetAssociatedInterface(WINUSB_INTERFACE_HANDLE,UCHAR,PWINUSB_INTERFACE_HANDLE); +BOOL WINAPI WinUsb_GetCurrentAlternateSetting(WINUSB_INTERFACE_HANDLE,PUCHAR); +BOOL WINAPI WinUsb_GetDescriptor(WINUSB_INTERFACE_HANDLE,UCHAR,UCHAR,USHORT,PUCHAR,ULONG,PULONG); +BOOL WINAPI WinUsb_GetOverlappedResult(WINUSB_INTERFACE_HANDLE,LPOVERLAPPED,LPDWORD,BOOL); +BOOL WINAPI WinUsb_GetPipePolicy(WINUSB_INTERFACE_HANDLE,UCHAR,ULONG,PULONG,PVOID); +BOOL WINAPI WinUsb_GetPowerPolicy(WINUSB_INTERFACE_HANDLE,ULONG,PULONG,PVOID); +BOOL WINAPI WinUsb_Initialize(HANDLE,PWINUSB_INTERFACE_HANDLE); +BOOL WINAPI WinUsb_QueryDeviceInformation(WINUSB_INTERFACE_HANDLE,ULONG,PULONG,PVOID); +BOOL WINAPI WinUsb_ReadPipe(WINUSB_INTERFACE_HANDLE,UCHAR,PUCHAR,ULONG,PULONG,LPOVERLAPPED); +BOOL WINAPI WinUsb_ResetPipe(WINUSB_INTERFACE_HANDLE,UCHAR); +BOOL WINAPI WinUsb_SetCurrentAlternateSetting(WINUSB_INTERFACE_HANDLE,UCHAR); +BOOL WINAPI WinUsb_SetPipePolicy(WINUSB_INTERFACE_HANDLE,UCHAR,ULONG,ULONG,PVOID); +BOOL WINAPI WinUsb_SetPowerPolicy(WINUSB_INTERFACE_HANDLE,ULONG,ULONG,PVOID); +BOOL WINAPI WinUsb_WritePipe(WINUSB_INTERFACE_HANDLE,UCHAR,PUCHAR,ULONG,PULONG,LPOVERLAPPED); + +#ifdef __cplusplus +} +#endif + +#endif /* _WINUSB_H_ */
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52677 Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- Program runs with this patch. --- dlls/winusb/Makefile.in | 5 +++++ dlls/winusb/main.c | 36 ++++++++++++++++++++++++++++++++++++ dlls/winusb/winusb.spec | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 dlls/winusb/main.c
diff --git a/dlls/winusb/Makefile.in b/dlls/winusb/Makefile.in index c8cab4dbed9..b6f01a1346c 100644 --- a/dlls/winusb/Makefile.in +++ b/dlls/winusb/Makefile.in @@ -1 +1,6 @@ MODULE = winusb.dll + +EXTRADLLFLAGS = -Wb,--prefer-native + +C_SRCS = \ + main.c diff --git a/dlls/winusb/main.c b/dlls/winusb/main.c new file mode 100644 index 00000000000..2653b87d20d --- /dev/null +++ b/dlls/winusb/main.c @@ -0,0 +1,36 @@ +/* + * Copyright 2022 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> + +#include "windef.h" +#include "winbase.h" +#include "winusb.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(winusb); + +/*********************************************************************** + * WinUsb_Free (winusb.@) + */ +BOOL WINAPI WinUsb_Free(WINUSB_INTERFACE_HANDLE handle) +{ + FIXME( "(%p) - stub\n", handle ); + return TRUE; +} diff --git a/dlls/winusb/winusb.spec b/dlls/winusb/winusb.spec index 09371e9ee46..a0b57d58096 100644 --- a/dlls/winusb/winusb.spec +++ b/dlls/winusb/winusb.spec @@ -1,7 +1,7 @@ @ stub WinUsb_AbortPipe @ stub WinUsb_ControlTransfer @ stub WinUsb_FlushPipe -@ stub WinUsb_Free +@ stdcall WinUsb_Free(ptr) @ stub WinUsb_GetAssociatedInterface @ stub WinUsb_GetCurrentAlternateSetting @ stub WinUsb_GetDescriptor
On 4/14/22 01:36, Mohamad Al-Jaf wrote:
+#ifndef _WINUSB_H_ +#define _WINUSB_H_
+#ifdef __cplusplus +extern "C" { +#endif
+typedef PVOID WINUSB_INTERFACE_HANDLE, *PWINUSB_INTERFACE_HANDLE;
+typedef struct _WINUSB_SETUP_PACKET {
- UCHAR RequestType;
- UCHAR Request;
- USHORT Value;
- USHORT Index;
- USHORT Length;
+} WINUSB_SETUP_PACKET, *PWINUSB_SETUP_PACKET;
I think the struct packing is wrong, the SDK uses #pragma pack(1) here, which probably should use #include "pshpack1.h" / "poppack.h".
+BOOL WINAPI WinUsb_AbortPipe(WINUSB_INTERFACE_HANDLE,UCHAR); +BOOL WINAPI WinUsb_ControlTransfer(WINUSB_INTERFACE_HANDLE,WINUSB_SETUP_PACKET,PUCHAR,ULONG,PULONG,LPOVERLAPPED); +BOOL WINAPI WinUsb_FlushPipe(WINUSB_INTERFACE_HANDLE,UCHAR); +BOOL WINAPI WinUsb_Free(WINUSB_INTERFACE_HANDLE); +BOOL WINAPI WinUsb_GetAssociatedInterface(WINUSB_INTERFACE_HANDLE,UCHAR,PWINUSB_INTERFACE_HANDLE); +BOOL WINAPI WinUsb_GetCurrentAlternateSetting(WINUSB_INTERFACE_HANDLE,PUCHAR); +BOOL WINAPI WinUsb_GetDescriptor(WINUSB_INTERFACE_HANDLE,UCHAR,UCHAR,USHORT,PUCHAR,ULONG,PULONG); +BOOL WINAPI WinUsb_GetOverlappedResult(WINUSB_INTERFACE_HANDLE,LPOVERLAPPED,LPDWORD,BOOL); +BOOL WINAPI WinUsb_GetPipePolicy(WINUSB_INTERFACE_HANDLE,UCHAR,ULONG,PULONG,PVOID); +BOOL WINAPI WinUsb_GetPowerPolicy(WINUSB_INTERFACE_HANDLE,ULONG,PULONG,PVOID); +BOOL WINAPI WinUsb_Initialize(HANDLE,PWINUSB_INTERFACE_HANDLE); +BOOL WINAPI WinUsb_QueryDeviceInformation(WINUSB_INTERFACE_HANDLE,ULONG,PULONG,PVOID); +BOOL WINAPI WinUsb_ReadPipe(WINUSB_INTERFACE_HANDLE,UCHAR,PUCHAR,ULONG,PULONG,LPOVERLAPPED); +BOOL WINAPI WinUsb_ResetPipe(WINUSB_INTERFACE_HANDLE,UCHAR); +BOOL WINAPI WinUsb_SetCurrentAlternateSetting(WINUSB_INTERFACE_HANDLE,UCHAR); +BOOL WINAPI WinUsb_SetPipePolicy(WINUSB_INTERFACE_HANDLE,UCHAR,ULONG,ULONG,PVOID); +BOOL WINAPI WinUsb_SetPowerPolicy(WINUSB_INTERFACE_HANDLE,ULONG,ULONG,PVOID); +BOOL WINAPI WinUsb_WritePipe(WINUSB_INTERFACE_HANDLE,UCHAR,PUCHAR,ULONG,PULONG,LPOVERLAPPED);
I have no idea what's the usual policy for how to write these. The signatures look alright, but are we still using LP*/P* types, or should it be expanded to pointers?
I see the previous patch version had more functions, and I can't really tell if it's better or not. Imho either add only the functions that are going to be used (so WinUsb_Free) or required by third-party programs to build, or add everything that the SDK public headers declare?
Anything in between seems arbitrary to me, but I have not much experience in adding stuff like this.
On 4/28/22 07:33, Rémi Bernon wrote:
On 4/14/22 01:36, Mohamad Al-Jaf wrote:
+#ifndef _WINUSB_H_ +#define _WINUSB_H_
+#ifdef __cplusplus +extern "C" { +#endif
+typedef PVOID WINUSB_INTERFACE_HANDLE, *PWINUSB_INTERFACE_HANDLE;
+typedef struct _WINUSB_SETUP_PACKET {
- UCHAR RequestType;
- UCHAR Request;
- USHORT Value;
- USHORT Index;
- USHORT Length;
+} WINUSB_SETUP_PACKET, *PWINUSB_SETUP_PACKET;
I think the struct packing is wrong, the SDK uses #pragma pack(1) here, which probably should use #include "pshpack1.h" / "poppack.h".
It doesn't make a difference in this case, though.
On Thu, Apr 28, 2022 at 12:15 PM Zebediah Figura zfigura@codeweavers.com wrote:
I think the struct packing is wrong, the SDK uses #pragma pack(1) here, which probably should use #include "pshpack1.h" / "poppack.h".
It doesn't make a difference in this case, though.
Hi,
Thanks for the review.
In the previous version pshpack1.h / poppack.h were included in usb100.h and ddk/wdm.h which was needed by ddk/winusbio.h. Since it doesn't make a difference in this case I suppose there's no reason to add it.
On Thu, Apr 28, 2022 at 8:33 AM Rémi Bernon rbernon@codeweavers.com wrote:
I have no idea what's the usual policy for how to write these. The signatures look alright, but are we still using LP*/P* types, or should it be expanded to pointers?
I'm not sure either, Wine is inconsistent in this regard. At least in winbase.h there's a lot of LP*/P* types.
Just curious what difference it makes compared to being expanded to pointers?
I see the previous patch version had more functions, and I can't really tell if it's better or not. Imho either add only the functions that are going to be used (so WinUsb_Free) or required by third-party programs to build, or add everything that the SDK public headers declare?
Anything in between seems arbitrary to me, but I have not much experience in adding stuff like this.
Yeah, I agree that either all the functions or just the one that's going to be used would be better.
The reason I removed the ddk/winusbio.h dependent functions is that some copyright concerns were raised for the winusbio.h file. It's a rather small file and I'm not sure how to add it in this case. Would rearranging the flags and structs be sufficient?
I'm not sure what the policy for headers is. IMO, I find it useful for public headers to be fully added, well the relevant parts to Wine that is. It saves developers time from having to add them later. Still, I'm fine with doing it either way.
-- Kind regards, Mohamad