winebus.sys: Move udev configuration values to the winebus service key.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-05-29 23:02:29 -05:00 committed by Alexandre Julliard
parent 50b9456e87
commit d525c736b9
4 changed files with 32 additions and 44 deletions

View File

@ -50,5 +50,7 @@ void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) DECLS
DEVICE_OBJECT* bus_enumerate_hid_devices(const platform_vtbl *vtbl, enum_func function, void* context) DECLSPEC_HIDDEN;
/* General Bus Functions */
DWORD check_bus_option(UNICODE_STRING *registry_path, const UNICODE_STRING *option, DWORD default_value) DECLSPEC_HIDDEN;
DWORD check_bus_option(const UNICODE_STRING *option, DWORD default_value) DECLSPEC_HIDDEN;
BOOL is_xbox_gamepad(WORD vid, WORD pid) DECLSPEC_HIDDEN;
HANDLE driver_key DECLSPEC_HIDDEN;

View File

@ -993,14 +993,9 @@ static void process_device_event(SDL_Event *event)
set_mapped_report_from_event(event);
}
typedef struct _thread_args {
HANDLE event;
UNICODE_STRING *registry_path;
} thread_arguments;
static DWORD CALLBACK deviceloop_thread(void *args)
{
thread_arguments *thread_args = args;
HANDLE init_done = args;
SDL_Event event;
if (pSDL_Init(SDL_INIT_GAMECONTROLLER|SDL_INIT_HAPTIC) < 0)
@ -1015,16 +1010,10 @@ static DWORD CALLBACK deviceloop_thread(void *args)
/* Process mappings */
if (pSDL_GameControllerAddMapping != NULL)
{
HANDLE key;
OBJECT_ATTRIBUTES attr;
WCHAR buffer[MAX_PATH];
UNICODE_STRING regpath = {0, sizeof(buffer), buffer};
static const WCHAR szPath[] = {'\\','m','a','p',0};
HKEY key;
static const WCHAR szPath[] = {'m','a','p',0};
RtlCopyUnicodeString(&regpath, thread_args->registry_path);
RtlAppendUnicodeToString(&regpath, szPath);
InitializeObjectAttributes(&attr, &regpath, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);
if (NtOpenKey(&key, KEY_ALL_ACCESS, &attr) == STATUS_SUCCESS)
if (!RegOpenKeyExW(driver_key, szPath, 0, KEY_ENUMERATE_SUB_KEYS, &key))
{
DWORD index = 0;
CHAR *buffer = NULL;
@ -1063,7 +1052,7 @@ static DWORD CALLBACK deviceloop_thread(void *args)
}
}
SetEvent(thread_args->event);
SetEvent(init_done);
while (1)
while (pSDL_WaitEvent(&event) != 0)
@ -1085,7 +1074,6 @@ NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_
HANDLE events[2];
DWORD result;
thread_arguments args;
TRACE("(%p, %s)\n", driver, debugstr_w(registry_path->Buffer));
if (sdl_handle == NULL)
@ -1136,13 +1124,11 @@ NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_
pSDL_JoystickGetVendor = wine_dlsym(sdl_handle, "SDL_JoystickGetVendor", NULL, 0);
}
map_controllers = check_bus_option(registry_path, &controller_mode, 1);
map_controllers = check_bus_option(&controller_mode, 1);
if (!(events[0] = CreateEventW(NULL, TRUE, FALSE, NULL)))
return STATUS_UNSUCCESSFUL;
args.event = events[0];
args.registry_path = registry_path;
if (!(events[1] = CreateThread(NULL, 0, deviceloop_thread, &args, 0, NULL)))
if (!(events[1] = CreateThread(NULL, 0, deviceloop_thread, events[0], 0, NULL)))
{
CloseHandle(events[0]);
return STATUS_UNSUCCESSFUL;

View File

@ -1468,12 +1468,12 @@ NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry
return STATUS_UNSUCCESSFUL;
}
disable_hidraw = check_bus_option(registry_path, &hidraw_disabled, 0);
disable_hidraw = check_bus_option(&hidraw_disabled, 0);
if (disable_hidraw)
TRACE("UDEV hidraw devices disabled in registry\n");
#ifdef HAS_PROPER_INPUT_HEADER
disable_input = check_bus_option(registry_path, &input_disabled, 0);
disable_input = check_bus_option(&input_disabled, 0);
if (disable_input)
TRACE("UDEV input devices disabled in registry\n");
#endif

View File

@ -63,6 +63,8 @@ static const WORD PID_XBOX_CONTROLLERS[] = {
static DRIVER_OBJECT *driver_obj;
HANDLE driver_key;
struct pnp_device
{
struct list entry;
@ -738,30 +740,19 @@ void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length)
LeaveCriticalSection(&ext->report_cs);
}
DWORD check_bus_option(UNICODE_STRING *registry_path, const UNICODE_STRING *option, DWORD default_value)
DWORD check_bus_option(const UNICODE_STRING *option, DWORD default_value)
{
OBJECT_ATTRIBUTES attr;
HANDLE key;
DWORD output = default_value;
char buffer[FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[sizeof(DWORD)])];
KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION*)buffer;
DWORD size;
InitializeObjectAttributes(&attr, registry_path, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);
if (NtOpenKey(&key, KEY_ALL_ACCESS, &attr) == STATUS_SUCCESS)
if (NtQueryValueKey(driver_key, option, KeyValuePartialInformation, info, sizeof(buffer), &size) == STATUS_SUCCESS)
{
DWORD size;
char buffer[FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[sizeof(DWORD)])];
KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION*)buffer;
if (NtQueryValueKey(key, option, KeyValuePartialInformation, info, sizeof(buffer), &size) == STATUS_SUCCESS)
{
if (info->Type == REG_DWORD)
output = *(DWORD*)info->Data;
}
NtClose(key);
if (info->Type == REG_DWORD)
return *(DWORD*)info->Data;
}
return output;
return default_value;
}
BOOL is_xbox_gamepad(WORD vid, WORD pid)
@ -782,6 +773,7 @@ static void WINAPI driver_unload(DRIVER_OBJECT *driver)
udev_driver_unload();
iohid_driver_unload();
sdl_driver_unload();
NtClose(driver_key);
}
NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
@ -794,16 +786,24 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
static UNICODE_STRING sdl = {sizeof(sdlW) - sizeof(WCHAR), sizeof(sdlW), (WCHAR *)sdlW};
static const WCHAR SDL_enabledW[] = {'E','n','a','b','l','e',' ','S','D','L',0};
static const UNICODE_STRING SDL_enabled = {sizeof(SDL_enabledW) - sizeof(WCHAR), sizeof(SDL_enabledW), (WCHAR*)SDL_enabledW};
OBJECT_ATTRIBUTES attr = {0};
NTSTATUS ret;
TRACE( "(%p, %s)\n", driver, debugstr_w(path->Buffer) );
attr.Length = sizeof(attr);
attr.ObjectName = path;
attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE;
if ((ret = NtOpenKey(&driver_key, KEY_ALL_ACCESS, &attr)) != STATUS_SUCCESS)
ERR("Failed to open driver key, status %#x.\n", ret);
driver_obj = driver;
driver->MajorFunction[IRP_MJ_PNP] = common_pnp_dispatch;
driver->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = hid_internal_dispatch;
driver->DriverUnload = driver_unload;
if (check_bus_option(path, &SDL_enabled, 1))
if (check_bus_option(&SDL_enabled, 1))
{
if (IoCreateDriver(&sdl, sdl_driver_init) == STATUS_SUCCESS)
return STATUS_SUCCESS;