2 * WINE Hid device services
4 * Copyright 2015 Aric Stewart
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define NONAMELESSUNION
25 #include "wine/debug.h"
26 #include "wine/unicode.h"
27 #include "wine/list.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(hid
);
31 static struct list minidriver_list
= LIST_INIT(minidriver_list
);
33 static minidriver
* find_minidriver(DRIVER_OBJECT
*driver
)
36 LIST_FOR_EACH_ENTRY(md
, &minidriver_list
, minidriver
, entry
)
38 if (md
->minidriver
.DriverObject
== driver
)
44 static VOID WINAPI
UnloadDriver(DRIVER_OBJECT
*driver
)
48 TRACE("Driver Unload\n");
49 md
= find_minidriver(driver
);
53 md
->DriverUnload(md
->minidriver
.DriverObject
);
54 list_remove(&md
->entry
);
55 HeapFree( GetProcessHeap(), 0, md
);
59 NTSTATUS WINAPI
HidRegisterMinidriver(HID_MINIDRIVER_REGISTRATION
*registration
)
62 driver
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*driver
));
65 return STATUS_NO_MEMORY
;
67 driver
->DriverUnload
= registration
->DriverObject
->DriverUnload
;
68 registration
->DriverObject
->DriverUnload
= UnloadDriver
;
70 driver
->minidriver
= *registration
;
71 list_add_tail(&minidriver_list
, &driver
->entry
);
73 return STATUS_SUCCESS
;