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 2020
----- 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
1016 discussions
Start a n
N
ew thread
Zebediah Figura : wineusb.sys: Implement device and instance IDs.
by Alexandre Julliard
17 Apr '20
17 Apr '20
Module: wine Branch: master Commit: a66d44b96e81750d33bb1e36cb30239d65e83e0e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a66d44b96e81750d33bb1e36…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Thu Apr 16 19:58:15 2020 -0500 wineusb.sys: Implement device and instance IDs. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wineusb.sys/wineusb.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/dlls/wineusb.sys/wineusb.c b/dlls/wineusb.sys/wineusb.c index b60d496e9e..918c7a584b 100644 --- a/dlls/wineusb.sys/wineusb.c +++ b/dlls/wineusb.sys/wineusb.c @@ -278,15 +278,58 @@ static NTSTATUS fdo_pnp(IRP *irp) return IoCallDriver(bus_pdo, irp); } +static void get_device_id(const struct usb_device *device, WCHAR *buffer) +{ + static const WCHAR formatW[] = {'U','S','B','\\','V','I','D','_','%','0','4','X', + '&','P','I','D','_','%','0','4','X',0}; + struct libusb_device_descriptor desc; + + libusb_get_device_descriptor(device->libusb_device, &desc); + sprintfW(buffer, formatW, desc.idVendor, desc.idProduct); +} + +static NTSTATUS query_id(const struct usb_device *device, IRP *irp, BUS_QUERY_ID_TYPE type) +{ + WCHAR *id = NULL; + + switch (type) + { + case BusQueryDeviceID: + if ((id = ExAllocatePool(PagedPool, 28 * sizeof(WCHAR)))) + get_device_id(device, id); + break; + + case BusQueryInstanceID: + if ((id = ExAllocatePool(PagedPool, 2 * sizeof(WCHAR)))) + { + id[0] = '0'; + id[1] = 0; + } + break; + + default: + FIXME("Unhandled ID query type %#x.\n", type); + return irp->IoStatus.Status; + } + + irp->IoStatus.Information = (ULONG_PTR)id; + return STATUS_SUCCESS; +} + static NTSTATUS pdo_pnp(DEVICE_OBJECT *device_obj, IRP *irp) { IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp); + struct usb_device *device = device_obj->DeviceExtension; NTSTATUS ret = irp->IoStatus.Status; TRACE("device_obj %p, irp %p, minor function %#x.\n", device_obj, irp, stack->MinorFunction); switch (stack->MinorFunction) { + case IRP_MN_QUERY_ID: + ret = query_id(device, irp, stack->Parameters.QueryId.IdType); + break; + case IRP_MN_START_DEVICE: case IRP_MN_QUERY_CAPABILITIES: ret = STATUS_SUCCESS;
1
0
0
0
Michael Stefaniuc : d3d10: Remove superfluous TRUE : FALSE conditional expression.
by Alexandre Julliard
17 Apr '20
17 Apr '20
Module: wine Branch: master Commit: 4ffc5e66ea31e8b831513bc8e462c876cdfdcb38 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=4ffc5e66ea31e8b831513bc8…
Author: Michael Stefaniuc <mstefani(a)winehq.org> Date: Thu Apr 16 00:08:29 2020 +0200 d3d10: Remove superfluous TRUE : FALSE conditional expression. Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/d3d10/effect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 04376efe9c..86ef50aac0 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -5337,7 +5337,7 @@ static void write_matrix_to_buffer(struct d3d10_effect_variable *variable, void { unsigned int col_count = !transpose ? variable->type->column_count : variable->type->row_count; unsigned int row_count = !transpose ? variable->type->row_count : variable->type->column_count; - BOOL major = variable->type->type_class == D3D10_SVC_MATRIX_COLUMNS ? TRUE : FALSE; + BOOL major = variable->type->type_class == D3D10_SVC_MATRIX_COLUMNS; float *dst = dst_void; unsigned int row, col; @@ -5415,7 +5415,7 @@ static void read_matrix_from_buffer(struct d3d10_effect_variable *variable, void { unsigned int col_count = !transpose ? variable->type->column_count : variable->type->row_count; unsigned int row_count = !transpose ? variable->type->row_count : variable->type->column_count; - BOOL major = variable->type->type_class == D3D10_SVC_MATRIX_COLUMNS ? TRUE : FALSE; + BOOL major = variable->type->type_class == D3D10_SVC_MATRIX_COLUMNS; float *src = src_void; unsigned int row, col;
1
0
0
0
Zebediah Figura : d3dcompiler: Avoid using the lookahead token for location.
by Alexandre Julliard
17 Apr '20
17 Apr '20
Module: wine Branch: master Commit: 53e6b328f68901ed2fc141bbd7146d055796442e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=53e6b328f68901ed2fc141bb…
Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Tue Apr 14 19:39:56 2020 -0500 d3dcompiler: Avoid using the lookahead token for location. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/d3dcompiler_43/hlsl.y | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index d3ef18bb6e..ccabd6d29f 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -2035,7 +2035,7 @@ primary_expr: C_FLOAT YYABORT; } c->node.type = HLSL_IR_CONSTANT; - c->node.loc = get_location(&yylloc); + c->node.loc = get_location(&@1); c->node.data_type = new_hlsl_type(d3dcompiler_strdup("float"), HLSL_CLASS_SCALAR, HLSL_TYPE_FLOAT, 1, 1); c->v.value.f[0] = $1; if (!($$ = make_list(&c->node))) @@ -2050,7 +2050,7 @@ primary_expr: C_FLOAT YYABORT; } c->node.type = HLSL_IR_CONSTANT; - c->node.loc = get_location(&yylloc); + c->node.loc = get_location(&@1); c->node.data_type = new_hlsl_type(d3dcompiler_strdup("int"), HLSL_CLASS_SCALAR, HLSL_TYPE_INT, 1, 1); c->v.value.i[0] = $1; if (!($$ = make_list(&c->node))) @@ -2065,7 +2065,7 @@ primary_expr: C_FLOAT YYABORT; } c->node.type = HLSL_IR_CONSTANT; - c->node.loc = get_location(&yylloc); + c->node.loc = get_location(&@1); c->node.data_type = new_hlsl_type(d3dcompiler_strdup("bool"), HLSL_CLASS_SCALAR, HLSL_TYPE_BOOL, 1, 1); c->v.value.b[0] = $1; if (!($$ = make_list(&c->node)))
1
0
0
0
Zebediah Figura : d3dcompiler: Make printed IR a bit more readable.
by Alexandre Julliard
17 Apr '20
17 Apr '20
Module: wine Branch: master Commit: 2573e698ffd95db98cfcf3220739be63c505c391 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=2573e698ffd95db98cfcf322…
Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Tue Apr 14 19:39:54 2020 -0500 d3dcompiler: Make printed IR a bit more readable. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/d3dcompiler_43/utils.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c index 0c8b918d13..d24341329d 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -1904,7 +1904,10 @@ static void debug_dump_instr_list(const struct list *list) static void debug_dump_src(const struct hlsl_ir_node *node) { - wine_dbg_printf("%p", node); + if (node->index) + wine_dbg_printf("@%u", node->index); + else + wine_dbg_printf("%p", node); } static void debug_dump_ir_var(const struct hlsl_ir_var *var) @@ -2178,7 +2181,10 @@ static void debug_dump_ir_loop(const struct hlsl_ir_loop *loop) static void debug_dump_instr(const struct hlsl_ir_node *instr) { - wine_dbg_printf("%4u: %p: ", instr->index, instr); + if (instr->index) + wine_dbg_printf("%4u: ", instr->index); + else + wine_dbg_printf("%p: ", instr); switch (instr->type) { case HLSL_IR_EXPR:
1
0
0
0
Brendan Shanks : winedbg: Use RtlGetVersion to fix displayed Windows version on Win8.1 or 10 prefix.
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: c18152630362c1bff1813fe8ad5c75ffb8dbb7cf URL:
https://source.winehq.org/git/wine.git/?a=commit;h=c18152630362c1bff1813fe8…
Author: Brendan Shanks <bshanks(a)codeweavers.com> Date: Thu Apr 16 11:13:27 2020 -0700 winedbg: Use RtlGetVersion to fix displayed Windows version on Win8.1 or 10 prefix. Signed-off-by: Brendan Shanks <bshanks(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/winedbg/tgt_active.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index 2b38ce95de..91dea2f9d8 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -728,11 +728,11 @@ version_table[] = static const char *get_windows_version(void) { - OSVERSIONINFOEXW info = { sizeof(OSVERSIONINFOEXW) }; + RTL_OSVERSIONINFOEXW info = { sizeof(RTL_OSVERSIONINFOEXW) }; static char str[64]; int i; - GetVersionExW( (OSVERSIONINFOW *)&info ); + RtlGetVersion( &info ); for (i = 0; i < ARRAY_SIZE(version_table); i++) {
1
0
0
0
Brendan Shanks : cmd: Use RtlGetVersion to fix displayed Windows version on Win8.1 or 10 prefix.
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: e8f16fcbcc6a168e8f1e526beb3e07d0beeea3d0 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e8f16fcbcc6a168e8f1e526b…
Author: Brendan Shanks <bshanks(a)codeweavers.com> Date: Thu Apr 16 11:12:58 2020 -0700 cmd: Use RtlGetVersion to fix displayed Windows version on Win8.1 or 10 prefix. Signed-off-by: Brendan Shanks <bshanks(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/cmd/wcmd.h | 1 + programs/cmd/wcmdmain.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h index b0769bd839..112fc1a1ea 100644 --- a/programs/cmd/wcmd.h +++ b/programs/cmd/wcmd.h @@ -22,6 +22,7 @@ #define IDI_ICON1 1 #include <windows.h> #include <windef.h> +#include <winternl.h> #ifndef RC_INVOKED #include <string.h> #include <stdlib.h> diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 5cad22b7ee..2834986bf9 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -2437,7 +2437,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[]) static const WCHAR cmdW[] = {'\\','c','m','d','.','e','x','e',0}; WCHAR comspec[MAX_PATH]; CMD_LIST *toExecute = NULL; /* Commands left to be executed */ - OSVERSIONINFOW osv; + RTL_OSVERSIONINFOEXW osv; char osver[50]; STARTUPINFOW startupInfo; @@ -2452,7 +2452,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[]) /* Get the windows version being emulated */ osv.dwOSVersionInfoSize = sizeof(osv); - GetVersionExW(&osv); + RtlGetVersion(&osv); /* Pre initialize some messages */ lstrcpyW(anykey, WCMD_LoadMessage(WCMD_ANYKEY));
1
0
0
0
Zebediah Figura : wineusb.sys: Implement IRP_MN_QUERY_DEVICE_RELATIONS.
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: 5b47a2db6c8496e05cd7ee9c39eb818fcd54b8b7 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=5b47a2db6c8496e05cd7ee9c…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Wed Apr 15 09:43:23 2020 -0500 wineusb.sys: Implement IRP_MN_QUERY_DEVICE_RELATIONS. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wineusb.sys/wineusb.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/dlls/wineusb.sys/wineusb.c b/dlls/wineusb.sys/wineusb.c index 22804d8657..b60d496e9e 100644 --- a/dlls/wineusb.sys/wineusb.c +++ b/dlls/wineusb.sys/wineusb.c @@ -38,6 +38,23 @@ WINE_DEFAULT_DEBUG_CHANNEL(wineusb); +#if defined(__i386__) && !defined(_WIN32) + +extern void * WINAPI wrap_fastcall_func1( void *func, const void *a ); +__ASM_STDCALL_FUNC( wrap_fastcall_func1, 8, + "popl %ecx\n\t" + "popl %eax\n\t" + "xchgl (%esp),%ecx\n\t" + "jmp *%eax" ); + +#define call_fastcall_func1(func,a) wrap_fastcall_func1(func,a) + +#else + +#define call_fastcall_func1(func,a) func(a) + +#endif + #define DECLARE_CRITICAL_SECTION(cs) \ static CRITICAL_SECTION cs; \ static CRITICAL_SECTION_DEBUG cs##_debug = \ @@ -172,6 +189,42 @@ static NTSTATUS fdo_pnp(IRP *irp) switch (stack->MinorFunction) { + case IRP_MN_QUERY_DEVICE_RELATIONS: + { + struct usb_device *device; + DEVICE_RELATIONS *devices; + unsigned int i = 0; + + if (stack->Parameters.QueryDeviceRelations.Type != BusRelations) + { + FIXME("Unhandled device relations type %#x.\n", stack->Parameters.QueryDeviceRelations.Type); + break; + } + + EnterCriticalSection(&wineusb_cs); + + if (!(devices = ExAllocatePool(PagedPool, + offsetof(DEVICE_RELATIONS, Objects[list_count(&device_list)])))) + { + LeaveCriticalSection(&wineusb_cs); + irp->IoStatus.Status = STATUS_NO_MEMORY; + break; + } + + LIST_FOR_EACH_ENTRY(device, &device_list, struct usb_device, entry) + { + devices->Objects[i++] = device->device_obj; + call_fastcall_func1(ObfReferenceObject, device->device_obj); + } + + LeaveCriticalSection(&wineusb_cs); + + devices->Count = i; + irp->IoStatus.Information = (ULONG_PTR)devices; + irp->IoStatus.Status = STATUS_SUCCESS; + break; + } + case IRP_MN_START_DEVICE: if ((ret = libusb_hotplug_register_callback(NULL, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT,
1
0
0
0
Zebediah Figura : wineusb.sys: Create USB devices.
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: b0c2e5c6ce0e116e33435db85c051d8feb07ecb2 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=b0c2e5c6ce0e116e33435db8…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Wed Apr 15 09:43:22 2020 -0500 wineusb.sys: Create USB devices. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wineusb.sys/wineusb.c | 160 ++++++++++++++++++++++++++++++++++++++++++++- include/ddk/usbioctl.h | 2 + 2 files changed, 161 insertions(+), 1 deletion(-) diff --git a/dlls/wineusb.sys/wineusb.c b/dlls/wineusb.sys/wineusb.c index 060fb3d0d2..22804d8657 100644 --- a/dlls/wineusb.sys/wineusb.c +++ b/dlls/wineusb.sys/wineusb.c @@ -38,11 +38,115 @@ WINE_DEFAULT_DEBUG_CHANNEL(wineusb); +#define DECLARE_CRITICAL_SECTION(cs) \ + static CRITICAL_SECTION cs; \ + static CRITICAL_SECTION_DEBUG cs##_debug = \ + { 0, 0, &cs, { &cs##_debug.ProcessLocksList, &cs##_debug.ProcessLocksList }, \ + 0, 0, { (DWORD_PTR)(__FILE__ ": " # cs) }}; \ + static CRITICAL_SECTION cs = { &cs##_debug, -1, 0, 0, 0, 0 }; + +DECLARE_CRITICAL_SECTION(wineusb_cs); + +static struct list device_list = LIST_INIT(device_list); + +struct usb_device +{ + struct list entry; + + DEVICE_OBJECT *device_obj; + + libusb_device *libusb_device; + libusb_device_handle *handle; +}; + +static DRIVER_OBJECT *driver_obj; static DEVICE_OBJECT *bus_fdo, *bus_pdo; +static libusb_hotplug_callback_handle hotplug_cb_handle; + +static void add_usb_device(libusb_device *libusb_device) +{ + static const WCHAR formatW[] = {'\\','D','e','v','i','c','e','\\','U','S','B','P','D','O','-','%','u',0}; + struct libusb_device_descriptor device_desc; + static unsigned int name_index; + libusb_device_handle *handle; + struct usb_device *device; + DEVICE_OBJECT *device_obj; + UNICODE_STRING string; + NTSTATUS status; + WCHAR name[20]; + int ret; + + libusb_get_device_descriptor(libusb_device, &device_desc); + + TRACE("Adding new device %p, vendor %04x, product %04x.\n", libusb_device, + device_desc.idVendor, device_desc.idProduct); + + if ((ret = libusb_open(libusb_device, &handle))) + { + WARN("Failed to open device: %s\n", libusb_strerror(ret)); + return; + } + + sprintfW(name, formatW, name_index++); + RtlInitUnicodeString(&string, name); + if ((status = IoCreateDevice(driver_obj, sizeof(*device), &string, + FILE_DEVICE_USB, 0, FALSE, &device_obj))) + { + ERR("Failed to create device, status %#x.\n", status); + LeaveCriticalSection(&wineusb_cs); + libusb_close(handle); + return; + } + + device = device_obj->DeviceExtension; + device->device_obj = device_obj; + device->libusb_device = libusb_ref_device(libusb_device); + device->handle = handle; + + EnterCriticalSection(&wineusb_cs); + list_add_tail(&device_list, &device->entry); + LeaveCriticalSection(&wineusb_cs); + + IoInvalidateDeviceRelations(bus_pdo, BusRelations); +} + +static void remove_usb_device(libusb_device *libusb_device) +{ + struct usb_device *device; + + TRACE("Removing device %p.\n", libusb_device); + + EnterCriticalSection(&wineusb_cs); + LIST_FOR_EACH_ENTRY(device, &device_list, struct usb_device, entry) + { + if (device->libusb_device == libusb_device) + { + libusb_unref_device(device->libusb_device); + libusb_close(device->handle); + list_remove(&device->entry); + IoInvalidateDeviceRelations(bus_pdo, BusRelations); + IoDeleteDevice(device->device_obj); + break; + } + } + LeaveCriticalSection(&wineusb_cs); +} + static BOOL thread_shutdown; static HANDLE event_thread; +static int LIBUSB_CALL hotplug_cb(libusb_context *context, libusb_device *device, + libusb_hotplug_event event, void *user_data) +{ + if (event == LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED) + add_usb_device(device); + else + remove_usb_device(device); + + return 0; +} + static DWORD CALLBACK event_thread_proc(void *arg) { int ret; @@ -69,22 +173,49 @@ static NTSTATUS fdo_pnp(IRP *irp) switch (stack->MinorFunction) { case IRP_MN_START_DEVICE: + if ((ret = libusb_hotplug_register_callback(NULL, + LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT, + LIBUSB_HOTPLUG_ENUMERATE, LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY, + LIBUSB_HOTPLUG_MATCH_ANY, hotplug_cb, NULL, &hotplug_cb_handle))) + { + ERR("Failed to register callback: %s\n", libusb_strerror(ret)); + irp->IoStatus.Status = STATUS_UNSUCCESSFUL; + break; + } + irp->IoStatus.Status = STATUS_SUCCESS; + break; + case IRP_MN_SURPRISE_REMOVAL: irp->IoStatus.Status = STATUS_SUCCESS; break; case IRP_MN_REMOVE_DEVICE: + { + struct usb_device *device, *cursor; + + libusb_hotplug_deregister_callback(NULL, hotplug_cb_handle); thread_shutdown = TRUE; libusb_interrupt_event_handler(NULL); WaitForSingleObject(event_thread, INFINITE); CloseHandle(event_thread); + EnterCriticalSection(&wineusb_cs); + LIST_FOR_EACH_ENTRY_SAFE(device, cursor, &device_list, struct usb_device, entry) + { + libusb_unref_device(device->libusb_device); + libusb_close(device->handle); + list_remove(&device->entry); + IoDeleteDevice(device->device_obj); + } + LeaveCriticalSection(&wineusb_cs); + irp->IoStatus.Status = STATUS_SUCCESS; IoSkipCurrentIrpStackLocation(irp); ret = IoCallDriver(bus_pdo, irp); IoDetachDevice(bus_pdo); IoDeleteDevice(bus_fdo); return ret; + } default: FIXME("Unhandled minor function %#x.\n", stack->MinorFunction); @@ -94,9 +225,34 @@ static NTSTATUS fdo_pnp(IRP *irp) return IoCallDriver(bus_pdo, irp); } +static NTSTATUS pdo_pnp(DEVICE_OBJECT *device_obj, IRP *irp) +{ + IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp); + NTSTATUS ret = irp->IoStatus.Status; + + TRACE("device_obj %p, irp %p, minor function %#x.\n", device_obj, irp, stack->MinorFunction); + + switch (stack->MinorFunction) + { + case IRP_MN_START_DEVICE: + case IRP_MN_QUERY_CAPABILITIES: + ret = STATUS_SUCCESS; + break; + + default: + FIXME("Unhandled minor function %#x.\n", stack->MinorFunction); + } + + irp->IoStatus.Status = ret; + IoCompleteRequest(irp, IO_NO_INCREMENT); + return ret; +} + static NTSTATUS WINAPI driver_pnp(DEVICE_OBJECT *device, IRP *irp) { - return fdo_pnp(irp); + if (device == bus_fdo) + return fdo_pnp(irp); + return pdo_pnp(device, irp); } static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *pdo) @@ -129,6 +285,8 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *path) TRACE("driver %p, path %s.\n", driver, debugstr_w(path->Buffer)); + driver_obj = driver; + if ((err = libusb_init(NULL))) { ERR("Failed to initialize libusb: %s\n", libusb_strerror(err)); diff --git a/include/ddk/usbioctl.h b/include/ddk/usbioctl.h index 003e2b6786..0438dce8bf 100644 --- a/include/ddk/usbioctl.h +++ b/include/ddk/usbioctl.h @@ -19,6 +19,8 @@ #ifndef __DDK_USBIOCTL_H__ #define __DDK_USBIOCTL_H__ +#include "ddk/usbiodef.h" + #define IOCTL_INTERNAL_USB_SUBMIT_URB \ CTL_CODE(FILE_DEVICE_USB, USB_SUBMIT_URB, METHOD_NEITHER, FILE_ANY_ACCESS)
1
0
0
0
Zebediah Figura : wineusb.sys: Start an event handler thread.
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: eb8cb9e0cfae1d43ebccc72ded6179b60012e188 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=eb8cb9e0cfae1d43ebccc72d…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Wed Apr 15 09:43:21 2020 -0500 wineusb.sys: Start an event handler thread. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wineusb.sys/wineusb.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/dlls/wineusb.sys/wineusb.c b/dlls/wineusb.sys/wineusb.c index 14795f4ec4..060fb3d0d2 100644 --- a/dlls/wineusb.sys/wineusb.c +++ b/dlls/wineusb.sys/wineusb.c @@ -40,6 +40,25 @@ WINE_DEFAULT_DEBUG_CHANNEL(wineusb); static DEVICE_OBJECT *bus_fdo, *bus_pdo; +static BOOL thread_shutdown; +static HANDLE event_thread; + +static DWORD CALLBACK event_thread_proc(void *arg) +{ + int ret; + + TRACE("Starting event thread.\n"); + + while (!thread_shutdown) + { + if ((ret = libusb_handle_events(NULL))) + ERR("Error handling events: %s\n", libusb_strerror(ret)); + } + + TRACE("Shutting down event thread.\n"); + return 0; +} + static NTSTATUS fdo_pnp(IRP *irp) { IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp); @@ -55,6 +74,11 @@ static NTSTATUS fdo_pnp(IRP *irp) break; case IRP_MN_REMOVE_DEVICE: + thread_shutdown = TRUE; + libusb_interrupt_event_handler(NULL); + WaitForSingleObject(event_thread, INFINITE); + CloseHandle(event_thread); + irp->IoStatus.Status = STATUS_SUCCESS; IoSkipCurrentIrpStackLocation(irp); ret = IoCallDriver(bus_pdo, irp); @@ -111,6 +135,8 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *path) return STATUS_UNSUCCESSFUL; } + event_thread = CreateThread(NULL, 0, event_thread_proc, NULL, 0, NULL); + driver->DriverExtension->AddDevice = driver_add_device; driver->DriverUnload = driver_unload; driver->MajorFunction[IRP_MJ_PNP] = driver_pnp;
1
0
0
0
Zebediah Figura : wineusb.sys: Implement basic IRP_MJ_PNP requests for the bus FDO.
by Alexandre Julliard
16 Apr '20
16 Apr '20
Module: wine Branch: master Commit: ff9645b21571c0da184844594ec19192bcdaa4dd URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ff9645b21571c0da18484459…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Wed Apr 15 09:43:20 2020 -0500 wineusb.sys: Implement basic IRP_MJ_PNP requests for the bus FDO. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wineusb.sys/wineusb.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/dlls/wineusb.sys/wineusb.c b/dlls/wineusb.sys/wineusb.c index 6af8a9aaa5..14795f4ec4 100644 --- a/dlls/wineusb.sys/wineusb.c +++ b/dlls/wineusb.sys/wineusb.c @@ -40,6 +40,41 @@ WINE_DEFAULT_DEBUG_CHANNEL(wineusb); static DEVICE_OBJECT *bus_fdo, *bus_pdo; +static NTSTATUS fdo_pnp(IRP *irp) +{ + IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp); + NTSTATUS ret; + + TRACE("irp %p, minor function %#x.\n", irp, stack->MinorFunction); + + switch (stack->MinorFunction) + { + case IRP_MN_START_DEVICE: + case IRP_MN_SURPRISE_REMOVAL: + irp->IoStatus.Status = STATUS_SUCCESS; + break; + + case IRP_MN_REMOVE_DEVICE: + irp->IoStatus.Status = STATUS_SUCCESS; + IoSkipCurrentIrpStackLocation(irp); + ret = IoCallDriver(bus_pdo, irp); + IoDetachDevice(bus_pdo); + IoDeleteDevice(bus_fdo); + return ret; + + default: + FIXME("Unhandled minor function %#x.\n", stack->MinorFunction); + } + + IoSkipCurrentIrpStackLocation(irp); + return IoCallDriver(bus_pdo, irp); +} + +static NTSTATUS WINAPI driver_pnp(DEVICE_OBJECT *device, IRP *irp) +{ + return fdo_pnp(irp); +} + static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *pdo) { NTSTATUS ret; @@ -78,6 +113,7 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *path) driver->DriverExtension->AddDevice = driver_add_device; driver->DriverUnload = driver_unload; + driver->MajorFunction[IRP_MJ_PNP] = driver_pnp; return STATUS_SUCCESS; }
1
0
0
0
← Newer
1
...
52
53
54
55
56
57
58
...
102
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
Results per page:
10
25
50
100
200