From: Alexandre Goujon Subject: [PATCH 5/5] kernel32/tests: Add a IOCTL_DVD_READ_STRUCTURE (DvdManufacturerDescriptor) test (try 4) Message-Id: <1342038412-9786-5-git-send-email-ale.goujon@gmail.com> Date: Wed, 11 Jul 2012 22:26:52 +0200 and fix wine It should fix bugs #29669 and (the duplicate) #30632 --- dlls/kernel32/tests/volume.c | 36 ++++++++++++++++++++++++++++++++++++ dlls/ntdll/cdrom.c | 21 +++++++++++++++++---- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c index 45bac31..8152ae1 100644 --- a/dlls/kernel32/tests/volume.c +++ b/dlls/kernel32/tests/volume.c @@ -34,6 +34,16 @@ struct COMPLETE_DVD_LAYER_DESCRIPTOR #include C_ASSERT(sizeof(struct COMPLETE_DVD_LAYER_DESCRIPTOR) == 22); +#include +struct COMPLETE_DVD_MANUFACTURER_DESCRIPTOR +{ + DVD_DESCRIPTOR_HEADER Header; + DVD_MANUFACTURER_DESCRIPTOR Descriptor; + UCHAR Padding; +}; +#include +C_ASSERT(sizeof(struct COMPLETE_DVD_MANUFACTURER_DESCRIPTOR) == 2053); + static HINSTANCE hdll; static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointA)(LPCSTR, LPSTR, DWORD); static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointW)(LPCWSTR, LPWSTR, DWORD); @@ -750,6 +760,7 @@ static void test_dvd_read_structure(HANDLE handle) DVD_LAYER_DESCRIPTOR dvdLayerDescriptor; struct COMPLETE_DVD_LAYER_DESCRIPTOR completeDvdLayerDescriptor; DVD_COPYRIGHT_DESCRIPTOR dvdCopyrightDescriptor; + struct COMPLETE_DVD_MANUFACTURER_DESCRIPTOR completeDvdManufacturerDescriptor; dvdReadStructure.BlockByteOffset.QuadPart = 0; dvdReadStructure.SessionId = 0; @@ -839,6 +850,31 @@ static void test_dvd_read_structure(HANDLE handle) &dvdCopyrightDescriptor, i, &nbBytes, NULL); ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "IOCTL_DVD_READ_STRUCTURE should have failed %d %u\n", ret, GetLastError()); } + + + /* DvdManufacturerDescriptor */ + dvdReadStructure.Format = 4; + + SetLastError(0xdeadbeef); + + ret = DeviceIoControl(handle, IOCTL_DVD_READ_STRUCTURE, &dvdReadStructure, sizeof(DVD_READ_STRUCTURE), + &completeDvdManufacturerDescriptor, sizeof(DVD_MANUFACTURER_DESCRIPTOR), &nbBytes, NULL); + ok(ret || broken(GetLastError() == ERROR_NOT_READY), + "IOCTL_DVD_READ_STRUCTURE (DvdManufacturerDescriptor) failed, last error = %u\n", GetLastError()); + if(!ret) + return; + + /* Confirm there is always a header before the actual data */ + ok( completeDvdManufacturerDescriptor.Header.Length == 0x0802, "Length is 0x%04x instead of 0x0802\n", completeDvdManufacturerDescriptor.Header.Length); + ok( completeDvdManufacturerDescriptor.Header.Reserved[0] == 0, "Reserved[0] is %x instead of 0\n", completeDvdManufacturerDescriptor.Header.Reserved[0]); + ok( completeDvdManufacturerDescriptor.Header.Reserved[1] == 0, "Reserved[1] is %x instead of 0\n", completeDvdManufacturerDescriptor.Header.Reserved[1]); + + SetLastError(0xdeadbeef); + + /* Basic parameter check */ + ret = DeviceIoControl(handle, IOCTL_DVD_READ_STRUCTURE, &dvdReadStructure, sizeof(DVD_READ_STRUCTURE), + NULL, sizeof(DVD_MANUFACTURER_DESCRIPTOR), &nbBytes, NULL); + ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "IOCTL_DVD_READ_STRUCTURE should have failed %d %u\n", ret, GetLastError()); } static void test_cdrom_ioctl(void) diff --git a/dlls/ntdll/cdrom.c b/dlls/ntdll/cdrom.c index 19549a2..72f1c17 100644 --- a/dlls/ntdll/cdrom.c +++ b/dlls/ntdll/cdrom.c @@ -231,6 +231,13 @@ typedef struct } internal_dvd_layer_descriptor; C_ASSERT(sizeof(internal_dvd_layer_descriptor) == 22); +typedef struct +{ + DVD_DESCRIPTOR_HEADER Header; + DVD_MANUFACTURER_DESCRIPTOR Descriptor; + UCHAR Padding; +} internal_dvd_manufacturer_descriptor; +C_ASSERT(sizeof(internal_dvd_manufacturer_descriptor) == 2053); static NTSTATUS CDROM_ReadTOC(int, int, CDROM_TOC*); static NTSTATUS CDROM_GetStatusCode(int); @@ -2598,9 +2605,12 @@ static NTSTATUS DVD_ReadStructure(int dev, const DVD_READ_STRUCTURE *structure, case DvdManufacturerDescriptor: { - PDVD_MANUFACTURER_DESCRIPTOR p = (PDVD_MANUFACTURER_DESCRIPTOR) layer; + internal_dvd_manufacturer_descriptor *p = (internal_dvd_manufacturer_descriptor*) layer; - memcpy(p->ManufacturingInformation, s.manufact.value, 2048); + p->Header.Length = 0x0802; + p->Header.Reserved[0] = 0; + p->Header.Reserved[1] = 0; + memcpy(p->Descriptor.ManufacturingInformation, s.manufact.value, 2048); } break; @@ -2623,7 +2633,7 @@ static NTSTATUS DVD_ReadStructure(int dev, const DVD_READ_STRUCTURE *structure, internal_dvd_layer_descriptor *xlayer; PDVD_COPYRIGHT_DESCRIPTOR copy; PDVD_DISK_KEY_DESCRIPTOR disk_key; - PDVD_MANUFACTURER_DESCRIPTOR manf; + internal_dvd_manufacturer_descriptor manf; } nt_desc; nt_desc.layer = layer; @@ -2708,8 +2718,11 @@ static NTSTATUS DVD_ReadStructure(int dev, const DVD_READ_STRUCTURE *structure, break; case DvdManufacturerDescriptor: + nt_desc.manf->Header.Length = 0x0802; + nt_desc.manf->Header.Reserved[0] = 0; + nt_desc.manf->Header.Reserved[1] = 0; memcpy( - nt_desc.manf->ManufacturingInformation, + nt_desc.manf->Descriptor.ManufacturingInformation, desc.manf.discManufacturingInfo, 2048); break; -- 1.7.9.5