If (!DeviceIoControl(hDevice, IOCTL_DISK_GET_DRIVE_LAYOUT_EX, NULL, 0, (void*)&dli, sizeof(dli), &bytesReturned, NULL)) Inspired of an answer from this post: How-to-call-deviceiocontrol-to-retrieve-the-amount-of-memory-it-needs DRIVE_LAYOUT_INFORMATION_EX dli Error %ld.\n", GetLastError ()) Įven if this post is a bit old, I found another way to get a fully populated PartitionEntry without creating a tricky struct. Wprintf(L"Partition Count = %ld\n", pdg.PartitionCount) Wprintf(L"Partition Style = %I64d\n", pdg.PartitionStyle) Wprintf(L"Drive path = %ws\n", wszDrive) IOCTL_DISK_GET_DRIVE_LAYOUT_EX, // dwIoControlCodeĭRIVE_LAYOUT_INFORMATION_EX pdg // disk drive partition structureīOOL bResult = FALSE // generic results flagīResult = GetDriveParition (wszDrive, &pdg) If (hDevice = INVALID_HANDLE_VALUE) // cannot open the drive HDevice = CreateFileW(wszPath, // drive to open HANDLE hDevice = INVALID_HANDLE_VALUE // handle to the drive to be examined #define wszDrive L"\\\\.\\PhysicalDrive6"īOOL GetDriveParition(LPWSTR wszPath, DRIVE_LAYOUT_INFORMATION_EX *pdg) If people could take a look at my code and tell me what they think I did wrong it would be much appreciated. I am using Microsoft Visual C++ Express Edition. When I debug the program is appears that the bool value is also unchanged after the "IOCTL_DISK_GET_DRIVE_LAYOUT_EX" call, meaning it is not returning the bResult value. I am trying to use the "IOCTL_DISK_GET_DRIVE_LAYOUT_EX" function, but according to my get error call my function is incorrect. I'm pretty sure at this point the best way to achieve this is through MSDN functions, microsofts inbuilt commands. I am currently trying to write a C++ program to automate retrieving information about the partitions of a sample hard-drive image, the information in question being the number of partitions on the disk and for each partition its start sector, size and and file system type.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |