Commit e61498c0 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wineusb.sys: Move the libusb_cancel_transfer() call to a new Unix library.

parent 9513f8a1
EXTRADEFS = -DWINE_NO_LONG_TYPES
MODULE = wineusb.sys
UNIXLIB = wineusb.so
IMPORTS = ntoskrnl
UNIX_LIBS = $(USB_LIBS)
UNIX_CFLAGS = $(USB_CFLAGS)
......@@ -7,6 +8,7 @@ UNIX_CFLAGS = $(USB_CFLAGS)
EXTRADLLFLAGS = -Wl,--subsystem,native -mcygwin
C_SRCS = \
unixlib.c \
wineusb.c
RC_SRCS = wineusb.rc
/*
* libusb backend
*
* Copyright 2020 Zebediah Figura
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include <libusb.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "wine/debug.h"
#include "wine/list.h"
#include "unixlib.h"
WINE_DEFAULT_DEBUG_CHANNEL(wineusb);
static NTSTATUS usb_cancel_transfer(void *args)
{
const struct usb_cancel_transfer_params *params = args;
int ret;
if ((ret = libusb_cancel_transfer(params->transfer)) < 0)
ERR("Failed to cancel transfer: %s\n", libusb_strerror(ret));
return STATUS_SUCCESS;
}
const unixlib_entry_t __wine_unix_call_funcs[] =
{
#define X(name) [unix_ ## name] = name
X(usb_cancel_transfer),
};
/*
* wineusb Unix library interface
*
* Copyright 2022 Zebediah Figura for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_WINEUSB_UNIXLIB_H
#define __WINE_WINEUSB_UNIXLIB_H
#include "windef.h"
#include "winternl.h"
#include "wine/unixlib.h"
struct usb_cancel_transfer_params
{
void *transfer;
};
enum unix_funcs
{
unix_usb_cancel_transfer,
};
#endif
......@@ -36,6 +36,8 @@
#include "wine/list.h"
#include "wine/unicode.h"
#include "unixlib.h"
WINE_DEFAULT_DEBUG_CHANNEL(wineusb);
#ifdef __ASM_USE_FASTCALL_WRAPPER
......@@ -64,6 +66,8 @@ __ASM_STDCALL_FUNC( wrap_fastcall_func1, 8,
DECLARE_CRITICAL_SECTION(wineusb_cs);
static unixlib_handle_t unix_handle;
static struct list device_list = LIST_INIT(device_list);
struct usb_device
......@@ -712,9 +716,12 @@ static NTSTATUS usb_submit_urb(struct usb_device *device, IRP *irp)
for (entry = mark->Flink; entry != mark; entry = entry->Flink)
{
IRP *queued_irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.ListEntry);
struct usb_cancel_transfer_params params =
{
.transfer = queued_irp->Tail.Overlay.DriverContext[0],
};
if ((ret = libusb_cancel_transfer(queued_irp->Tail.Overlay.DriverContext[0])) < 0)
ERR("Failed to cancel transfer: %s\n", libusb_strerror(ret));
__wine_unix_call(unix_handle, unix_usb_cancel_transfer, &params);
}
LeaveCriticalSection(&wineusb_cs);
......@@ -930,10 +937,20 @@ static void WINAPI driver_unload(DRIVER_OBJECT *driver)
NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *path)
{
NTSTATUS status;
void *instance;
int err;
TRACE("driver %p, path %s.\n", driver, debugstr_w(path->Buffer));
RtlPcToFileHeader(DriverEntry, &instance);
if ((status = NtQueryVirtualMemory(GetCurrentProcess(), instance,
MemoryWineUnixFuncs, &unix_handle, sizeof(unix_handle), NULL)))
{
ERR("Failed to initialize Unix library, status %#x.\n", status);
return status;
}
driver_obj = driver;
if ((err = libusb_init(NULL)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment