From 4f9ec8caa0120799ba234a819f976c3ca5c7308f Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Fri, 15 Jan 2021 22:08:46 +0000 Subject: [PATCH] CDVD: Increase buffer for DVD_LAYER_DESCRIPTOR Also added some extra messages if that fails (and not because it's a CD) --- pcsx2/CDVD/Windows/IOCtlSrc.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pcsx2/CDVD/Windows/IOCtlSrc.cpp b/pcsx2/CDVD/Windows/IOCtlSrc.cpp index ca07ba512b..3d3cb1c375 100644 --- a/pcsx2/CDVD/Windows/IOCtlSrc.cpp +++ b/pcsx2/CDVD/Windows/IOCtlSrc.cpp @@ -211,12 +211,28 @@ bool IOCtlSrc::ReadDVDInfo() // least 18 bytes of the layer descriptor or else the ioctl will fail. The // media specific information seems to be empty, so there's no point reading // any more than that. - std::array buffer; + + // UPDATE 15 Jan 2021 + // Okay so some drives seem to have descriptors BIGGER than 22 bytes! + // This causes the read to fail with INVALID_PARAMETER. + // So lets just give it 32 bytes to play with, it seems happy enough with that. + // Refraction + std::array buffer; DVD_READ_STRUCTURE dvdrs{{0}, DvdPhysicalDescriptor, 0, 0}; if (!DeviceIoControl(m_device, IOCTL_DVD_READ_STRUCTURE, &dvdrs, sizeof(dvdrs), buffer.data(), buffer.size(), &unused, nullptr)) + { + if ((GetLastError() == ERROR_INVALID_FUNCTION) || (GetLastError() == ERROR_NOT_SUPPORTED)) + { + Console.Warning("IOCTL_DVD_READ_STRUCTURE not supported"); + } + else if(GetLastError() != ERROR_UNRECOGNIZED_MEDIA) // ERROR_UNRECOGNIZED_MEDIA means probably a CD or no disc + { + Console.Warning("IOCTL Unknown Error %d", GetLastError()); + } return false; + } auto& layer = *reinterpret_cast( reinterpret_cast(buffer.data())->Data);