[PATCH v2] winebus.sys: Allow mapping of SDL controllers

Aric Stewart aric at codeweavers.com
Fri Mar 15 14:35:25 CDT 2019



On 3/15/19 9:47 AM, Zebediah Figura wrote:
> On 3/7/19 11:36 AM, Aric Stewart wrote:
>  > +            ULONG index = 0;
>  > +            KEY_VALUE_PARTIAL_INFORMATION *info;
>  > +            DWORD length, result_len;
>  > +            NTSTATUS status;
>  > +
>  > +            length = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + (1000 * sizeof(WCHAR));
>  > +            info = HeapAlloc(GetProcessHeap(), 0, length);
>  > +
>  > +            do {
>  > +                status = NtEnumerateValueKey(key, index, KeyValuePartialInformation,
>  > +                                             info, length, &result_len);
>  > +                if (status == STATUS_SUCCESS)
>  > +                {
>  > +                    CHAR mapping[1000] = {0};
>  > +                    WideCharToMultiByte(CP_ACP, 0, info->Data,
>  > +                        (info->DataLength / sizeof(WCHAR)), mapping, sizeof(mapping),
>  > +                        NULL, NULL);
>  > +                    if (mapping[0] != 0)
>  > +                    {
>  > +                        TRACE("Setting mapping %s\n",debugstr_a(mapping));
>  > +                        pSDL_GameControllerAddMapping(mapping);
>  > +                    } else {
>  > +                        ERR("Failed to convert mapping %s\n",debugstr_w(info->Data));
>  > +                    }
>  > +                    index ++;
>  > +                }
>  > +            } while (status == STATUS_SUCCESS);
>  > +            HeapFree(GetProcessHeap(), 0, info);
>  > +            NtClose(key);
> 
> I have to imagine that these strings can be arbitrarily long, and so I'd think it would be better to dynamically reallocate the structure.
> 

Agreed, patch sent.

> I still don't like the use of NT APIs here: just because a real native driver uses it doesn't mean we have to, and they're generally more complex and harder to read. Still, if you insist...

It is easier for me here as I am being passed a UNICODE_STRING with the full path for the driver registry path in an NT API format. 

-aric



More information about the wine-devel mailing list