kernel32/tests: Add a IOCTL_DVD_READ_STRUCTURE (DvdManufacturerDescriptor) test.

This commit is contained in:
Alexandre Goujon 2012-07-16 20:06:25 +02:00 committed by Alexandre Julliard
parent 27880abb97
commit 5feea8ce1a
2 changed files with 53 additions and 4 deletions

View File

@ -34,6 +34,16 @@ struct COMPLETE_DVD_LAYER_DESCRIPTOR
#include <poppack.h> #include <poppack.h>
C_ASSERT(sizeof(struct COMPLETE_DVD_LAYER_DESCRIPTOR) == 22); C_ASSERT(sizeof(struct COMPLETE_DVD_LAYER_DESCRIPTOR) == 22);
#include <pshpack1.h>
struct COMPLETE_DVD_MANUFACTURER_DESCRIPTOR
{
DVD_DESCRIPTOR_HEADER Header;
DVD_MANUFACTURER_DESCRIPTOR Descriptor;
UCHAR Padding;
};
#include <poppack.h>
C_ASSERT(sizeof(struct COMPLETE_DVD_MANUFACTURER_DESCRIPTOR) == 2053);
static HINSTANCE hdll; static HINSTANCE hdll;
static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointA)(LPCSTR, LPSTR, DWORD); static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointA)(LPCSTR, LPSTR, DWORD);
static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointW)(LPCWSTR, LPWSTR, DWORD); static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointW)(LPCWSTR, LPWSTR, DWORD);
@ -750,6 +760,7 @@ static void test_dvd_read_structure(HANDLE handle)
DVD_LAYER_DESCRIPTOR dvdLayerDescriptor; DVD_LAYER_DESCRIPTOR dvdLayerDescriptor;
struct COMPLETE_DVD_LAYER_DESCRIPTOR completeDvdLayerDescriptor; struct COMPLETE_DVD_LAYER_DESCRIPTOR completeDvdLayerDescriptor;
DVD_COPYRIGHT_DESCRIPTOR dvdCopyrightDescriptor; DVD_COPYRIGHT_DESCRIPTOR dvdCopyrightDescriptor;
struct COMPLETE_DVD_MANUFACTURER_DESCRIPTOR completeDvdManufacturerDescriptor;
dvdReadStructure.BlockByteOffset.QuadPart = 0; dvdReadStructure.BlockByteOffset.QuadPart = 0;
dvdReadStructure.SessionId = 0; dvdReadStructure.SessionId = 0;
@ -839,6 +850,31 @@ static void test_dvd_read_structure(HANDLE handle)
&dvdCopyrightDescriptor, i, &nbBytes, NULL); &dvdCopyrightDescriptor, i, &nbBytes, NULL);
ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "IOCTL_DVD_READ_STRUCTURE should have failed %d %u\n", ret, GetLastError()); 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) static void test_cdrom_ioctl(void)

View File

@ -231,6 +231,13 @@ typedef struct
} internal_dvd_layer_descriptor; } internal_dvd_layer_descriptor;
C_ASSERT(sizeof(internal_dvd_layer_descriptor) == 22); 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_ReadTOC(int, int, CDROM_TOC*);
static NTSTATUS CDROM_GetStatusCode(int); static NTSTATUS CDROM_GetStatusCode(int);
@ -2595,9 +2602,12 @@ static NTSTATUS DVD_ReadStructure(int dev, const DVD_READ_STRUCTURE *structure,
case DvdManufacturerDescriptor: 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; break;
@ -2620,7 +2630,7 @@ static NTSTATUS DVD_ReadStructure(int dev, const DVD_READ_STRUCTURE *structure,
internal_dvd_layer_descriptor *xlayer; internal_dvd_layer_descriptor *xlayer;
PDVD_COPYRIGHT_DESCRIPTOR copy; PDVD_COPYRIGHT_DESCRIPTOR copy;
PDVD_DISK_KEY_DESCRIPTOR disk_key; PDVD_DISK_KEY_DESCRIPTOR disk_key;
PDVD_MANUFACTURER_DESCRIPTOR manf; internal_dvd_manufacturer_descriptor *manf;
} nt_desc; } nt_desc;
nt_desc.layer = layer; nt_desc.layer = layer;
@ -2705,8 +2715,11 @@ static NTSTATUS DVD_ReadStructure(int dev, const DVD_READ_STRUCTURE *structure,
break; break;
case DvdManufacturerDescriptor: case DvdManufacturerDescriptor:
nt_desc.manf->Header.Length = 0x0802;
nt_desc.manf->Header.Reserved[0] = 0;
nt_desc.manf->Header.Reserved[1] = 0;
memcpy( memcpy(
nt_desc.manf->ManufacturingInformation, nt_desc.manf->Descriptor.ManufacturingInformation,
desc.manf.discManufacturingInfo, desc.manf.discManufacturingInfo,
2048); 2048);
break; break;