Zebediah Figura : hidclass.sys: Merge main.c into pnp.c.

Alexandre Julliard julliard at winehq.org
Fri Apr 16 15:56:21 CDT 2021


Module: wine
Branch: master
Commit: e30a14525e3b791037c2228d018be9dc18ac0ef7
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=e30a14525e3b791037c2228d018be9dc18ac0ef7

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Thu Apr 15 21:03:58 2021 -0500

hidclass.sys: Merge main.c into pnp.c.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/hidclass.sys/Makefile.in |   1 -
 dlls/hidclass.sys/hid.h       |   5 ---
 dlls/hidclass.sys/main.c      | 102 ------------------------------------------
 dlls/hidclass.sys/pnp.c       |  79 ++++++++++++++++++++++++++++++--
 4 files changed, 76 insertions(+), 111 deletions(-)

diff --git a/dlls/hidclass.sys/Makefile.in b/dlls/hidclass.sys/Makefile.in
index be4af747853..b1b26dba70b 100644
--- a/dlls/hidclass.sys/Makefile.in
+++ b/dlls/hidclass.sys/Makefile.in
@@ -9,5 +9,4 @@ C_SRCS = \
 	buffer.c \
 	descriptor.c \
 	device.c \
-	main.c \
 	pnp.c
diff --git a/dlls/hidclass.sys/hid.h b/dlls/hidclass.sys/hid.h
index 41f3766a535..03eeff9fb92 100644
--- a/dlls/hidclass.sys/hid.h
+++ b/dlls/hidclass.sys/hid.h
@@ -86,7 +86,6 @@ typedef struct _minidriver
 } minidriver;
 
 NTSTATUS call_minidriver(ULONG code, DEVICE_OBJECT *device, void *in_buff, ULONG in_size, void *out_buff, ULONG out_size) DECLSPEC_HIDDEN;
-minidriver* find_minidriver(DRIVER_OBJECT* driver) DECLSPEC_HIDDEN;
 
 /* Internal device functions */
 NTSTATUS HID_CreateDevice(DEVICE_OBJECT *native_device, HID_MINIDRIVER_REGISTRATION *driver, DEVICE_OBJECT **device) DECLSPEC_HIDDEN;
