Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- The function WinUsb_Free is defined without WINBASEAPI in the Windows SDK header. --- include/Makefile.in | 1 + include/winusb.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 include/winusb.h
diff --git a/include/Makefile.in b/include/Makefile.in index 9578c557af7..189b4676091 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -833,6 +833,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..188b4380878 --- /dev/null +++ b/include/winusb.h @@ -0,0 +1,36 @@ +/* + * 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_ + +#include <winapifamily.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef PVOID WINUSB_INTERFACE_HANDLE, *PWINUSB_INTERFACE_HANDLE; + +BOOL WINAPI WinUsb_Free(WINUSB_INTERFACE_HANDLE); + +#ifdef __cplusplus +} +#endif + +#endif /* _WINUSB_H_ */
This allows the game Nickelodeon All-Star Brawl to run.
Proton-Issue: https://github.com/ValveSoftware/Proton/issues/5198 Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- v2: - Use HeapFree to free the WINUSB_INTERFACE_HANDLE.
This should be fine, right? There are similar functions using HeapFree or heap_free in the codebase. --- dlls/winusb/Makefile.in | 5 +++++ dlls/winusb/main.c | 37 +++++++++++++++++++++++++++++++++++++ dlls/winusb/winusb.spec | 2 +- 3 files changed, 43 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..bed7e5c3d62 --- /dev/null +++ b/dlls/winusb/main.c @@ -0,0 +1,37 @@ +/* + * 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(usb); + +/*********************************************************************** + * WinUsb_Free (winusb.@) + */ +BOOL WINAPI WinUsb_Free(WINUSB_INTERFACE_HANDLE handle) +{ + FIXME( "(%p) - semi-stub\n", handle ); + if (handle) HeapFree( GetProcessHeap(), 0, 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 3/10/22 22:57, Mohamad Al-Jaf wrote:
+/***********************************************************************
WinUsb_Free (winusb.@)
- */
+BOOL WINAPI WinUsb_Free(WINUSB_INTERFACE_HANDLE handle) +{
- FIXME( "(%p) - semi-stub\n", handle );
- if (handle) HeapFree( GetProcessHeap(), 0, handle );
- return TRUE;
+}
This doesn't make any sense by itself. Where is that handle coming from?
On Fri, Mar 11, 2022 at 11:47 AM Zebediah Figura zfigura@codeweavers.com wrote:
On 3/10/22 22:57, Mohamad Al-Jaf wrote:
+/***********************************************************************
WinUsb_Free (winusb.@)
- */
+BOOL WINAPI WinUsb_Free(WINUSB_INTERFACE_HANDLE handle) +{
- FIXME( "(%p) - semi-stub\n", handle );
- if (handle) HeapFree( GetProcessHeap(), 0, handle );
- return TRUE;
+}
This doesn't make any sense by itself. Where is that handle coming from?
Hi Zebediah,
Thanks for the feedback.
Yeah, it doesn't make sense to me either. I asked about this in my previous patch, but no one replied.
Also, I thought about adding heap_free(handle) to make this into a semi-stub, but wouldn't that cause heap corruption since the handle is not initialized? I'm not sure why it's being called first and not the function that initializes WINUSB_INTERFACE_HANDLE.
I don't know why the game calls WinUsb_Free prior to initializing the handle. What is it passing, a NULL pointer? If not, where did it get the handle?
This is why I added the if statement.
Also, this doesn't seem to be affecting just this game, but an application called REVELPROG-IS.[1] It too calls WinUsb_Free prior to initializing a handle.
Perhaps they're creating a SafeWinUsbHandle, in which case the handle can be assigned IntPtr.Zero before WinUsb_Free is called, but again this appears to be a NULL pointer.[2]
In any case, would it cause a problem to leave this function as a semi-stub? The if statement should prevent HeapFree from attempting to free a NULL pointer. If not, I can resubmit the original stub.
This patch isn't intended to fix applications that rely on winusb, just games. Proton just disabled the dll to fix the issue and this is why I offered to stub the entire dll even though it's likely not needed. The native dll can be used for applications, but seeing as how it's a Windows driver I don't think it would work properly, if at all.
[1] https://forum.reveltronics.com/viewtopic.php?p=2579&sid=ee42ab8a5b5737fb... [2] https://books.google.ca/books?id=pkefBgAAQBAJ&pg=PA319&lpg=PA319&...
-- Kind regards, Mohamad