Arbitrary DOS device name

Daniel Kucera wine at danman.eu
Tue Jan 25 11:39:55 CST 2022


On 2022-01-24 12:26, Stefan Dösinger wrote:
> Am Montag, 24. Jänner 2022, 13:13:23 EAT schrieb Daniel Kucera:
> 
>> I am reversing the driver and I'll create a Linux char device to 
>> handle
>> those ioctl calls and talk to the USB device using libusb.
> 
> If I understand you right you want to create a 
> $WINEPREFIX/dosdevices/d6CDE-0
> link to whatever char device your Linux driver creates, and that 
> doesn't work
> because Wine will only do that for COM ports and other drives?

I can create the link but wine refuses to open the device because it 
doesn't match any of the defined device prefixes: 
https://github.com/wine-mirror/wine/blob/e909986e6ea5ecd49b2b847f321ad89b2ae4f6f1/dlls/ntdll/path.c#L72

> From Wine's point of view the proper solution is to load the original 
> Windows
> device driver, have it talk to the USB hardware via libusb and the 
> Windows
> software via the device it creates. Wine nowadays should have 
> infrastructure
> to support that. I haven't used it myself though.

I was researching this option but I haven't even found a way to load a 
driver.
Besides, if the original driver doesn't work out-of-the-box (which I 
presume it won't), I am not really able to write/compile wine/Windows 
driver.

> 
> Beyond opening the device name, how would the ioctl forward work? Is it 
> some
> standard serial port ioctl that pass throuh Wine to your driver fine? 
> Or would
> you need to teach Wine to forward them as well?

So what works for me now is, that when I create the link COM81 -> 
/dev/hantek and create the device using cuse 
(https://libfuse.github.io/doxygen/cuse_8c.html) , the software is able 
to open the device:

  FUSE library version: 3.10.3
  unique: 2, opcode: CUSE_INIT (4096), nodeid: 0, insize: 56, pid: 
1568849
  CUSE_INIT: 7.34
  flags=0x00000001
    CUSE_INIT: 7.31
    flags=0x00000001
    max_read=0x00020000
    max_write=0x00100000
    dev_major=0
    dev_minor=0
    dev_info: DEVNAME=hantek
    unique: 2, success, outsize: 103
  unique: 4, opcode: OPEN (14), nodeid: 0, insize: 48, pid: 1568962
    unique: 4, success, outsize: 32
  unique: 6, opcode: IOCTL (39), nodeid: 0, insize: 72, pid: 1568962
  unknown ioctld 21505
    unique: 6, error: -22 (Invalid argument), outsize: 16
  unique: 8, opcode: RELEASE (18), nodeid: 0, insize: 64, pid: 0
    unique: 8, success, outsize: 16

The software is calling DeviceIoControl() which results in ioctl calls 
in wine server and ends here:
https://github.com/wine-mirror/wine/blob/master/server/fd.c#L2408

To forward the call to device, I would need to modify this function, 
something in this sense:

diff --git a/server/fd.c b/server/fd.c
index 5d80e218b97..627b44fc195 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -2261,7 +2261,8 @@ int default_fd_ioctl( struct fd *fd, ioctl_code_t 
code, struct async *async )
          unmount_device( fd );
          return 1;
      default:
-        set_error( STATUS_NOT_SUPPORTED );
+       ioctl(fd->unix_fd, code, ioctl_data); // how the get the call 
data here?
+        //set_error( STATUS_NOT_SUPPORTED );
          return 0;
      }
  }




More information about the wine-devel mailing list