winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
April 2021
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
865 discussions
Start a n
N
ew thread
Paul Gofman : kernel32: Implement VirtualAllocFromApp().
by Alexandre Julliard
15 Apr '21
15 Apr '21
Module: wine Branch: master Commit: 61ca1128d1ee4c3d34010ad2002495c9fbcaf966 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=61ca1128d1ee4c3d34010ad2…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Wed Apr 14 19:26:52 2021 +0300 kernel32: Implement VirtualAllocFromApp(). Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- .../api-ms-win-core-memory-l1-1-3.spec | 2 +- dlls/kernel32/tests/virtual.c | 39 +++++++++++++++++++++- dlls/kernelbase/kernelbase.spec | 2 +- dlls/kernelbase/memory.c | 22 ++++++++++++ include/winbase.h | 1 + 5 files changed, 63 insertions(+), 3 deletions(-) diff --git a/dlls/api-ms-win-core-memory-l1-1-3/api-ms-win-core-memory-l1-1-3.spec b/dlls/api-ms-win-core-memory-l1-1-3/api-ms-win-core-memory-l1-1-3.spec index b0d402b24c7..5b143ec1af3 100644 --- a/dlls/api-ms-win-core-memory-l1-1-3/api-ms-win-core-memory-l1-1-3.spec +++ b/dlls/api-ms-win-core-memory-l1-1-3/api-ms-win-core-memory-l1-1-3.spec @@ -19,7 +19,7 @@ @ stdcall UnmapViewOfFile(ptr) kernel32.UnmapViewOfFile @ stub UnmapViewOfFileEx @ stdcall VirtualAlloc(ptr long long long) kernel32.VirtualAlloc -@ stub VirtualAllocFromApp +@ stdcall VirtualAllocFromApp(ptr long long long) kernelbase.VirtualAllocFromApp @ stdcall VirtualFree(ptr long long) kernel32.VirtualFree @ stdcall VirtualFreeEx(long ptr long long) kernel32.VirtualFreeEx @ stdcall VirtualLock(ptr long) kernel32.VirtualLock diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index e6d9e8621a9..4abaa5befd1 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -35,7 +35,7 @@ #define NUM_THREADS 4 #define MAPPING_SIZE 0x100000 -static HINSTANCE hkernel32, hntdll; +static HINSTANCE hkernel32, hkernelbase, hntdll; static SYSTEM_INFO si; static UINT (WINAPI *pGetWriteWatch)(DWORD,LPVOID,SIZE_T,LPVOID*,ULONG_PTR*,ULONG*); static UINT (WINAPI *pResetWriteWatch)(LPVOID,SIZE_T); @@ -50,6 +50,7 @@ static ULONG (WINAPI *pRtlRemoveVectoredExceptionHandler)(PVOID); static BOOL (WINAPI *pGetProcessDEPPolicy)(HANDLE, LPDWORD, PBOOL); static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); static NTSTATUS (WINAPI *pNtProtectVirtualMemory)(HANDLE, PVOID *, SIZE_T *, ULONG, ULONG *); +static PVOID (WINAPI *pVirtualAllocFromApp)(PVOID, SIZE_T, DWORD, DWORD); /* ############################### */ @@ -443,6 +444,39 @@ static void test_VirtualAlloc(void) ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n"); } +static void test_VirtualAllocFromApp(void) +{ + void *p; + BOOL ret; + if (!pVirtualAllocFromApp) + { + win_skip("VirtualAllocFromApp is not available.\n"); + return; + } + + p = GetProcAddress(hkernel32, "VirtualAllocFromApp"); + ok(!p, "Found VirtualAllocFromApp in kernel32.dll.\n"); + + SetLastError(0xdeadbeef); + p = pVirtualAllocFromApp(NULL, 0x1000, MEM_RESERVE, PAGE_READWRITE); + ok(p && GetLastError() == 0xdeadbeef, "Got unexpected mem %p, GetLastError() %u.\n", p, GetLastError()); + ret = VirtualFree(p, 0, MEM_RELEASE); + ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError()); + + SetLastError(0xdeadbeef); + p = pVirtualAllocFromApp(NULL, 0x1000, MEM_RESERVE, PAGE_EXECUTE); + ok(!p && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected mem %p, GetLastError() %u.\n", + p, GetLastError()); + SetLastError(0xdeadbeef); + p = pVirtualAllocFromApp(NULL, 0x1000, MEM_RESERVE, PAGE_EXECUTE_READ); + ok(!p && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected mem %p, GetLastError() %u.\n", + p, GetLastError()); + SetLastError(0xdeadbeef); + p = pVirtualAllocFromApp(NULL, 0x1000, MEM_RESERVE, PAGE_EXECUTE_READWRITE); + ok(!p && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected mem %p, GetLastError() %u.\n", + p, GetLastError()); +} + static void test_MapViewOfFile(void) { static const char testfile[] = "testfile.xxx"; @@ -4238,6 +4272,7 @@ START_TEST(virtual) } hkernel32 = GetModuleHandleA("kernel32.dll"); + hkernelbase = GetModuleHandleA("kernelbase.dll"); hntdll = GetModuleHandleA("ntdll.dll"); pGetWriteWatch = (void *) GetProcAddress(hkernel32, "GetWriteWatch"); @@ -4252,6 +4287,7 @@ START_TEST(virtual) pRtlAddVectoredExceptionHandler = (void *)GetProcAddress( hntdll, "RtlAddVectoredExceptionHandler" ); pRtlRemoveVectoredExceptionHandler = (void *)GetProcAddress( hntdll, "RtlRemoveVectoredExceptionHandler" ); pNtProtectVirtualMemory = (void *)GetProcAddress( hntdll, "NtProtectVirtualMemory" ); + pVirtualAllocFromApp = (void *)GetProcAddress( hkernelbase, "VirtualAllocFromApp" ); GetSystemInfo(&si); trace("system page size %#x\n", si.dwPageSize); @@ -4266,6 +4302,7 @@ START_TEST(virtual) test_VirtualProtect(); test_VirtualAllocEx(); test_VirtualAlloc(); + test_VirtualAllocFromApp(); test_MapViewOfFile(); test_NtAreMappedFilesTheSame(); test_CreateFileMapping(); diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec index 615b928bd22..28cfd842223 100644 --- a/dlls/kernelbase/kernelbase.spec +++ b/dlls/kernelbase/kernelbase.spec @@ -1678,7 +1678,7 @@ @ stdcall VirtualAlloc(ptr long long long) @ stdcall VirtualAllocEx(long ptr long long long) @ stdcall VirtualAllocExNuma(long ptr long long long long) -# @ stub VirtualAllocFromApp +@ stdcall VirtualAllocFromApp(ptr long long long) @ stdcall VirtualFree(ptr long long) @ stdcall VirtualFreeEx(long ptr long long) @ stdcall VirtualLock(ptr long) diff --git a/dlls/kernelbase/memory.c b/dlls/kernelbase/memory.c index 60333db242f..4b71c0cc6ec 100644 --- a/dlls/kernelbase/memory.c +++ b/dlls/kernelbase/memory.c @@ -314,6 +314,28 @@ LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAlloc2( HANDLE process, void *addr, SIZE_ } +/*********************************************************************** + * VirtualAllocFromApp (kernelbase.@) + */ +LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAllocFromApp( void *addr, SIZE_T size, + DWORD type, DWORD protect ) +{ + LPVOID ret = addr; + + TRACE_(virtual)( "addr %p, size %p, type %#x, protect %#x.\n", addr, (void *)size, type, protect ); + + if (protect == PAGE_EXECUTE || protect == PAGE_EXECUTE_READ || protect == PAGE_EXECUTE_READWRITE + || protect == PAGE_EXECUTE_WRITECOPY) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return NULL; + } + + if (!set_ntstatus( NtAllocateVirtualMemory( GetCurrentProcess(), &ret, 0, &size, type, protect ))) return NULL; + return ret; +} + + /*********************************************************************** * VirtualFree (kernelbase.@) */ diff --git a/include/winbase.h b/include/winbase.h index beb91371bb6..11a92fa84d9 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -2748,6 +2748,7 @@ WINBASEAPI LPVOID WINAPI VirtualAlloc(LPVOID,SIZE_T,DWORD,DWORD); WINBASEAPI LPVOID WINAPI VirtualAlloc2(HANDLE,LPVOID,SIZE_T,DWORD,DWORD,MEM_EXTENDED_PARAMETER*,ULONG); WINBASEAPI LPVOID WINAPI VirtualAllocEx(HANDLE,LPVOID,SIZE_T,DWORD,DWORD); WINBASEAPI LPVOID WINAPI VirtualAllocExNuma(HANDLE,void*,SIZE_T,DWORD,DWORD,DWORD); +WINBASEAPI LPVOID WINAPI VirtualAllocFromApp(LPVOID,SIZE_T,DWORD,DWORD); WINBASEAPI BOOL WINAPI VirtualFree(LPVOID,SIZE_T,DWORD); WINBASEAPI BOOL WINAPI VirtualFreeEx(HANDLE,LPVOID,SIZE_T,DWORD); WINBASEAPI BOOL WINAPI VirtualLock(LPVOID,SIZE_T);
1
0
0
0
Zebediah Figura : hidclass.sys: Always wait for the lower driver in hid_device_thread().
by Alexandre Julliard
15 Apr '21
15 Apr '21
Module: wine Branch: master Commit: fd25cc3c3b5ec6eab43d4974b2d6c49080a4fcd6 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=fd25cc3c3b5ec6eab43d4974…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Wed Apr 14 23:22:07 2021 -0500 hidclass.sys: Always wait for the lower driver in hid_device_thread(). Doing otherwise may result in memory corruption. The lower driver should complete its IRPs on device removal anyway. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/hidclass.sys/device.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c index fc1dfd07db1..6ca5e39e648 100644 --- a/dlls/hidclass.sys/device.c +++ b/dlls/hidclass.sys/device.c @@ -288,12 +288,11 @@ static DWORD CALLBACK hid_device_thread(void *args) IO_STATUS_BLOCK irp_status; HID_XFER_PACKET *packet; DWORD rc; - HANDLE events[2]; + HANDLE event; NTSTATUS ntrc; BASE_DEVICE_EXTENSION *ext = device->DeviceExtension; - events[0] = CreateEventA(NULL, TRUE, FALSE, NULL); - events[1] = ext->halt_event; + event = CreateEventA(NULL, TRUE, FALSE, NULL); packet = HeapAlloc(GetProcessHeap(), 0, sizeof(*packet) + ext->preparseData->caps.InputReportByteLength); packet->reportBuffer = (BYTE *)packet + sizeof(*packet); @@ -302,7 +301,7 @@ static DWORD CALLBACK hid_device_thread(void *args) { while(1) { - ResetEvent(events[0]); + ResetEvent(event); packet->reportBufferLen = ext->preparseData->caps.InputReportByteLength; packet->reportId = 0; @@ -311,11 +310,11 @@ static DWORD CALLBACK hid_device_thread(void *args) device, NULL, 0, packet, sizeof(*packet), TRUE, NULL, &irp_status); - IoSetCompletionRoutine(irp, read_Completion, events[0], TRUE, TRUE, TRUE); + IoSetCompletionRoutine(irp, read_Completion, event, TRUE, TRUE, TRUE); ntrc = IoCallDriver(device, irp); if (ntrc == STATUS_PENDING) - WaitForMultipleObjects(2, events, FALSE, INFINITE); + WaitForSingleObject(event, INFINITE); if (irp->IoStatus.u.Status == STATUS_SUCCESS) { @@ -339,19 +338,19 @@ static DWORD CALLBACK hid_device_thread(void *args) while(1) { - ResetEvent(events[0]); + ResetEvent(event); irp = IoBuildDeviceIoControlRequest(IOCTL_HID_READ_REPORT, device, NULL, 0, packet->reportBuffer, ext->preparseData->caps.InputReportByteLength, TRUE, NULL, &irp_status); - IoSetCompletionRoutine(irp, read_Completion, events[0], TRUE, TRUE, TRUE); + IoSetCompletionRoutine(irp, read_Completion, event, TRUE, TRUE, TRUE); ntrc = IoCallDriver(device, irp); if (ntrc == STATUS_PENDING) { - WaitForMultipleObjects(2, events, FALSE, INFINITE); + WaitForSingleObject(event, INFINITE); } rc = WaitForSingleObject(ext->halt_event, 0); @@ -376,8 +375,7 @@ static DWORD CALLBACK hid_device_thread(void *args) } } - /* FIXME: releasing packet requires IRP cancellation support */ - CloseHandle(events[0]); + CloseHandle(event); TRACE("Device thread exiting\n"); return 1;
1
0
0
0
Zebediah Figura : winebus.sys: Move device destruction to IRP_MN_REMOVE_DEVICE.
by Alexandre Julliard
15 Apr '21
15 Apr '21
Module: wine Branch: master Commit: 27f40156baa7f1e09c6e420f6c278606557a505a URL:
https://source.winehq.org/git/wine.git/?a=commit;h=27f40156baa7f1e09c6e420f…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Wed Apr 14 23:22:06 2021 -0500 winebus.sys: Move device destruction to IRP_MN_REMOVE_DEVICE. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winebus.sys/bus_iohid.c | 1 - dlls/winebus.sys/bus_sdl.c | 4 ++-- dlls/winebus.sys/bus_udev.c | 2 +- dlls/winebus.sys/main.c | 56 ++++++++++++++++++++++++++++++-------------- 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index c275011b491..0123e73f7ba 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -384,7 +384,6 @@ static void handle_RemovalCallback(void *context, IOReturn result, void *sender, { bus_unlink_hid_device(device); IoInvalidateDeviceRelations(bus_pdo, BusRelations); - bus_remove_hid_device(device); } } diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 154c0fb19a3..779a1af2736 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -890,8 +890,6 @@ static void try_remove_device(SDL_JoystickID id) bus_unlink_hid_device(device); IoInvalidateDeviceRelations(bus_pdo, BusRelations); - - bus_remove_hid_device(device); } static void try_add_device(unsigned int index) @@ -965,6 +963,8 @@ static void try_add_device(unsigned int index) private->sdl_joystick = joystick; private->sdl_controller = controller; private->id = id; + + /* FIXME: We should probably move this to IRP_MN_START_DEVICE. */ if (controller) rc = build_mapped_report_descriptor(private); else diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index c717c13a7db..0c150322006 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -1300,6 +1300,7 @@ static void try_add_device(struct udev_device *dev) private->device_fd = fd; #ifdef HAS_PROPER_INPUT_HEADER if (strcmp(subsystem, "input") == 0) + /* FIXME: We should probably move this to IRP_MN_START_DEVICE. */ if (!build_report_descriptor((struct wine_input_private*)private, dev)) { ERR("Building report descriptor failed, removing device\n"); @@ -1335,7 +1336,6 @@ static void try_remove_device(struct udev_device *dev) bus_unlink_hid_device(device); IoInvalidateDeviceRelations(bus_pdo, BusRelations); - bus_remove_hid_device(device); } static void build_initial_deviceset(void) diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 598cd2483fa..01e839f02d8 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -367,24 +367,9 @@ void bus_remove_hid_device(DEVICE_OBJECT *device) { struct device_extension *ext = (struct device_extension *)device->DeviceExtension; struct pnp_device *pnp_device = ext->pnp_device; - LIST_ENTRY *entry; - IRP *irp; TRACE("(%p)\n", device); - /* Cancel pending IRPs */ - EnterCriticalSection(&ext->cs); - while ((entry = RemoveHeadList(&ext->irp_queue)) != &ext->irp_queue) - { - irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.s.ListEntry); - irp->IoStatus.u.Status = STATUS_DELETE_PENDING; - irp->IoStatus.Information = 0; - IoCompleteRequest(irp, IO_NO_INCREMENT); - } - LeaveCriticalSection(&ext->cs); - - ext->vtbl->free_device(device); - ext->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&ext->cs); @@ -606,19 +591,56 @@ static NTSTATUS fdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp) static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp) { + struct device_extension *ext = device->DeviceExtension; NTSTATUS status = irp->IoStatus.u.Status; IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); + TRACE("device %p, irp %p, minor function %#x.\n", device, irp, irpsp->MinorFunction); + switch (irpsp->MinorFunction) { case IRP_MN_QUERY_ID: - TRACE("IRP_MN_QUERY_ID\n"); status = handle_IRP_MN_QUERY_ID(device, irp); break; + case IRP_MN_QUERY_CAPABILITIES: - TRACE("IRP_MN_QUERY_CAPABILITIES\n"); status = STATUS_SUCCESS; break; + + case IRP_MN_REMOVE_DEVICE: + { + struct pnp_device *pnp_device = ext->pnp_device; + LIST_ENTRY *entry; + + EnterCriticalSection(&ext->cs); + while ((entry = RemoveHeadList(&ext->irp_queue)) != &ext->irp_queue) + { + IRP *queued_irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.s.ListEntry); + queued_irp->IoStatus.u.Status = STATUS_DELETE_PENDING; + queued_irp->IoStatus.Information = 0; + IoCompleteRequest(queued_irp, IO_NO_INCREMENT); + } + LeaveCriticalSection(&ext->cs); + + ext->vtbl->free_device(device); + + ext->cs.DebugInfo->Spare[0] = 0; + DeleteCriticalSection(&ext->cs); + + HeapFree(GetProcessHeap(), 0, ext->serial); + HeapFree(GetProcessHeap(), 0, ext->last_report); + + irp->IoStatus.u.Status = STATUS_SUCCESS; + IoCompleteRequest(irp, IO_NO_INCREMENT); + + IoDeleteDevice(device); + + /* pnp_device must be released after the device is gone */ + HeapFree(GetProcessHeap(), 0, pnp_device); + + return STATUS_SUCCESS; + } + default: FIXME("Unhandled function %08x\n", irpsp->MinorFunction); break;
1
0
0
0
Zebediah Figura : winebus.sys: Reject ioctls on a removed device.
by Alexandre Julliard
15 Apr '21
15 Apr '21
Module: wine Branch: master Commit: b0f25d7e1bd3654f7e028ef4a557ce9528173297 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=b0f25d7e1bd3654f7e028ef4…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Wed Apr 14 23:22:05 2021 -0500 winebus.sys: Reject ioctls on a removed device. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winebus.sys/main.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index f184945779d..598cd2483fa 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -114,6 +114,8 @@ struct device_extension { CRITICAL_SECTION cs; + BOOL removed; + struct pnp_device *pnp_device; WORD vid, pid, input; @@ -355,6 +357,10 @@ void bus_unlink_hid_device(DEVICE_OBJECT *device) EnterCriticalSection(&device_list_cs); list_remove(&pnp_device->entry); LeaveCriticalSection(&device_list_cs); + + EnterCriticalSection(&ext->cs); + ext->removed = TRUE; + LeaveCriticalSection(&ext->cs); } void bus_remove_hid_device(DEVICE_OBJECT *device) @@ -709,6 +715,16 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) return IoCallDriver(bus_pdo, irp); } + EnterCriticalSection(&ext->cs); + + if (ext->removed) + { + LeaveCriticalSection(&ext->cs); + irp->IoStatus.u.Status = STATUS_DELETE_PENDING; + IoCompleteRequest(irp, IO_NO_INCREMENT); + return STATUS_DELETE_PENDING; + } + switch (irpsp->Parameters.DeviceIoControl.IoControlCode) { case IOCTL_HID_GET_DEVICE_ATTRIBUTES: @@ -791,7 +807,6 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) { HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); TRACE_(hid_report)("IOCTL_HID_GET_INPUT_REPORT\n"); - EnterCriticalSection(&ext->cs); status = ext->vtbl->begin_report_processing(device); if (status != STATUS_SUCCESS) { @@ -806,13 +821,11 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) if (status == STATUS_SUCCESS) packet->reportBufferLen = irp->IoStatus.Information; - LeaveCriticalSection(&ext->cs); break; } case IOCTL_HID_READ_REPORT: { TRACE_(hid_report)("IOCTL_HID_READ_REPORT\n"); - EnterCriticalSection(&ext->cs); status = ext->vtbl->begin_report_processing(device); if (status != STATUS_SUCCESS) { @@ -832,7 +845,6 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) InsertTailList(&ext->irp_queue, &irp->Tail.Overlay.s.ListEntry); status = STATUS_PENDING; } - LeaveCriticalSection(&ext->cs); break; } case IOCTL_HID_SET_OUTPUT_REPORT: @@ -873,6 +885,8 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) } } + LeaveCriticalSection(&ext->cs); + if (status != STATUS_PENDING) IoCompleteRequest(irp, IO_NO_INCREMENT);
1
0
0
0
Zebediah Figura : winebus.sys: Move platform-specific device cleanup to a callback function.
by Alexandre Julliard
15 Apr '21
15 Apr '21
Module: wine Branch: master Commit: f8ec3fdcdbdc6a0d3a062cbbb61b47229fd177cb URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f8ec3fdcdbdc6a0d3a062cbb…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Wed Apr 14 23:22:04 2021 -0500 winebus.sys: Move platform-specific device cleanup to a callback function. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winebus.sys/bus.h | 1 + dlls/winebus.sys/bus_iohid.c | 5 +++ dlls/winebus.sys/bus_sdl.c | 27 ++++++-------- dlls/winebus.sys/bus_udev.c | 88 ++++++++++++++++++++------------------------ dlls/winebus.sys/main.c | 7 ++++ 5 files changed, 65 insertions(+), 63 deletions(-) diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h index 22a4b46a516..a157f576ef9 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -29,6 +29,7 @@ void sdl_driver_unload( void ) DECLSPEC_HIDDEN; /* Native device function table */ typedef struct { + void (*free_device)(DEVICE_OBJECT *device); int (*compare_platform_device)(DEVICE_OBJECT *device, void *platform_dev); NTSTATUS (*get_reportdescriptor)(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length); NTSTATUS (*get_string)(DEVICE_OBJECT *device, DWORD index, WCHAR *buffer, DWORD length); diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index ee6225bf398..c275011b491 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -136,6 +136,10 @@ static void handle_IOHIDDeviceIOHIDReportCallback(void *context, process_hid_report(device, report, report_length); } +static void free_device(DEVICE_OBJECT *device) +{ +} + static int compare_platform_device(DEVICE_OBJECT *device, void *platform_dev) { struct platform_private *private = impl_from_DEVICE_OBJECT(device); @@ -270,6 +274,7 @@ static NTSTATUS set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report static const platform_vtbl iohid_vtbl = { + free_device, compare_platform_device, get_reportdescriptor, get_string, diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index bf62f448976..154c0fb19a3 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -605,6 +605,17 @@ static BOOL build_mapped_report_descriptor(struct platform_private *ext) return TRUE; } +static void free_device(DEVICE_OBJECT *device) +{ + struct platform_private *ext = impl_from_DEVICE_OBJECT(device); + + pSDL_JoystickClose(ext->sdl_joystick); + if (ext->sdl_controller) + pSDL_GameControllerClose(ext->sdl_controller); + if (ext->sdl_haptic) + pSDL_HapticClose(ext->sdl_haptic); +} + static int compare_platform_device(DEVICE_OBJECT *device, void *platform_dev) { SDL_JoystickID id1 = impl_from_DEVICE_OBJECT(device)->id; @@ -722,6 +733,7 @@ static NTSTATUS set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report static const platform_vtbl sdl_vtbl = { + free_device, compare_platform_device, get_reportdescriptor, get_string, @@ -872,29 +884,14 @@ static BOOL set_mapped_report_from_event(SDL_Event *event) static void try_remove_device(SDL_JoystickID id) { DEVICE_OBJECT *device = NULL; - struct platform_private *private; - SDL_Joystick *sdl_joystick; - SDL_GameController *sdl_controller; - SDL_Haptic *sdl_haptic; device = bus_enumerate_hid_devices(&sdl_vtbl, compare_joystick_id, ULongToPtr(id)); if (!device) return; - private = impl_from_DEVICE_OBJECT(device); - sdl_joystick = private->sdl_joystick; - sdl_controller = private->sdl_controller; - sdl_haptic = private->sdl_haptic; - bus_unlink_hid_device(device); IoInvalidateDeviceRelations(bus_pdo, BusRelations); bus_remove_hid_device(device); - - pSDL_JoystickClose(sdl_joystick); - if (sdl_controller) - pSDL_GameControllerClose(sdl_controller); - if (sdl_haptic) - pSDL_HapticClose(sdl_haptic); } static void try_add_device(unsigned int index) diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 74cf6a28a1a..c717c13a7db 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -653,6 +653,23 @@ static WCHAR *get_sysattr_string(struct udev_device *dev, const char *sysattr) return strdupAtoW(attr); } +static void hidraw_free_device(DEVICE_OBJECT *device) +{ + struct platform_private *private = impl_from_DEVICE_OBJECT(device); + + if (private->report_thread) + { + write(private->control_pipe[1], "q", 1); + WaitForSingleObject(private->report_thread, INFINITE); + close(private->control_pipe[0]); + close(private->control_pipe[1]); + CloseHandle(private->report_thread); + } + + close(private->device_fd); + udev_device_unref(private->udev_device); +} + static int compare_platform_device(DEVICE_OBJECT *device, void *platform_dev) { struct udev_device *dev1 = impl_from_DEVICE_OBJECT(device)->udev_device; @@ -921,6 +938,7 @@ static NTSTATUS hidraw_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE static const platform_vtbl hidraw_vtbl = { + hidraw_free_device, compare_platform_device, hidraw_get_reportdescriptor, hidraw_get_string, @@ -937,6 +955,27 @@ static inline struct wine_input_private *input_impl_from_DEVICE_OBJECT(DEVICE_OB return (struct wine_input_private*)get_platform_private(device); } +static void lnxev_free_device(DEVICE_OBJECT *device) +{ + struct wine_input_private *ext = input_impl_from_DEVICE_OBJECT(device); + + if (ext->base.report_thread) + { + write(ext->base.control_pipe[1], "q", 1); + WaitForSingleObject(ext->base.report_thread, INFINITE); + close(ext->base.control_pipe[0]); + close(ext->base.control_pipe[1]); + CloseHandle(ext->base.report_thread); + } + + HeapFree(GetProcessHeap(), 0, ext->current_report_buffer); + HeapFree(GetProcessHeap(), 0, ext->last_report_buffer); + HeapFree(GetProcessHeap(), 0, ext->report_descriptor); + + close(ext->base.device_fd); + udev_device_unref(ext->base.udev_device); +} + static NTSTATUS lnxev_get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length) { struct wine_input_private *ext = input_impl_from_DEVICE_OBJECT(device); @@ -1051,6 +1090,7 @@ static NTSTATUS lnxev_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE * } static const platform_vtbl lnxev_vtbl = { + lnxev_free_device, compare_platform_device, lnxev_get_reportdescriptor, lnxev_get_string, @@ -1285,54 +1325,17 @@ static void try_add_device(struct udev_device *dev) static void try_remove_device(struct udev_device *dev) { DEVICE_OBJECT *device = NULL; - struct platform_private* private; -#ifdef HAS_PROPER_INPUT_HEADER - BOOL is_input = FALSE; -#endif device = bus_find_hid_device(&hidraw_vtbl, dev); #ifdef HAS_PROPER_INPUT_HEADER if (device == NULL) - { device = bus_find_hid_device(&lnxev_vtbl, dev); - is_input = TRUE; - } #endif if (!device) return; bus_unlink_hid_device(device); IoInvalidateDeviceRelations(bus_pdo, BusRelations); - - private = impl_from_DEVICE_OBJECT(device); - - if (private->report_thread) - { - write(private->control_pipe[1], "q", 1); - WaitForSingleObject(private->report_thread, INFINITE); - close(private->control_pipe[0]); - close(private->control_pipe[1]); - CloseHandle(private->report_thread); -#ifdef HAS_PROPER_INPUT_HEADER - if (strcmp(udev_device_get_subsystem(dev), "input") == 0) - { - HeapFree(GetProcessHeap(), 0, ((struct wine_input_private*)private)->current_report_buffer); - HeapFree(GetProcessHeap(), 0, ((struct wine_input_private*)private)->last_report_buffer); - } -#endif - } - -#ifdef HAS_PROPER_INPUT_HEADER - if (is_input) - { - struct wine_input_private *ext = (struct wine_input_private*)private; - HeapFree(GetProcessHeap(), 0, ext->report_descriptor); - } -#endif - - dev = private->udev_device; - close(private->device_fd); bus_remove_hid_device(device); - udev_device_unref(dev); } static void build_initial_deviceset(void) @@ -1482,12 +1485,6 @@ static DWORD CALLBACK deviceloop_thread(void *args) return 0; } -static int device_unload(DEVICE_OBJECT *device, void *context) -{ - try_remove_device(impl_from_DEVICE_OBJECT(device)->udev_device); - return 1; -} - void udev_driver_unload( void ) { TRACE("Unload Driver\n"); @@ -1500,11 +1497,6 @@ void udev_driver_unload( void ) close(deviceloop_control[0]); close(deviceloop_control[1]); CloseHandle(deviceloop_handle); - - bus_enumerate_hid_devices(&hidraw_vtbl, device_unload, NULL); -#ifdef HAS_PROPER_INPUT_HEADER - bus_enumerate_hid_devices(&lnxev_vtbl, device_unload, NULL); -#endif } NTSTATUS udev_driver_init(void) diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 7d3f5064f84..f184945779d 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -377,6 +377,8 @@ void bus_remove_hid_device(DEVICE_OBJECT *device) } LeaveCriticalSection(&ext->cs); + ext->vtbl->free_device(device); + ext->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&ext->cs); @@ -474,6 +476,10 @@ static NTSTATUS handle_IRP_MN_QUERY_ID(DEVICE_OBJECT *device, IRP *irp) return status; } +static void mouse_free_device(DEVICE_OBJECT *device) +{ +} + static NTSTATUS mouse_get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *ret_length) { TRACE("buffer %p, length %u.\n", buffer, length); @@ -526,6 +532,7 @@ static NTSTATUS mouse_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE * static const platform_vtbl mouse_vtbl = { + .free_device = mouse_free_device, .get_reportdescriptor = mouse_get_reportdescriptor, .get_string = mouse_get_string, .begin_report_processing = mouse_begin_report_processing,
1
0
0
0
Zebediah Figura : winebus.sys: Rename "report_cs" to "cs".
by Alexandre Julliard
15 Apr '21
15 Apr '21
Module: wine Branch: master Commit: b6409950d95e59201c914dd801388c1938b3dca5 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=b6409950d95e59201c914dd8…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Wed Apr 14 23:22:03 2021 -0500 winebus.sys: Rename "report_cs" to "cs". Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winebus.sys/main.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 8d3dec4779a..7d3f5064f84 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -112,6 +112,8 @@ struct pnp_device struct device_extension { + CRITICAL_SECTION cs; + struct pnp_device *pnp_device; WORD vid, pid, input; @@ -127,7 +129,6 @@ struct device_extension BOOL last_report_read; DWORD buffer_size; LIST_ENTRY irp_queue; - CRITICAL_SECTION report_cs; BYTE platform_private[1]; }; @@ -285,8 +286,8 @@ DEVICE_OBJECT *bus_create_hid_device(const WCHAR *busidW, WORD vid, WORD pid, memset(ext->platform_private, 0, platform_data_size); InitializeListHead(&ext->irp_queue); - InitializeCriticalSection(&ext->report_cs); - ext->report_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": report_cs"); + InitializeCriticalSection(&ext->cs); + ext->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": cs"); /* add to list of pnp devices */ pnp_dev->device = device; @@ -366,7 +367,7 @@ void bus_remove_hid_device(DEVICE_OBJECT *device) TRACE("(%p)\n", device); /* Cancel pending IRPs */ - EnterCriticalSection(&ext->report_cs); + EnterCriticalSection(&ext->cs); while ((entry = RemoveHeadList(&ext->irp_queue)) != &ext->irp_queue) { irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.s.ListEntry); @@ -374,10 +375,10 @@ void bus_remove_hid_device(DEVICE_OBJECT *device) irp->IoStatus.Information = 0; IoCompleteRequest(irp, IO_NO_INCREMENT); } - LeaveCriticalSection(&ext->report_cs); + LeaveCriticalSection(&ext->cs); - ext->report_cs.DebugInfo->Spare[0] = 0; - DeleteCriticalSection(&ext->report_cs); + ext->cs.DebugInfo->Spare[0] = 0; + DeleteCriticalSection(&ext->cs); HeapFree(GetProcessHeap(), 0, ext->serial); HeapFree(GetProcessHeap(), 0, ext->last_report); @@ -783,12 +784,12 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) { HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); TRACE_(hid_report)("IOCTL_HID_GET_INPUT_REPORT\n"); - EnterCriticalSection(&ext->report_cs); + EnterCriticalSection(&ext->cs); status = ext->vtbl->begin_report_processing(device); if (status != STATUS_SUCCESS) { irp->IoStatus.u.Status = status; - LeaveCriticalSection(&ext->report_cs); + LeaveCriticalSection(&ext->cs); break; } @@ -798,18 +799,18 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) if (status == STATUS_SUCCESS) packet->reportBufferLen = irp->IoStatus.Information; - LeaveCriticalSection(&ext->report_cs); + LeaveCriticalSection(&ext->cs); break; } case IOCTL_HID_READ_REPORT: { TRACE_(hid_report)("IOCTL_HID_READ_REPORT\n"); - EnterCriticalSection(&ext->report_cs); + EnterCriticalSection(&ext->cs); status = ext->vtbl->begin_report_processing(device); if (status != STATUS_SUCCESS) { irp->IoStatus.u.Status = status; - LeaveCriticalSection(&ext->report_cs); + LeaveCriticalSection(&ext->cs); break; } if (!ext->last_report_read) @@ -824,7 +825,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) InsertTailList(&ext->irp_queue, &irp->Tail.Overlay.s.ListEntry); status = STATUS_PENDING; } - LeaveCriticalSection(&ext->report_cs); + LeaveCriticalSection(&ext->cs); break; } case IOCTL_HID_SET_OUTPUT_REPORT: @@ -880,7 +881,7 @@ void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) if (!length || !report) return; - EnterCriticalSection(&ext->report_cs); + EnterCriticalSection(&ext->cs); if (length > ext->buffer_size) { HeapFree(GetProcessHeap(), 0, ext->last_report); @@ -891,7 +892,7 @@ void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) ext->buffer_size = 0; ext->last_report_size = 0; ext->last_report_read = TRUE; - LeaveCriticalSection(&ext->report_cs); + LeaveCriticalSection(&ext->cs); return; } else @@ -914,7 +915,7 @@ void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) ext->last_report_read = TRUE; IoCompleteRequest(irp, IO_NO_INCREMENT); } - LeaveCriticalSection(&ext->report_cs); + LeaveCriticalSection(&ext->cs); } DWORD check_bus_option(const UNICODE_STRING *option, DWORD default_value)
1
0
0
0
Rémi Bernon : user32: Implement SendInput INPUT_HARDWARE check.
by Alexandre Julliard
14 Apr '21
14 Apr '21
Module: wine Branch: master Commit: 092c7a09a5afde3f11b71b1816388e80d062e8ec URL:
https://source.winehq.org/git/wine.git/?a=commit;h=092c7a09a5afde3f11b71b18…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Apr 9 13:11:32 2021 +0200 user32: Implement SendInput INPUT_HARDWARE check. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=50506
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/input.c | 14 ++++++++++---- dlls/user32/tests/input.c | 10 ++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 22e53585f00..7cf7e53a6c8 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -180,7 +180,7 @@ static void update_mouse_coords( INPUT *input ) UINT WINAPI SendInput( UINT count, LPINPUT inputs, int size ) { UINT i; - NTSTATUS status; + NTSTATUS status = STATUS_SUCCESS; if (size != sizeof(INPUT)) { @@ -202,14 +202,20 @@ UINT WINAPI SendInput( UINT count, LPINPUT inputs, int size ) for (i = 0; i < count; i++) { - if (inputs[i].type == INPUT_MOUSE) + INPUT input = inputs[i]; + switch (input.type) { + case INPUT_MOUSE: /* we need to update the coordinates to what the server expects */ - INPUT input = inputs[i]; update_mouse_coords( &input ); + /* fallthrough */ + case INPUT_KEYBOARD: status = send_hardware_message( 0, &input, SEND_HWMSG_INJECTED ); + break; + case INPUT_HARDWARE: + SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); + return 0; } - else status = send_hardware_message( 0, &inputs[i], SEND_HWMSG_INJECTED ); if (status) { diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 0bbd03c615e..2397b4104e4 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -4285,12 +4285,11 @@ static void test_SendInput(void) input[1].hi.wParamH = 'A' | 0xc000; SetLastError( 0xdeadbeef ); res = SendInput( 16, input, sizeof(*input) ); - todo_wine ok( (res == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) || broken(res == 16 && GetLastError() == 0xdeadbeef) /* 32bit */, "SendInput returned %u, error %#x\n", res, GetLastError() ); while ((res = wait_for_message(&msg)) && msg.message == WM_TIMER) DispatchMessageA(&msg); - todo_wine ok( !res, "SendInput triggered unexpected message %#x\n", msg.message ); + ok( !res, "SendInput triggered unexpected message %#x\n", msg.message ); empty_message_queue(); memset( input, 0, sizeof(input) ); @@ -4303,21 +4302,20 @@ static void test_SendInput(void) input[2].ki.dwFlags = KEYEVENTF_KEYUP; SetLastError( 0xdeadbeef ); res = SendInput( 16, input, sizeof(*input) ); - todo_wine ok( (res == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) || broken(res == 16 && GetLastError() == 0xdeadbeef), "SendInput returned %u, error %#x\n", res, GetLastError() ); while ((res = wait_for_message(&msg)) && (msg.message == WM_TIMER || broken(msg.message == WM_KEYDOWN || msg.message == WM_KEYUP))) DispatchMessageA(&msg); - todo_wine ok( !res, "SendInput triggered unexpected message %#x\n", msg.message ); + ok( !res, "SendInput triggered unexpected message %#x\n", msg.message ); empty_message_queue(); for (i = 0; i < ARRAY_SIZE(input); ++i) input[i].type = INPUT_HARDWARE + 1; SetLastError( 0xdeadbeef ); res = SendInput( 16, input, sizeof(*input) ); - todo_wine ok( res == 16 && GetLastError() == 0xdeadbeef, "SendInput returned %u, error %#x\n", res, GetLastError() ); + ok( res == 16 && GetLastError() == 0xdeadbeef, "SendInput returned %u, error %#x\n", res, GetLastError() ); while ((res = wait_for_message(&msg)) && msg.message == WM_TIMER) DispatchMessageA(&msg); - todo_wine ok( !res, "SendInput triggered unexpected message %#x\n", msg.message ); + ok( !res, "SendInput triggered unexpected message %#x\n", msg.message ); empty_message_queue(); trace( "done\n" );
1
0
0
0
Rémi Bernon : user32/tests: Add more SendInput tests.
by Alexandre Julliard
14 Apr '21
14 Apr '21
Module: wine Branch: master Commit: 2f8da3c12adcd29f69d568c4fbba37ddfecbded6 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=2f8da3c12adcd29f69d568c4…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Apr 9 13:11:31 2021 +0200 user32/tests: Add more SendInput tests. Validating that SendInput with INPUT_HARDWARE type should be no-op. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=50506
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/input.c | 18 ++++++++ dlls/user32/tests/input.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 8992c463c48..22e53585f00 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -182,6 +182,24 @@ UINT WINAPI SendInput( UINT count, LPINPUT inputs, int size ) UINT i; NTSTATUS status; + if (size != sizeof(INPUT)) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return 0; + } + + if (!count) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return 0; + } + + if (!inputs) + { + SetLastError( ERROR_NOACCESS ); + return 0; + } + for (i = 0; i < count; i++) { if (inputs[i].type == INPUT_MOUSE) diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 646a9a66eb5..0bbd03c615e 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -4212,6 +4212,118 @@ static void test_UnregisterDeviceNotification(void) ok(ret == FALSE, "Unregistering NULL Device Notification returned: %d\n", ret); } +static void test_SendInput(void) +{ + INPUT input[16]; + UINT res, i; + HWND hwnd; + MSG msg; + + hwnd = CreateWindowW( L"static", L"test", WS_OVERLAPPED, 0, 0, 100, 100, 0, 0, 0, 0 ); + ok( hwnd != 0, "CreateWindowW failed\n" ); + + ShowWindow( hwnd, SW_SHOWNORMAL ); + UpdateWindow( hwnd ); + SetForegroundWindow( hwnd ); + SetFocus( hwnd ); + empty_message_queue(); + + SetLastError( 0xdeadbeef ); + res = SendInput( 0, NULL, 0 ); + ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() ); + SetLastError( 0xdeadbeef ); + res = SendInput( 1, NULL, 0 ); + ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() ); + SetLastError( 0xdeadbeef ); + res = SendInput( 1, NULL, sizeof(*input) ); + ok( res == 0 && (GetLastError() == ERROR_NOACCESS || GetLastError() == ERROR_INVALID_PARAMETER), + "SendInput returned %u, error %#x\n", res, GetLastError() ); + SetLastError( 0xdeadbeef ); + res = SendInput( 0, input, sizeof(*input) ); + ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() ); + SetLastError( 0xdeadbeef ); + res = SendInput( 0, NULL, sizeof(*input) ); + ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() ); + + memset( input, 0, sizeof(input) ); + SetLastError( 0xdeadbeef ); + res = SendInput( 1, input, sizeof(*input) ); + ok( res == 1 && GetLastError() == 0xdeadbeef, "SendInput returned %u, error %#x\n", res, GetLastError() ); + SetLastError( 0xdeadbeef ); + res = SendInput( 16, input, sizeof(*input) ); + ok( res == 16 && GetLastError() == 0xdeadbeef, "SendInput returned %u, error %#x\n", res, GetLastError() ); + + SetLastError( 0xdeadbeef ); + res = SendInput( 1, input, 0 ); + ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() ); + SetLastError( 0xdeadbeef ); + res = SendInput( 1, input, sizeof(*input) + 1 ); + ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() ); + SetLastError( 0xdeadbeef ); + res = SendInput( 1, input, sizeof(*input) - 1 ); + ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() ); + + for (i = 0; i < ARRAY_SIZE(input); ++i) input[i].type = INPUT_KEYBOARD; + SetLastError( 0xdeadbeef ); + res = SendInput( 16, input, offsetof( INPUT, ki ) + sizeof(KEYBDINPUT) ); + ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() ); + SetLastError( 0xdeadbeef ); + res = SendInput( 16, input, sizeof(*input) ); + ok( res == 16 && GetLastError() == 0xdeadbeef, "SendInput returned %u, error %#x\n", res, GetLastError() ); + empty_message_queue(); + + for (i = 0; i < ARRAY_SIZE(input); ++i) input[i].type = INPUT_HARDWARE; + SetLastError( 0xdeadbeef ); + res = SendInput( 16, input, offsetof( INPUT, hi ) + sizeof(HARDWAREINPUT) ); + ok( res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError() ); + + input[0].hi.uMsg = WM_KEYDOWN; + input[0].hi.wParamL = 0; + input[0].hi.wParamH = 'A'; + input[1].hi.uMsg = WM_KEYUP; + input[1].hi.wParamL = 0; + input[1].hi.wParamH = 'A' | 0xc000; + SetLastError( 0xdeadbeef ); + res = SendInput( 16, input, sizeof(*input) ); + todo_wine + ok( (res == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) || + broken(res == 16 && GetLastError() == 0xdeadbeef) /* 32bit */, + "SendInput returned %u, error %#x\n", res, GetLastError() ); + while ((res = wait_for_message(&msg)) && msg.message == WM_TIMER) DispatchMessageA(&msg); + todo_wine ok( !res, "SendInput triggered unexpected message %#x\n", msg.message ); + empty_message_queue(); + + memset( input, 0, sizeof(input) ); + input[0].type = INPUT_HARDWARE; + input[1].type = INPUT_KEYBOARD; + input[1].ki.wVk = 'A'; + input[1].ki.dwFlags = 0; + input[2].type = INPUT_KEYBOARD; + input[2].ki.wVk = 'A'; + input[2].ki.dwFlags = KEYEVENTF_KEYUP; + SetLastError( 0xdeadbeef ); + res = SendInput( 16, input, sizeof(*input) ); + todo_wine + ok( (res == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) || + broken(res == 16 && GetLastError() == 0xdeadbeef), + "SendInput returned %u, error %#x\n", res, GetLastError() ); + while ((res = wait_for_message(&msg)) && (msg.message == WM_TIMER || broken(msg.message == WM_KEYDOWN || msg.message == WM_KEYUP))) + DispatchMessageA(&msg); + todo_wine ok( !res, "SendInput triggered unexpected message %#x\n", msg.message ); + empty_message_queue(); + + for (i = 0; i < ARRAY_SIZE(input); ++i) input[i].type = INPUT_HARDWARE + 1; + SetLastError( 0xdeadbeef ); + res = SendInput( 16, input, sizeof(*input) ); + todo_wine ok( res == 16 && GetLastError() == 0xdeadbeef, "SendInput returned %u, error %#x\n", res, GetLastError() ); + while ((res = wait_for_message(&msg)) && msg.message == WM_TIMER) DispatchMessageA(&msg); + todo_wine ok( !res, "SendInput triggered unexpected message %#x\n", msg.message ); + empty_message_queue(); + + trace( "done\n" ); + DestroyWindow( hwnd ); +} + START_TEST(input) { char **argv; @@ -4234,6 +4346,7 @@ START_TEST(input) return; } + test_SendInput(); test_Input_blackbox(); test_Input_whitebox(); test_Input_unicode();
1
0
0
0
Georg Lehmann : winevulkan: Fix queue creation with mixed queue flags.
by Alexandre Julliard
14 Apr '21
14 Apr '21
Module: wine Branch: master Commit: 62cb6ace2cfe46358e6526868145a5bd8a7f990b URL:
https://source.winehq.org/git/wine.git/?a=commit;h=62cb6ace2cfe46358e652686…
Author: Georg Lehmann <dadschoorse(a)gmail.com> Date: Wed Apr 14 00:31:25 2021 +0200 winevulkan: Fix queue creation with mixed queue flags. The Vulkan spec says: The queueFamilyIndex member of each element of pQueueCreateInfos must be unique within pQueueCreateInfos, except that two members can share the same queueFamilyIndex if one is a protected-capable queue and one is not a protected-capable queue. Signed-off-by: Georg Lehmann <dadschoorse(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winevulkan/vulkan.c | 84 +++++++++++++++++++++++----------------- dlls/winevulkan/vulkan_private.h | 6 ++- 2 files changed, 52 insertions(+), 38 deletions(-) diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index b186e425edb..9c322d75c76 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -310,25 +310,21 @@ static void wine_vk_free_command_buffers(struct VkDevice_T *device, } } -static struct VkQueue_T *wine_vk_device_alloc_queues(struct VkDevice_T *device, - uint32_t family_index, uint32_t queue_count, VkDeviceQueueCreateFlags flags) +static void wine_vk_device_get_queues(struct VkDevice_T *device, + uint32_t family_index, uint32_t queue_count, VkDeviceQueueCreateFlags flags, + struct VkQueue_T* queues) { VkDeviceQueueInfo2 queue_info; - struct VkQueue_T *queues; unsigned int i; - if (!(queues = calloc(queue_count, sizeof(*queues)))) - { - ERR("Failed to allocate memory for queues\n"); - return NULL; - } - for (i = 0; i < queue_count; i++) { struct VkQueue_T *queue = &queues[i]; queue->base.loader_magic = VULKAN_ICD_MAGIC_VALUE; queue->device = device; + queue->family_index = family_index; + queue->queue_index = i; queue->flags = flags; /* The Vulkan spec says: @@ -352,8 +348,6 @@ static struct VkQueue_T *wine_vk_device_alloc_queues(struct VkDevice_T *device, WINE_VK_ADD_DISPATCHABLE_MAPPING(device->phys_dev->instance, queue, queue->queue); } - - return queues; } static void wine_vk_device_free_create_info(VkDeviceCreateInfo *create_info) @@ -425,17 +419,19 @@ static VkResult wine_vk_device_convert_create_info(const VkDeviceCreateInfo *src */ static void wine_vk_device_free(struct VkDevice_T *device) { + struct VkQueue_T *queue; + if (!device) return; if (device->queues) { unsigned int i; - for (i = 0; i < device->max_queue_families; i++) + for (i = 0; i < device->queue_count; i++) { - if (device->queues[i] && device->queues[i]->queue) - WINE_VK_REMOVE_HANDLE_MAPPING(device->phys_dev->instance, device->queues[i]); - free(device->queues[i]); + queue = &device->queues[i]; + if (queue && queue->queue) + WINE_VK_REMOVE_HANDLE_MAPPING(device->phys_dev->instance, queue); } free(device->queues); device->queues = NULL; @@ -736,7 +732,7 @@ VkResult WINAPI wine_vkCreateDevice(VkPhysicalDevice phys_dev, const VkAllocationCallbacks *allocator, VkDevice *device) { VkDeviceCreateInfo create_info_host; - uint32_t max_queue_families; + struct VkQueue_T *next_queue; struct VkDevice_T *object; unsigned int i; VkResult res; @@ -791,17 +787,18 @@ VkResult WINAPI wine_vkCreateDevice(VkPhysicalDevice phys_dev, /* We need to cache all queues within the device as each requires wrapping since queues are * dispatchable objects. */ - phys_dev->instance->funcs.p_vkGetPhysicalDeviceQueueFamilyProperties(phys_dev->phys_dev, - &max_queue_families, NULL); - object->max_queue_families = max_queue_families; - TRACE("Max queue families: %u.\n", object->max_queue_families); + for (i = 0; i < create_info_host.queueCreateInfoCount; i++) + { + object->queue_count += create_info_host.pQueueCreateInfos[i].queueCount; + } - if (!(object->queues = calloc(max_queue_families, sizeof(*object->queues)))) + if (!(object->queues = calloc(object->queue_count, sizeof(*object->queues)))) { res = VK_ERROR_OUT_OF_HOST_MEMORY; goto fail; } + next_queue = object->queues; for (i = 0; i < create_info_host.queueCreateInfoCount; i++) { uint32_t flags = create_info_host.pQueueCreateInfos[i].flags; @@ -810,12 +807,8 @@ VkResult WINAPI wine_vkCreateDevice(VkPhysicalDevice phys_dev, TRACE("Queue family index %u, queue count %u.\n", family_index, queue_count); - if (!(object->queues[family_index] = wine_vk_device_alloc_queues(object, family_index, queue_count, flags))) - { - ERR("Failed to allocate memory for queues.\n"); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto fail; - } + wine_vk_device_get_queues(object, family_index, queue_count, flags, next_queue); + next_queue += queue_count; } object->quirks = phys_dev->instance->quirks; @@ -1071,17 +1064,42 @@ void WINAPI wine_vkFreeCommandBuffers(VkDevice device, VkCommandPool pool_handle wine_vk_free_command_buffers(device, pool, count, buffers); } +static VkQueue wine_vk_device_find_queue(VkDevice device, const VkDeviceQueueInfo2 *info) +{ + struct VkQueue_T* queue; + uint32_t i; + + for (i = 0; i < device->queue_count; i++) + { + queue = &device->queues[i]; + if (queue->family_index == info->queueFamilyIndex + && queue->queue_index == info->queueIndex + && queue->flags == info->flags) + { + return queue; + } + } + + return VK_NULL_HANDLE; +} + void WINAPI wine_vkGetDeviceQueue(VkDevice device, uint32_t family_index, uint32_t queue_index, VkQueue *queue) { + VkDeviceQueueInfo2 queue_info; TRACE("%p, %u, %u, %p\n", device, family_index, queue_index, queue); - *queue = &device->queues[family_index][queue_index]; + queue_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2; + queue_info.pNext = NULL; + queue_info.flags = 0; + queue_info.queueFamilyIndex = family_index; + queue_info.queueIndex = queue_index; + + *queue = wine_vk_device_find_queue(device, &queue_info); } void WINAPI wine_vkGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *info, VkQueue *queue) { - struct VkQueue_T *matching_queue; const VkBaseInStructure *chain; TRACE("%p, %p, %p\n", device, info, queue); @@ -1089,13 +1107,7 @@ void WINAPI wine_vkGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *in if ((chain = info->pNext)) FIXME("Ignoring a linked structure of type %u.\n", chain->sType); - matching_queue = &device->queues[info->queueFamilyIndex][info->queueIndex]; - if (matching_queue->flags != info->flags) - { - WARN("No matching flags were specified %#x, %#x.\n", matching_queue->flags, info->flags); - matching_queue = VK_NULL_HANDLE; - } - *queue = matching_queue; + *queue = wine_vk_device_find_queue(device, info); } VkResult WINAPI wine_vkQueueSubmit(VkQueue queue, uint32_t count, diff --git a/dlls/winevulkan/vulkan_private.h b/dlls/winevulkan/vulkan_private.h index 1a44edb3c26..3f710a16a7b 100644 --- a/dlls/winevulkan/vulkan_private.h +++ b/dlls/winevulkan/vulkan_private.h @@ -89,8 +89,8 @@ struct VkDevice_T struct VkPhysicalDevice_T *phys_dev; /* parent */ VkDevice device; /* native device */ - struct VkQueue_T **queues; - uint32_t max_queue_families; + struct VkQueue_T* queues; + uint32_t queue_count; unsigned int quirks; @@ -155,6 +155,8 @@ struct VkQueue_T struct VkDevice_T *device; /* parent */ VkQueue queue; /* native queue */ + uint32_t family_index; + uint32_t queue_index; VkDeviceQueueCreateFlags flags; struct wine_vk_mapping mapping;
1
0
0
0
Jacek Caban : winevulkan: Move wine_vk_init to loader.c.
by Alexandre Julliard
14 Apr '21
14 Apr '21
Module: wine Branch: master Commit: cc3c23c312f55a01316575474515234bfb5f9a69 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=cc3c23c312f55a0131657547…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Apr 14 17:58:45 2021 +0200 winevulkan: Move wine_vk_init to loader.c. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winevulkan/loader.c | 67 ++++++++++++++++++++++++++++++++++++++++ dlls/winevulkan/vulkan.c | 53 ++++--------------------------- dlls/winevulkan/vulkan_private.h | 8 +++++ 3 files changed, 81 insertions(+), 47 deletions(-) diff --git a/dlls/winevulkan/loader.c b/dlls/winevulkan/loader.c index 0966e2d9468..746a25041d0 100644 --- a/dlls/winevulkan/loader.c +++ b/dlls/winevulkan/loader.c @@ -206,6 +206,73 @@ VkResult WINAPI wine_vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *supporte return VK_SUCCESS; } +static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context) +{ + const struct vulkan_funcs *driver; + HDC hdc; + + hdc = GetDC(0); + driver = __wine_get_vulkan_driver(hdc, WINE_VULKAN_DRIVER_VERSION); + ReleaseDC(0, hdc); + if (!driver) + ERR("Failed to load Wine graphics driver supporting Vulkan.\n"); + else + unix_vk_init(driver); + + return driver != NULL; +} + +static BOOL wine_vk_init_once(void) +{ + static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT; + + return InitOnceExecuteOnce(&init_once, wine_vk_init, NULL, NULL); +} + +VkResult WINAPI wine_vkCreateInstance(const VkInstanceCreateInfo *create_info, + const VkAllocationCallbacks *allocator, VkInstance *instance) +{ + TRACE("create_info %p, allocator %p, instance %p\n", create_info, allocator, instance); + + if(!wine_vk_init_once()) + return VK_ERROR_INITIALIZATION_FAILED; + + return unix_vkCreateInstance(create_info, allocator, instance); +} + +VkResult WINAPI wine_vkEnumerateInstanceExtensionProperties(const char *layer_name, + uint32_t *count, VkExtensionProperties *properties) +{ + TRACE("%p, %p, %p\n", layer_name, count, properties); + + if (layer_name) + { + WARN("Layer enumeration not supported from ICD.\n"); + return VK_ERROR_LAYER_NOT_PRESENT; + } + + if (!wine_vk_init_once()) + { + *count = 0; + return VK_SUCCESS; + } + + return unix_vkEnumerateInstanceExtensionProperties(layer_name, count, properties); +} + +VkResult WINAPI wine_vkEnumerateInstanceVersion(uint32_t *version) +{ + TRACE("%p\n", version); + + if (!wine_vk_init_once()) + { + *version = VK_API_VERSION_1_0; + return VK_SUCCESS; + } + + return unix_vkEnumerateInstanceVersion(version); +} + static HANDLE get_display_device_init_mutex(void) { static const WCHAR init_mutexW[] = {'d','i','s','p','l','a','y','_','d','e','v','i','c','e','_','i','n','i','t',0}; diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index fbcbe4721a3..b186e425edb 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -450,26 +450,10 @@ static void wine_vk_device_free(struct VkDevice_T *device) free(device); } -static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context) +void unix_vk_init(const struct vulkan_funcs *driver) { - HDC hdc; - - hdc = GetDC(0); - vk_funcs = __wine_get_vulkan_driver(hdc, WINE_VULKAN_DRIVER_VERSION); - ReleaseDC(0, hdc); - if (!vk_funcs) - ERR("Failed to load Wine graphics driver supporting Vulkan.\n"); - else - p_vkEnumerateInstanceVersion = vk_funcs->p_vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion"); - - return TRUE; -} - -static void wine_vk_init_once(void) -{ - static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT; - - InitOnceExecuteOnce(&init_once, wine_vk_init, NULL, NULL); + vk_funcs = driver; + p_vkEnumerateInstanceVersion = vk_funcs->p_vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion"); } /* Helper function for converting between win32 and host compatible VkInstanceCreateInfo. @@ -845,7 +829,7 @@ fail: return res; } -VkResult WINAPI wine_vkCreateInstance(const VkInstanceCreateInfo *create_info, +VkResult WINAPI unix_vkCreateInstance(const VkInstanceCreateInfo *create_info, const VkAllocationCallbacks *allocator, VkInstance *instance) { VkInstanceCreateInfo create_info_host; @@ -853,12 +837,6 @@ VkResult WINAPI wine_vkCreateInstance(const VkInstanceCreateInfo *create_info, struct VkInstance_T *object; VkResult res; - TRACE("create_info %p, allocator %p, instance %p\n", create_info, allocator, instance); - - wine_vk_init_once(); - if (!vk_funcs) - return VK_ERROR_INITIALIZATION_FAILED; - if (allocator) FIXME("Support for allocation callbacks not implemented yet\n"); @@ -975,7 +953,7 @@ VkResult WINAPI wine_vkEnumerateDeviceExtensionProperties(VkPhysicalDevice phys_ return *count < phys_dev->extension_count ? VK_INCOMPLETE : VK_SUCCESS; } -VkResult WINAPI wine_vkEnumerateInstanceExtensionProperties(const char *layer_name, +VkResult WINAPI unix_vkEnumerateInstanceExtensionProperties(const char *layer_name, uint32_t *count, VkExtensionProperties *properties) { uint32_t num_properties = 0, num_host_properties; @@ -983,21 +961,6 @@ VkResult WINAPI wine_vkEnumerateInstanceExtensionProperties(const char *layer_na unsigned int i, j; VkResult res; - TRACE("%p, %p, %p\n", layer_name, count, properties); - - if (layer_name) - { - WARN("Layer enumeration not supported from ICD.\n"); - return VK_ERROR_LAYER_NOT_PRESENT; - } - - wine_vk_init_once(); - if (!vk_funcs) - { - *count = 0; - return VK_SUCCESS; - } - res = vk_funcs->p_vkEnumerateInstanceExtensionProperties(NULL, &num_host_properties, NULL); if (res != VK_SUCCESS) return res; @@ -1055,14 +1018,10 @@ VkResult WINAPI wine_vkEnumerateDeviceLayerProperties(VkPhysicalDevice phys_dev, return VK_SUCCESS; } -VkResult WINAPI wine_vkEnumerateInstanceVersion(uint32_t *version) +VkResult WINAPI unix_vkEnumerateInstanceVersion(uint32_t *version) { VkResult res; - TRACE("%p\n", version); - - wine_vk_init_once(); - if (p_vkEnumerateInstanceVersion) { res = p_vkEnumerateInstanceVersion(version); diff --git a/dlls/winevulkan/vulkan_private.h b/dlls/winevulkan/vulkan_private.h index 6574d282eea..1a44edb3c26 100644 --- a/dlls/winevulkan/vulkan_private.h +++ b/dlls/winevulkan/vulkan_private.h @@ -243,4 +243,12 @@ BOOL wine_vk_instance_extension_supported(const char *name) DECLSPEC_HIDDEN; BOOL wine_vk_is_type_wrapped(VkObjectType type) DECLSPEC_HIDDEN; uint64_t wine_vk_unwrap_handle(VkObjectType type, uint64_t handle) DECLSPEC_HIDDEN; +void unix_vk_init(const struct vulkan_funcs *driver) DECLSPEC_HIDDEN; + +VkResult WINAPI unix_vkCreateInstance(const VkInstanceCreateInfo *create_info, + const VkAllocationCallbacks *allocator, VkInstance *instance) DECLSPEC_HIDDEN; +VkResult WINAPI unix_vkEnumerateInstanceExtensionProperties(const char *layer_name, + uint32_t *count, VkExtensionProperties *properties) DECLSPEC_HIDDEN; +VkResult WINAPI unix_vkEnumerateInstanceVersion(uint32_t *version) DECLSPEC_HIDDEN; + #endif /* __WINE_VULKAN_PRIVATE_H */
1
0
0
0
← Newer
1
...
47
48
49
50
51
52
53
...
87
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Results per page:
10
25
50
100
200