CD-ROM access via "\\\\.\\Cdrom0"

Pavel Roskin proski at gnu.org
Fri Nov 17 02:01:51 CST 2006


Hello!

I've tried to figure out why some programs working with CD and DVD
drives work only if the emulated version is set to Windows NT 4, but not
Windows 2000 or XP.

I used DVDDecrypter 3.5.4.0 with the current Wine from git.
DVDDecrypter is configured to use SPTI, which is the default.  Fixing
ASPI would be a separate topic.

If NT4 is emulated, the program scans all drives by letters and then
opens drive H: (which is the DVD drive on my system).  Here's an excerpt
from the log produced by

WINEDEBUG=+file,+cdrom,+ntdll,+kernel,+aspi wine DVDDecrypter.exe

trace:file:CreateFileW L"\\\\.\\H:" GENERIC_READ GENERIC_WRITE FILE_SHARE_READ FILE_SHARE_WRITE 
 creation 3 attributes 0x0
trace:file:RtlDosPathNameToNtPathName_U (L"\\\\.\\H:",0x7d6b75b0,(nil),(nil))
trace:file:RtlGetFullPathName_U (L"\\\\.\\H:" 520 0x7d6b7314 (nil))
trace:ntdll:NtCreateFile handle=0x7d6b75b8 access=c0000000 name=L"\\??\\H:" objattr=00000040 roo
t=(nil) sec=(nil) io=0x7d6b75a8 alloc_size=(nil)
attr=00000000 sharing=00000003 disp=1 options=00000050 ea=(nil).0x00000000
trace:file:get_dos_device L"H:" -> "/dev/scd0"
trace:file:CreateFileW returning 0x8c

And that's what the same command would produce with win2k emulation:

trace:file:CreateFileW L"\\\\.\\Cdrom0" GENERIC_READ GENERIC_WRITE FILE_SHARE_READ FILE_SHARE_WR
ITE  creation 3 attributes 0x0
trace:file:RtlDosPathNameToNtPathName_U (L"\\\\.\\Cdrom0",0x7d6b25b0,(nil),(nil))
trace:file:RtlGetFullPathName_U (L"\\\\.\\Cdrom0" 520 0x7d6b2314 (nil))
trace:ntdll:NtCreateFile handle=0x7d6b25b8 access=c0000000 name=L"\\??\\Cdrom0" objattr=00000040
 root=(nil) sec=(nil) io=0x7d6b25a8 alloc_size=(nil)
attr=00000000 sharing=00000003 disp=1 options=00000050 ea=(nil).0x00000000
warn:file:CreateFileW Unable to create file L"\\\\.\\Cdrom0" (status c0000034)
trace:file:CreateFileW returning 0xffffffff
trace:file:CreateFileW L"\\\\.\\Cdrom1" GENERIC_READ GENERIC_WRITE FILE_SHARE_READ FILE_SHARE_WR
ITE  creation 3 attributes 0x0
trace:file:RtlDosPathNameToNtPathName_U (L"\\\\.\\Cdrom1",0x7d6b25b0,(nil),(nil))

The program cycles like this to Cdrom63 and then gives up.

I think it would be great if Wine adds supported for opening CD-ROMs by
number.  Better yet if it enumerated CD-ROMs an other drives
automatically.

I have make a proof-of-concept patch that allows DVDDecrypter to find
the CD-ROM drive under win2k emulation.  I had to create a link
from .wine/dosdevices/cdrom0 to /dev/scd0 manually.  This is not the
right fix, but it shows that it can be done.


diff --git a/dlls/ntdll/path.c b/dlls/ntdll/path.c
index e4af89a..2ca5883 100644
--- a/dlls/ntdll/path.c
+++ b/dlls/ntdll/path.c
@@ -316,6 +316,7 @@ DOS_PATHNAME_TYPE WINAPI RtlDetermineDos
 ULONG WINAPI RtlIsDosDeviceName_U( PCWSTR dos_name )
 {
     static const WCHAR consoleW[] = {'\\','\\','.','\\','C','O','N',0};
+    static const WCHAR cdromW[] = {'\\','\\','.','\\','C','D','R','O','M',0};
     static const WCHAR auxW[3] = {'A','U','X'};
     static const WCHAR comW[3] = {'C','O','M'};
     static const WCHAR conW[3] = {'C','O','N'};
@@ -372,6 +373,12 @@ ULONG WINAPI RtlIsDosDeviceName_U( PCWST
         if (strncmpiW( start, comW, 3 ) && strncmpiW( start, lptW, 3 )) break;
         if (*end <= '0' || *end > '9') break;
         return MAKELONG( 4 * sizeof(WCHAR), (start - dos_name) * sizeof(WCHAR) );
+    case 11:
+        if (*(end - 1) <= '0' || *(end - 1) > '9') break;
+    case 10:
+        if (*end <= '0' || *end > '9') break;
+        if (strncmpiW( start, cdromW, 9 )) break;
+        return MAKELONG( (end - start + 1) * sizeof(WCHAR), (start - dos_name) * sizeof(WCHAR) );
     default:  /* can't match anything */
         break;
     }



-- 
Regards,
Pavel Roskin





More information about the wine-devel mailing list