STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR structure
Used in conjunction with the IOCTL_STORAGE_QUERY_PROPERTY control code to retrieve the storage access alignment descriptor data for a device.
Syntax
typedef struct _STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR { DWORD Version; DWORD Size; DWORD BytesPerCacheLine; DWORD BytesOffsetForCacheAlignment; DWORD BytesPerLogicalSector; DWORD BytesPerPhysicalSector; DWORD BytesOffsetForSectorAlignment; } STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR, *PSTORAGE_ACCESS_ALIGNMENT_DESCRIPTOR;
Members
- Version
-
Contains the size of this structure, in bytes. The value of this member will change as members are added to the structure.
- Size
-
Specifies the total size of the data returned, in bytes. This may include data that follows this structure.
- BytesPerCacheLine
-
The number of bytes in a cache line of the device.
- BytesOffsetForCacheAlignment
-
The address offset necessary for proper cache access alignment, in bytes.
- BytesPerLogicalSector
-
The number of bytes in a logical sector of the device.
- BytesPerPhysicalSector
-
The number of bytes in a physical sector of the device.
- BytesOffsetForSectorAlignment
-
The logical sector offset within the first physical sector where the first logical sector is placed, in bytes.
Example: Offset = 3 Logical sectors
+---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |LBA |##|##|##|00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17| +---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |Physical | | | ... |Sector | 0 | 1 | 2 +---------+-----------------------+-----------------------+---------------
In this example,
BytesOffsetForSectorAlignment = 3 * BytesPerLogicalSector.
Examples
The following sample code retrieves a STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR structure and displays the physical sector size and the logical sector size if it differs from the physical sector size.
#include <windows.h>
#include <stdio.h>
DWORD DetectSectorSize( WCHAR * devName, PSTORAGE_ACCESS_ALIGNMENT_DESCRIPTOR pAlignmentDescriptor);
DWORD wmain()
{
DWORD Error = NO_ERROR;
STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR Alignment = {0};
WCHAR szDisk[] = L"\\\\.\\PhysicalDrive0";
Error = DetectSectorSize(szDisk, &Alignment);
if (Error)
{
wprintf(L"Error %lu encountered while querying alignment.\n", Error);
return Error;
}
wprintf(L"Disk %s Properties\n", (WCHAR*) szDisk);
if (Alignment.BytesPerLogicalSector < Alignment.BytesPerPhysicalSector)
{
wprintf(L" Emulated sector size is %lu bytes.\n", Alignment.BytesPerLogicalSector);
wprintf(L" Physical sector size is %lu bytes.\n", Alignment.BytesPerPhysicalSector);
}
else
{
wprintf(L" Physical sector size is %lu bytes.\n", Alignment.BytesPerPhysicalSector);
}
return 0;
}
DWORD DetectSectorSize( WCHAR * devName, PSTORAGE_ACCESS_ALIGNMENT_DESCRIPTOR pAlignmentDescriptor)
{
DWORD Bytes = 0;
BOOL bReturn = FALSE;
DWORD Error = NO_ERROR;
STORAGE_PROPERTY_QUERY Query;
ZeroMemory(&Query, sizeof(Query));
HANDLE hFile = CreateFileW( devName,
STANDARD_RIGHTS_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hFile==INVALID_HANDLE_VALUE)
{
Error=GetLastError();
return Error;
}
Query.QueryType = PropertyStandardQuery;
Query.PropertyId = StorageAccessAlignmentProperty;
bReturn = DeviceIoControl( hFile,
IOCTL_STORAGE_QUERY_PROPERTY,
&Query,
sizeof(STORAGE_PROPERTY_QUERY),
pAlignmentDescriptor,
sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR),
&Bytes,
NULL);
if (bReturn == FALSE)
{
Error=GetLastError();
}
CloseHandle(hFile);
return Error;
}
Requirements
|
Minimum supported client | Windows Vista [desktop apps only] |
|---|---|
|
Minimum supported server | Windows Server 2008 [desktop apps only] |
|
Header |
|
See also
Send comments about this topic to Microsoft
Build date: 4/16/2013