Post by Lynn McGuireCan someone try my DiskId32 program on their Windows 64 PC
and tell me what happened ?
http://www.winsim.com/diskid32/diskid32.html
BTW, does Visual C++ 2003 work well on Windows 64 yet ?
Thanks,
Lynn McGuire
In a small application I use a very small code part of diskid32 written by Lynn
McGuire, but now this application had a problem with a "64bit windows
8" system.
I search and found a memory violation in the part of diskid32.cpp during usage
of IOCTL_STORAGE_QUERY_PROPERTY.
I don't check it (because it is not in use by me), but I think the call to
IOCTL_DISK_GET_DRIVE_GEOMETRY_EX has the same problem.
I use a small part of your freeware and I think it's fair to tell you the
problem, a lot of internet threads show discussion about the code of diskid32.
//
// Problem in DISKID32.cpp
// There is a "buffer" defined as array, but in DeviceIoControl there
is given a pointer to the array which is also a pointer to memory // So, the
DeviceIoControl writes possibly into invalid memory //
//-----------------------------------------------------------------
// Wrong (original) code
//-----------------------------------------------------------------
char buffer [10000];
memset ((void *) & query, 0, sizeof (query)); query.PropertyId =
StorageDeviceProperty; query.QueryType = PropertyStandardQuery;
memset (buffer, 0, sizeof (buffer));
if (DeviceIoControl (hPhysicalDriveIOCTL, IOCTL_STORAGE_QUERY_PROPERTY,
& query,
sizeof (query),
& buffer,
sizeof (buffer),
& cbBytesReturned, NULL))
{
STORAGE_DEVICE_DESCRIPTOR * descrip = (STORAGE_DEVICE_DESCRIPTOR *) &
buffer;
...
//-----------------------------------------------------------------
// With following fix, the defined memory is really used
//-----------------------------------------------------------------
char buffer [10000];
memset ((void *) & query, 0, sizeof (query)); query.PropertyId =
StorageDeviceProperty; query.QueryType = PropertyStandardQuery;
memset (buffer, 0, sizeof (buffer));
if (DeviceIoControl (hPhysicalDriveIOCTL, IOCTL_STORAGE_QUERY_PROPERTY,
& query,
sizeof (query),
buffer, //
<<<<<<<<<<<<<<<<< without
&, because buffer is a pointer to 10000 chars
sizeof (buffer),
& cbBytesReturned, NULL))
{
STORAGE_DEVICE_DESCRIPTOR * descrip = (STORAGE_DEVICE_DESCRIPTOR *) buffer; //
<<<<<<<<<<<<<<<<< without
&
//... see IOCTL_DISK_GET_DRIVE_GEOMETRY_EX and access also
Thank you for alerting me to the coding error.