[PATCH v3 07/20] winebus.sys: Add Linux udev bus
Thomas Faber
thfabba at gmx.de
Tue Sep 6 09:13:32 CDT 2016
> +NTSTATUS WINAPI common_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
> +{
> + NTSTATUS rc = STATUS_NOT_SUPPORTED;
You generally want to initialize this with irp->IoStatus.Status.
For requests the bus driver doesn't support, it needs to return
whatever the drivers higher up the stack decided.
E.g. IRP_MN_QUERY_DEVICE_RELATIONS might be handled by a bus driver FDO
above, in which case it will likely set the status to success -- and
lower-level drivers need to propagate this status unless they have
specific reason to override it.
This is the reason for the requirement to initialize IoStatus to
STATUS_NOT_SUPPORTED when sending the IRP.
> + IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp);
> +
> + switch(irpsp->MinorFunction)
> + {
> + case IRP_MN_QUERY_DEVICE_RELATIONS:
> + TRACE("IRP_MN_QUERY_DEVICE_RELATIONS\n");
> + break;
> + case IRP_MN_QUERY_ID:
> + {
> + TRACE("IRP_MN_QUERY_ID\n");
> + break;
> + }
> + case IRP_MN_QUERY_CAPABILITIES:
> + TRACE("IRP_MN_QUERY_CAPABILITIES\n");
> + break;
> + }
> + IoCompleteRequest( irp, IO_NO_INCREMENT );
> + return rc;
> +}
> +
> +DWORD check_bus_disabled(UNICODE_STRING *registry_path)
> +{
> + OBJECT_ATTRIBUTES attr;
> + HANDLE key;
> + DWORD disabled = 0;
> + static const WCHAR disabledW[] = {'D','i','s','a','b','l','e','d',0};
> + static const UNICODE_STRING disabled_str = {sizeof(disabledW) - sizeof(WCHAR), sizeof(disabledW), (WCHAR*)disabledW};
> +
> + InitializeObjectAttributes(&attr, registry_path, OBJ_CASE_INSENSITIVE, NULL, NULL);
This is another case for OBJ_KERNEL_HANDLE. You basically want this by
default in kernel code, unless you specifically intend to pass this
handle to an application.
> + if (ZwOpenKey(&key, KEY_ALL_ACCESS, &attr) == STATUS_SUCCESS)
> + {
> + DWORD size;
> + KEY_VALUE_PARTIAL_INFORMATION info;
> +
> + if (ZwQueryValueKey(key, &disabled_str, KeyValuePartialInformation, &info, sizeof(info), &size) == STATUS_SUCCESS)
Your 'info' structure isn't large enough to hold DWORD
data, since the 'Data' member is a one byte array.
> + {
> + disabled = *(DWORD*)&info.Data;
> + }
> +
> + ZwClose(key);
> + }
> +
> + return disabled;
> +}
More information about the wine-devel
mailing list