From: Alex Henrie <alexhenrie24@gmail.com> The hack has to be in kernel32.dll; having it in krnl386.exe is not enough for all programs that need the old behavior. And in my testing, the error was STATUS_ACCESS_DENIED whether using a physical CD or a mounted ISO file, never STATUS_MEDIA_WRITE_PROTECTED. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59636 --- dlls/kernelbase/file.c | 16 ++++++++++++++++ dlls/krnl386.exe16/int21.c | 7 ------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c index 83977a2c40b..cfc4d70a708 100644 --- a/dlls/kernelbase/file.c +++ b/dlls/kernelbase/file.c @@ -873,6 +873,22 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateFileW( LPCWSTR filename, DWORD access, DWO NULL, attributes & FILE_ATTRIBUTE_VALID_FLAGS, sharing, nt_disposition[creation - CREATE_NEW], get_nt_file_options( attributes, creation ), NULL, 0 ); + + /* Before Windows NT, the write flag was ignored on CD drives */ + if (status == STATUS_ACCESS_DENIED && (access & GENERIC_WRITE) && (GetVersion() & 0x80000000)) + { + WCHAR volume[MAX_PATH]; + if (GetVolumePathNameW( filename, volume, ARRAY_SIZE(volume) ) && + GetDriveTypeW( volume ) == DRIVE_CDROM) + { + WARN( "Ignoring write flag on CD drive\n" ); + status = NtCreateFile( &ret, (access & ~GENERIC_WRITE) | SYNCHRONIZE | FILE_READ_ATTRIBUTES, + &attr, &io, NULL, attributes & FILE_ATTRIBUTE_VALID_FLAGS, sharing, + nt_disposition[creation - CREATE_NEW], + get_nt_file_options( attributes, creation ), NULL, 0 ); + } + } + if (status) { if (vxd_name && vxd_name[0]) diff --git a/dlls/krnl386.exe16/int21.c b/dlls/krnl386.exe16/int21.c index e8f1361cc37..13f33966f8a 100644 --- a/dlls/krnl386.exe16/int21.c +++ b/dlls/krnl386.exe16/int21.c @@ -920,13 +920,6 @@ static BOOL INT21_CreateFile( CONTEXT *context, MultiByteToWideChar(CP_OEMCP, 0, pathA, -1, pathW, MAX_PATH); winHandle = CreateFileW( pathW, winAccess, winSharing, NULL, winMode, winAttributes, 0 ); - /* DOS allows opening files on a CDROM R/W */ - if( winHandle == INVALID_HANDLE_VALUE && - (GetLastError() == ERROR_WRITE_PROTECT || - GetLastError() == ERROR_ACCESS_DENIED)) { - winHandle = CreateFileW( pathW, winAccess & ~GENERIC_WRITE, - winSharing, NULL, winMode, winAttributes, 0 ); - } if (winHandle == INVALID_HANDLE_VALUE) return FALSE; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10633