Answer the question
In order to leave comments, you need to log in
C++ What parameters does the function take?
ULONGLONG *GetFileClusters(
LPCWSTR lpFileName, //путь к файлу
ULONG ClusterSize, //размер кластера (какое значение сюда передавать?)
ULONG *ClCount, //???
ULONG *FileSize //размер файла
)
{
HANDLE hFile; //дескриптор файла
ULONG OutSize; //
ULONG Bytes, Cls, CnCount, r; //???
ULONGLONG *Clusters = NULL; //список кластеров
BOOLEAN Result = FALSE;
LARGE_INTEGER PrevVCN, Lcn; //???
STARTING_VCN_INPUT_BUFFER InBuf; //???
PRETRIEVAL_POINTERS_BUFFER OutBuf; //???
//получение доступа к диску:
hFile = CreateFile(lpFileName, FILE_READ_ATTRIBUTES,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL, OPEN_EXISTING, 0, 0);
//при успехе доступа:
if (hFile != INVALID_HANDLE_VALUE)
{
//
*FileSize = GetFileSize(hFile, NULL); //получение размера файла
OutSize = sizeof(RETRIEVAL_POINTERS_BUFFER) + (*FileSize / ClusterSize) * sizeof(OutBuf->Extents); //???
//OutBuf = malloc(OutSize); //выделение памяти
InBuf.StartingVcn.QuadPart = 0; //???
if (DeviceIoControl(hFile, FSCTL_GET_RETRIEVAL_POINTERS, &InBuf,
sizeof(InBuf), OutBuf, OutSize, &Bytes, NULL))
{
*ClCount = (*FileSize + ClusterSize - 1) / ClusterSize; //???
//Clusters = malloc(*ClCount * sizeof(ULONGLONG));
PrevVCN = OutBuf->StartingVcn; //???
for (r = 0, Cls = 0; r < OutBuf->ExtentCount; r++)
{
Lcn = OutBuf->Extents[r].Lcn; //???
for (CnCount = OutBuf->Extents[r].NextVcn.QuadPart - PrevVCN.QuadPart;
CnCount; CnCount--, Cls++, Lcn.QuadPart++) Clusters[Cls] = Lcn.QuadPart;
PrevVCN = OutBuf->Extents[r].NextVcn; //???
}
}
//
free(OutBuf); //???
CloseHandle(hFile);
}
//вернуть список кластеров:
return Clusters;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question