https://bugs.winehq.org/show_bug.cgi?id=37724
Bug ID: 37724 Summary: Modern applications won't find COM ports nor HID devices Product: Wine Version: unspecified Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: setupapi Assignee: wine-bugs@winehq.org Reporter: heha@hrz.tu-chemnitz.de Distribution: ---
While old apps search COM ports use CreateFile("COMx"...) attempts to detect the presence of serial interfaces, newer apps use SetupDi functions. As a typical excerpt:
devs=SetupDiGetClassDevs(&GUID_DEVCLASS_PORTS,NULL,0,DIGCF_PRESENT); if (devs!=INVALID_HANDLE_VALUE) { SP_DEVINFO_DATA devInfo; devInfo.cbSize=sizeof devInfo; for (i=0; SetupDiEnumDeviceInfo(devs,i,&devInfo); i++) { HKEY hKey; TCHAR s[16]; DWORD slen=sizeof s; *s=0; if ((hKey=SetupDiOpenDevRegKey(devs,&devInfo, DICS_FLAG_GLOBAL,0,DIREG_DEV,KEY_READ)) ==INVALID_HANDLE_VALUE) continue; RegQueryValueEx(hKey,T("PortName"),NULL,NULL,(LPBYTE)s,&slen); RegCloseKey(hKey); if (*s=='C') { // filter out LPTx int idx=ComboBox_AddString(hCombo,s); int num=StrToInt(s+3)-1; ComboBox_SetItemData(hCombo,idx,num); if (num==Config.SerialNo) ComboBox_SetCurSel(hCombo,idx); } } SetupDiDestroyDeviceInfoList(devs); }
The main advantages for this approach are: * Unlimited COM port numbers * Much faster than looped CreateFile attempts
Therefore, modern apps use this procedure.
Similarly, apps talking with modern USB HID devices (these devices don't need an install procedure), do this procedure to find their device:
GUID hidGuid; HidD_GetHidGuid(&hidGuid); devs=SetupDiGetClassDevs(&hidGuid,0,0,DIGCF_PRESENT|DIGCF_DEVICEINTERFACE); if (devs!=INVALID_HANDLE_VALUE) { SP_DEVICE_INTERFACE_DATA devinterface; devinterface.cbSize=sizeof devinterface; for (i=0; SetupDiEnumDeviceInterfaces(devs,NULL,&hidGuid,i,&devinterface); i++) { THid Hid; union{ // save stack space SP_DEVICE_INTERFACE_DETAIL_DATA detail; TCHAR space[MAX_PATH+4]; WCHAR ps[128]; // Product String HIDD_ATTRIBUTES a; }u; SP_DEVINFO_DATA info; info.cbSize=sizeof info; u.detail.cbSize=sizeof u.detail; if (!SetupDiGetDeviceInterfaceDetail(devs,&devinterface, &u.detail,sizeof u,NULL,&info)) continue; Hid.hDev=CreateFile(u.detail.DevicePath,GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,NULL); if (Hid.hDev!=INVALID_HANDLE_VALUE) { HidD_GetAttributes(Hid.hDev,&u.a); if (*(DWORD*)&u.a.VendorID==0x27D916C0 && HidD_GetProductString(Hid.hDev,u.ps,elemof(u.ps))) { int l=ComboBox_AddStringW(hCombo,u.ps); ComboBox_SetItemData(hCombo,l,i); if (i==Config.iUsbHid) ComboBox_SetCurSel(hCombo,l); } CloseHandle(Hid.hDev); } } SetupDiDestroyDeviceInfoList(devs); }
Nice when at least the COM port detection will work in near future.
I can write a small test application to support the bug-fixing process. Googling for Funkuhr.exe will reveal a source code that contains both routines already.
https://bugs.winehq.org/show_bug.cgi?id=37724
Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |bon@elektron.ikp.physik.tu- | |darmstadt.de
--- Comment #1 from Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de --- Hendrik wrote:
I can write a small test application to support the bug-fixing process.
I think the right place for test code is the wine test suite in dlls/setupapi/tests Please consider!
Another area where wine setupapi is not yet fit is usb devices. Vendors more and more use winusb to talk to these devices and as winusb is a dll a winusb replacement dll using libusb is thinkable. But devices still must be found.
https://bugs.winehq.org/show_bug.cgi?id=37724
Saulius K. saulius2@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |saulius2@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=37724
Ken Sharp imwellcushtymelike@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |hardware
https://bugs.winehq.org/show_bug.cgi?id=37724
--- Comment #2 from Austin English austinenglish@gmail.com --- FYI, a stub winusb was added: https://source.winehq.org/git/wine.git/commitdiff/c6adf8af6e3015e7a2cb40aa95...
which was enough for an app requested by a user in #winehq (GrandMA2)
https://bugs.winehq.org/show_bug.cgi?id=37724
Constantine hi-angel@yandex.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |hi-angel@yandex.ru
https://bugs.winehq.org/show_bug.cgi?id=37724
--- Comment #3 from Henrik Haftmann heha@hrz.tu-chemnitz.de --- Sorry, the (my) problem is: I don't know how to add that code to the wine test suite so I hoped that one reader will do this.
But then someone "changed" the problem to libusb/winusb stuff which is completely different. Really not nice. The problem listed above still persists.
https://bugs.winehq.org/show_bug.cgi?id=37724
Gerold Gerold.Ruhland@gmx-topmail.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |Gerold.Ruhland@gmx-topmail. | |de
--- Comment #4 from Gerold Gerold.Ruhland@gmx-topmail.de --- Looks like the flag DIGCF_PRESENT is ignored
Using devs=SetupDiGetClassDevs(&GUID_DEVCLASS_PORTS,NULL,0,DIGCF_PRESENT);
also returns devices NOT present in the system.
At least with CrossOver 17.5.1 based on Wine 2.8
Has this been fixed in current Wine stable?
https://bugs.winehq.org/show_bug.cgi?id=37724
--- Comment #5 from Gijs Vermeulen gijsvrm@gmail.com --- (In reply to Gerold from comment #4)
It would seem so, look at these commits:
3fa12ba3a5bdb44fa7f055a014048e59c6915aea 4526c5923cc55a7de0a6d803631898d63da325c7 8343099ff51a5e398f75789fbec70bc566bac9ac
https://bugs.winehq.org/show_bug.cgi?id=37724
Zebediah Figura z.figura12@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |1.7.33 Status|UNCONFIRMED |RESOLVED Component|setupapi |mountmgr.sys Resolution|--- |DUPLICATE CC| |z.figura12@gmail.com
--- Comment #6 from Zebediah Figura z.figura12@gmail.com --- This bug got a little muddy, but the initial report seems (mostly) valid: we do create kernel-mode devices for serial ports, but we don't register setupapi interfaces for them. We do both for HID devices now, though, so that part is fixed.
Anyway, since the remaining part is just bug 10051, I'm resolving this as a duplicate.
*** This bug has been marked as a duplicate of bug 10051 ***
https://bugs.winehq.org/show_bug.cgi?id=37724
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #7 from Austin English austinenglish@gmail.com --- Closing.