https://bugs.winehq.org/show_bug.cgi?id=40311
Bug ID: 40311 Summary: Processing of 'DeviceIoControl' calls doesn't corresponds to specification Product: Wine Version: unspecified Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: ntoskrnl Assignee: wine-bugs@winehq.org Reporter: ugnenko@mail.ru Distribution: ---
As described in specification 'Buffer Descriptions for I/O Control Codes' for 'METHOD_IN_DIRECT' or 'METHOD_OUT_DIRECT' transfer types the data buffer, to which points the pointer passed as 'lpOutputBuffer' argument into 'DeviceIoControl', must be accessible from driver. In other words, when in control code is specified 'METHOD_IN_DIRECT' tranfer type, the 'lpOutputBuffer' buffer may be used as the additional buffer of data that driver may transfer to device. This feature is used in software and drivers for Hantek Oscilloscopes. The pointer 'lpOutputBuffer' and argument 'nOutBufferSize', which are passed to 'DeviceIoControl' function, must are used as corresponding values for fields 'StartVa', 'ByteOffset' and 'ByteCount' in 'irp->MdlAddress' structure.
But Wine allocates new output buffer that are passed to 'IoBuildDeviceIoControlRequest' (see function 'dispatch_ioctl' in source file 'dlls/ntoskrnl.exe/ntoskrnl.c'). Thus data stored in output buffer aren't available for driver.
Specification: https://msdn.microsoft.com/en-us/library/windows/hardware/ff540663(v=vs.85)....
https://bugs.winehq.org/show_bug.cgi?id=40311
ugnenko@mail.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |ugnenko@mail.ru
https://bugs.winehq.org/show_bug.cgi?id=40311
Sebastian Lackner sebastian@fds-team.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |sebastian@fds-team.de
--- Comment #1 from Sebastian Lackner sebastian@fds-team.de --- I have sent patches for this issue:
http://source.winehq.org/patches/data/127128 http://source.winehq.org/patches/data/127129 http://source.winehq.org/patches/data/127130 http://source.winehq.org/patches/data/127131
https://bugs.winehq.org/show_bug.cgi?id=40311
--- Comment #2 from ugnenko@mail.ru --- (In reply to Sebastian Lackner from comment #1)
I have sent patches for this issue:
http://source.winehq.org/patches/data/127128 http://source.winehq.org/patches/data/127129 http://source.winehq.org/patches/data/127130 http://source.winehq.org/patches/data/127131
At the moment I temporarily solved my problem. But my solution is very dirty hack (patch https://github.com/AlexUg/hantekdso.sys/blob/master/hantekdso.sys/resources/...).
Thank you very much for your work. I hope your patches will be included in the next release.
https://bugs.winehq.org/show_bug.cgi?id=40311
--- Comment #3 from Sebastian Lackner sebastian@fds-team.de --- I wasn't aware of this patch, but actually it looks like your solution is not really that much different from my one. My proposed patch also transfers both the input and output buffer as a big chunk of data. In my opinion, all other alternative (for example transferring only the addresses, and then implement mapping on top of ReadProcessMemory) would require a much bigger overhead. Wine is also planning to use the driver framework for input devices, so multiple wineserver calls back and forth would be bad.
Regarding your project, please note that there is actually ongoing effort to implement Plug&Play support, HID support, and later also USB support. I'm not sure if your code is too much specialized for one specific USB Oscilloscope, but probably some parts (for example libusb handling) could also be useful for Wine. ;)
https://bugs.winehq.org/show_bug.cgi?id=40311
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Version|unspecified |1.9.5 Status|UNCONFIRMED |NEEDINFO CC| |focht@gmx.net
--- Comment #4 from Anastasius Focht focht@gmx.net --- Hello folks,
what's the status here? What happened to Sebastian's patches?
Regards
https://bugs.winehq.org/show_bug.cgi?id=40311
--- Comment #5 from ugnenko@mail.ru --- The bug is currently fixed. If I'm not mistaken, since version 3.4 (I don't remember exactly).
https://bugs.winehq.org/show_bug.cgi?id=40311
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEEDINFO |RESOLVED Fixed by SHA1| |b466e893116af5007a1302aef56 | |030f150884b75 Resolution|--- |FIXED
--- Comment #6 from Anastasius Focht focht@gmx.net --- Hello,
--- quote --- The bug is currently fixed. If I'm not mistaken, since version 3.4 (I don't remember exactly). --- quote ---
thanks. Indeed, I should have checked the git history from the time Sebastian commented here plus some extra months ;-)
Here we go.
--- snip --- $ git log --pretty=format:"%h %an %ad %s" --since "2016-10-16" --until "2016-12-01" --author "Sebastian" -- dlls/ntoskrnl.exe
b466e89311 Sebastian Lackner Sun Oct 16 08:57:21 2016 +0200 ntoskrnl.exe: Explicitly set MappedSystemVa for MDLs. 9912ef778f Sebastian Lackner Sun Oct 16 08:53:29 2016 +0200 ntoskrnl.exe: Use MmInitializeMdl in IoAllocateMdl. eb7ac554d1 Sebastian Lackner Sun Oct 16 08:51:06 2016 +0200 ntoskrnl.exe: Add support for METHOD_IN_DIRECT/METHOD_OUT_DIRECT ioctls. 5789b94f19 Sebastian Lackner Sun Oct 16 08:48:55 2016 +0200 ntoskrnl.exe: Defer deallocation of in_buff in dispatch_ioctl. --- snip ---
Using commit https://source.winehq.org/git/wine.git/commitdiff/b466e893116af5007a1302aef5... ("ntoskrnl.exe: Explicitly set MappedSystemVa for MDLs.") as resolution. Part of Wine 1.9.22 release.
Thanks Sebastian
Regards
https://bugs.winehq.org/show_bug.cgi?id=40311
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #7 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 5.8.