[libdvdcss-devel] [Git][videolan/libdvdcss][master] 3 commits: Use wide chars explicitly to open the drive
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sat Dec 20 11:20:34 UTC 2025
Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdcss
Commits:
f5541d52 by Steve Lhomme at 2025-12-20T12:19:48+01:00
Use wide chars explicitly to open the drive
- - - - -
30dc25e8 by Steve Lhomme at 2025-12-20T12:19:48+01:00
Read the drive handle as a HANDLE
We still incorrectly pass it on as an int after this call.
- - - - -
4b940751 by Steve Lhomme at 2025-12-20T12:19:48+01:00
Use CreateFile2 when building for Win8+
CreateFileW is not allowed in Universal Windows Platform builds, but
CreateFile2 is. We call always use the call on Win8+ platforms which
includes all the UWP platforms and provides common code.
- - - - -
1 changed file:
- src/device.c
Changes:
=====================================
src/device.c
=====================================
@@ -480,7 +480,8 @@ static int libc_open ( dvdcss_t dvdcss, const char *psz_device )
#if defined( _WIN32 )
static int win2k_open ( dvdcss_t dvdcss, const char *psz_device )
{
- char psz_dvd[7] = "\\\\.\\\0:";
+ HANDLE h_fd;
+ WCHAR psz_dvd[7] = L"\\\\.\\\0:";
psz_dvd[4] = psz_device[0];
/* To work around an M$ bug in IOCTL_DVD_READ_STRUCTURE, we need read
@@ -491,24 +492,42 @@ static int win2k_open ( dvdcss_t dvdcss, const char *psz_device )
* won't send back the right result).
* (See Microsoft Q241374: Read and Write Access Required for SCSI
* Pass Through Requests) */
- dvdcss->i_fd = (int)
- CreateFile( psz_dvd, GENERIC_READ | GENERIC_WRITE,
+#if _WIN32_WINNT < 0x0602 /* _WIN32_WINNT_WIN8 */
+ h_fd =
+ CreateFileW( psz_dvd, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING,
FILE_FLAG_RANDOM_ACCESS, NULL );
- if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE )
- dvdcss->i_fd = (int)
- CreateFile( psz_dvd, GENERIC_READ, FILE_SHARE_READ,
+ if( h_fd == INVALID_HANDLE_VALUE )
+ h_fd =
+ CreateFileW( psz_dvd, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING,
FILE_FLAG_RANDOM_ACCESS, NULL );
-
- if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE )
+#else
+ CREATEFILE2_EXTENDED_PARAMETERS params;
+ ZeroMemory(¶ms, sizeof(params));
+ params.dwSize = sizeof(params);
+ params.dwFileFlags = FILE_FLAG_RANDOM_ACCESS;
+ h_fd =
+ CreateFile2( psz_dvd, GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ OPEN_EXISTING,
+ ¶ms );
+
+ if( h_fd == INVALID_HANDLE_VALUE )
+ h_fd =
+ CreateFile2( psz_dvd, GENERIC_READ, FILE_SHARE_READ,
+ OPEN_EXISTING,
+ ¶ms );
+#endif
+ if( h_fd == INVALID_HANDLE_VALUE )
{
print_error( dvdcss, "failed to open device %s", psz_device );
return -1;
}
+ dvdcss->i_fd = (int) h_fd;
dvdcss->i_pos = 0;
return 0;
View it on GitLab: https://code.videolan.org/videolan/libdvdcss/-/compare/7558acb06d8ba6346a3bb6fd668929ff04573946...4b940751fbbc9ca1d0631b21f0bcad56ca0376d9
--
View it on GitLab: https://code.videolan.org/videolan/libdvdcss/-/compare/7558acb06d8ba6346a3bb6fd668929ff04573946...4b940751fbbc9ca1d0631b21f0bcad56ca0376d9
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the libdvdcss-devel
mailing list