Arbitrary DOS device name

Daniel Kucera wine at danman.eu
Mon Jan 24 04:13:23 CST 2022


Hello all,

I have a Windows software which tries to access dos device name but it 
is failing:

0009:Call KERNEL32.CreateFileA(0060f588 
"\\\\.\\d6CDE-0",40000000,00000002,00000000,00000003,00000000,00000000) 
ret=00b1117f
0009:Call ntdll.RtlInitAnsiString(0060f49c,0060f588 "\\\\.\\d6CDE-0") 
ret=7b036296
0009:Ret  ntdll.RtlInitAnsiString() retval=0060f49c ret=7b036296
0009:Call ntdll.RtlAnsiStringToUnicodeString(3fff8bf8,0060f49c,00000000) 
ret=7b0362fb
0009:Ret  ntdll.RtlAnsiStringToUnicodeString() retval=00000000 
ret=7b0362fb
0009:Call ntdll._wcsicmp(3fff8c00 L"\\\\.\\d6CDE-0",7b09d0c0 L"CONIN$") 
ret=7b0355c9
0009:Ret  ntdll._wcsicmp() retval=fffffff9 ret=7b0355c9
0009:Call ntdll._wcsicmp(3fff8c00 L"\\\\.\\d6CDE-0",7b09d0ce L"CONOUT$") 
ret=7b035636
0009:Ret  ntdll._wcsicmp() retval=fffffff9 ret=7b035636
0009:Call ntdll.wcsncmp(3fff8c00 L"\\\\.\\d6CDE-0",7b09d644 
L"\\\\.\\",00000004) ret=7b035670
0009:Ret  ntdll.wcsncmp() retval=00000000 ret=7b035670
0009:Call ntdll.iswalpha(00000064) ret=7b0356cd
0009:Ret  ntdll.iswalpha() retval=00000102 ret=7b0356cd
0009:Call ntdll._wcsnicmp(3fff8c08 L"d6CDE-0",7b09d638 
L"PIPE\\",00000005) ret=7b0356f5
0009:Ret  ntdll._wcsnicmp() retval=fffffff4 ret=7b0356f5
0009:Call ntdll._wcsnicmp(3fff8c08 L"d6CDE-0",7b09d624 
L"MAILSLOT\\",00000009) ret=7b03570e
0009:Ret  ntdll._wcsnicmp() retval=fffffff7 ret=7b03570e
0009:Call ntdll.RtlIsDosDeviceName_U(3fff8c08 L"d6CDE-0") ret=7b035724
0009:Ret  ntdll.RtlIsDosDeviceName_U() retval=00000000 ret=7b035724
0009:Call ntdll.RtlDosPathNameToNtPathName_U(3fff8c00 
L"\\\\.\\d6CDE-0",0060f458,00000000,00000000) ret=7b035769
0009:Ret  ntdll.RtlDosPathNameToNtPathName_U() retval=00000001 
ret=7b035769
0009:Call 
ntdll.NtCreateFile(0060f454,40100080,0060f474,0060f460,00000000,00000000,00000002,00000001,00000060,00000000,00000000) 
ret=7b03581e
0009:Ret  ntdll.NtCreateFile() retval=c0000034 ret=7b03581e
0009:Call ntdll.RtlNtStatusToDosError(c0000034) ret=7b035a11
0009:Ret  ntdll.RtlNtStatusToDosError() retval=00000002 ret=7b035a11
0009:Call ntdll.RtlFreeUnicodeString(0060f458) ret=7b03592b
0009:Ret  ntdll.RtlFreeUnicodeString() retval=0060f458 ret=7b03592b
0009:Ret  KERNEL32.CreateFileA() retval=ffffffff ret=00b1117f

The problem is, that wine doesn't recognize "\\\\.\\d6CDE-0" as valid 
DOS device name:
https://github.com/wine-mirror/wine/blob/e909986e6ea5ecd49b2b847f321ad89b2ae4f6f1/dlls/ntdll/path.c#L70

Even when I created the device in HKEY_LOCAL_MACHINE\Software\Wine\Ports 
it doesn't allow to open it.

When I patched the corresponding DLL to use COM81 and created the device 
in Ports, it works okay (can open the device).

I want to write a patch for ntdll/path.c to recognize my string as DOS 
device but I want it to be generic enough to be acceptable.

What approach do you suggest? Can I add a generic match, something like: 
"\\\\.\\[^\\]+$" ?

To add some context here, the software is for controlling USB 
osclloscope from Hantek:
http://hantek.com/uploadpic/hantek/files/20210731/Hantek-6000_Ver2.2.7_D20210721.rar
It installs a driver which creates mentioned "DOS device" and 
communicates through it using ioctl.
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.

Thanks.

-- 

S pozdravom / Best regards
Daniel Kucera.



More information about the wine-devel mailing list