@@ -99,10 +98,6 @@ NTSTATUS WINAPI HID_Device_read(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN
 NTSTATUS WINAPI HID_Device_write(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
 NTSTATUS WINAPI HID_Device_create(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
 NTSTATUS WINAPI HID_Device_close(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
-NTSTATUS WINAPI HID_PNP_Dispatch(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
-
-/* Pseudo-Plug and Play support*/
-NTSTATUS WINAPI PNP_AddDevice(DRIVER_OBJECT *driver, DEVICE_OBJECT* PDO) DECLSPEC_HIDDEN;
 
 /* Parsing HID Report Descriptors into preparsed data */
 WINE_HIDP_PREPARSED_DATA* ParseDescriptor(BYTE *descriptor, unsigned int length) DECLSPEC_HIDDEN;
diff --git a/dlls/hidclass.sys/main.c b/dlls/hidclass.sys/main.c
deleted file mode 100644
index 50657b80f5e..00000000000
--- a/dlls/hidclass.sys/main.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * WINE Hid device services
- *
- * Copyright 2015 Aric Stewart
- *
- * 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
- */
-
-#define NONAMELESSUNION
-#include <unistd.h>
-#include <stdarg.h>
-#include "hid.h"
-#include "wine/debug.h"
-#include "wine/list.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(hid);
-
-static struct list minidriver_list = LIST_INIT(minidriver_list);
-
-minidriver* find_minidriver(DRIVER_OBJECT *driver)
-{
-    minidriver *md;
-    LIST_FOR_EACH_ENTRY(md, &minidriver_list, minidriver, entry)
-    {
-        if (md->minidriver.DriverObject == driver)
-            return md;
-    }
-    return NULL;
-}
-
-static VOID WINAPI UnloadDriver(DRIVER_OBJECT *driver)
-{
-    minidriver *md;
-
-    TRACE("Driver Unload\n");
-    md = find_minidriver(driver);
-    if (md)
-    {
-        if (md->DriverUnload)
-            md->DriverUnload(md->minidriver.DriverObject);
-        list_remove(&md->entry);
-        HeapFree( GetProcessHeap(), 0, md );
-    }
-}
-
-NTSTATUS WINAPI HidRegisterMinidriver(HID_MINIDRIVER_REGISTRATION *registration)
-{
-    minidriver *driver;
-    driver = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*driver));
-
-    if (!driver)
-        return STATUS_NO_MEMORY;
-
-    driver->DriverUnload = registration->DriverObject->DriverUnload;
-    registration->DriverObject->DriverUnload = UnloadDriver;
-
-    registration->DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = HID_Device_ioctl;
-    registration->DriverObject->MajorFunction[IRP_MJ_READ] = HID_Device_read;
-    registration->DriverObject->MajorFunction[IRP_MJ_WRITE] = HID_Device_write;
-    registration->DriverObject->MajorFunction[IRP_MJ_CREATE] = HID_Device_create;
-    registration->DriverObject->MajorFunction[IRP_MJ_CLOSE] = HID_Device_close;
-
-    driver->PNPDispatch = registration->DriverObject->MajorFunction[IRP_MJ_PNP];
-    registration->DriverObject->MajorFunction[IRP_MJ_PNP] = HID_PNP_Dispatch;
-
-    driver->AddDevice = registration->DriverObject->DriverExtension->AddDevice;
-    registration->DriverObject->DriverExtension->AddDevice = PNP_AddDevice;
-
-    driver->minidriver = *registration;
-    list_add_tail(&minidriver_list, &driver->entry);
-
-    return STATUS_SUCCESS;
-}
-
-NTSTATUS call_minidriver(ULONG code, DEVICE_OBJECT *device, void *in_buff, ULONG in_size, void *out_buff, ULONG out_size)
-{
-    IRP *irp;
-    IO_STATUS_BLOCK io;
-    KEVENT event;
-
-    KeInitializeEvent(&event, NotificationEvent, FALSE);
-
-    irp = IoBuildDeviceIoControlRequest(code, device, in_buff, in_size,
-        out_buff, out_size, TRUE, &event, &io);
-
-    if (IoCallDriver(device, irp) == STATUS_PENDING)
-        KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
-
-    return io.u.Status;
-}
diff --git a/dlls/hidclass.sys/pnp.c b/dlls/hidclass.sys/pnp.c
index f7985d298d8..bb2035cac21 100644
--- a/dlls/hidclass.sys/pnp.c
+++ b/dlls/hidclass.sys/pnp.c
@@ -1,5 +1,5 @@
 /*
- * WINE HID Pseudo-Plug and Play support
+ * Human Interface Device class driver
  *
  * Copyright 2015 Aric Stewart
  *
@@ -30,6 +30,19 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(hid);
 
+static struct list minidriver_list = LIST_INIT(minidriver_list);
+
+static minidriver *find_minidriver(DRIVER_OBJECT *driver)
+{
+    minidriver *md;
+    LIST_FOR_EACH_ENTRY(md, &minidriver_list, minidriver, entry)
+    {
+        if (md->minidriver.DriverObject == driver)
+            return md;
+    }
+    return NULL;
+}
+
 static NTSTATUS WINAPI internalComplete(DEVICE_OBJECT *deviceObject, IRP *irp,
     void *context)
 {
@@ -69,7 +82,7 @@ static NTSTATUS get_device_id(DEVICE_OBJECT *device, BUS_QUERY_ID_TYPE type, WCH
     return status;
 }
 
-NTSTATUS WINAPI PNP_AddDevice(DRIVER_OBJECT *driver, DEVICE_OBJECT *PDO)
+static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *PDO)
 {
     WCHAR device_id[MAX_DEVICE_ID_LEN], instance_id[MAX_DEVICE_ID_LEN];
     DEVICE_OBJECT *device = NULL;
@@ -211,7 +224,7 @@ static NTSTATUS remove_device(minidriver *minidriver, DEVICE_OBJECT *device, IRP
     return rc;
 }
 
-NTSTATUS WINAPI HID_PNP_Dispatch(DEVICE_OBJECT *device, IRP *irp)
+static NTSTATUS WINAPI driver_pnp(DEVICE_OBJECT *device, IRP *irp)
 {
     NTSTATUS rc = STATUS_NOT_SUPPORTED;
     IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp);
@@ -296,3 +309,63 @@ NTSTATUS WINAPI HID_PNP_Dispatch(DEVICE_OBJECT *device, IRP *irp)
     IoCompleteRequest( irp, IO_NO_INCREMENT );
     return rc;
 }
+
+static void WINAPI driver_unload(DRIVER_OBJECT *driver)
+{
+    minidriver *md;
+
+    TRACE("\n");
+
+    if ((md = find_minidriver(driver)))
+    {
+        if (md->DriverUnload)
+            md->DriverUnload(md->minidriver.DriverObject);
+        list_remove(&md->entry);
+        HeapFree(GetProcessHeap(), 0, md);
+    }
+}
+
+NTSTATUS WINAPI HidRegisterMinidriver(HID_MINIDRIVER_REGISTRATION *registration)
+{
+    minidriver *driver;
+
+    if (!(driver = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*driver))))
+        return STATUS_NO_MEMORY;
+
+    driver->DriverUnload = registration->DriverObject->DriverUnload;
+    registration->DriverObject->DriverUnload = driver_unload;
+
+    registration->DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = HID_Device_ioctl;
+    registration->DriverObject->MajorFunction[IRP_MJ_READ] = HID_Device_read;
+    registration->DriverObject->MajorFunction[IRP_MJ_WRITE] = HID_Device_write;
+    registration->DriverObject->MajorFunction[IRP_MJ_CREATE] = HID_Device_create;
+    registration->DriverObject->MajorFunction[IRP_MJ_CLOSE] = HID_Device_close;
+
+    driver->PNPDispatch = registration->DriverObject->MajorFunction[IRP_MJ_PNP];
+    registration->DriverObject->MajorFunction[IRP_MJ_PNP] = driver_pnp;
+
+    driver->AddDevice = registration->DriverObject->DriverExtension->AddDevice;
+    registration->DriverObject->DriverExtension->AddDevice = driver_add_device;
+
+    driver->minidriver = *registration;
+    list_add_tail(&minidriver_list, &driver->entry);
+
+    return STATUS_SUCCESS;
+}
+
+NTSTATUS call_minidriver(ULONG code, DEVICE_OBJECT *device, void *in_buff, ULONG in_size, void *out_buff, ULONG out_size)
+{
+    IRP *irp;
+    IO_STATUS_BLOCK io;
+    KEVENT event;
+
+    KeInitializeEvent(&event, NotificationEvent, FALSE);
+
+    irp = IoBuildDeviceIoControlRequest(code, device, in_buff, in_size,
+        out_buff, out_size, TRUE, &event, &io);
+
+    if (IoCallDriver(device, irp) == STATUS_PENDING)
+        KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
+
+    return io.u.Status;
+}




More information about the wine-cvs mailing list