S
S
starkdm2015-09-02 20:40:39
Programming
starkdm, 2015-09-02 20:40:39

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

1 answer(s)
M
Maxim, 2015-09-02
@lbyte

LPCWSTR lpFileName, //path to file
ULONG ClusterSize, //cluster size (what value to pass here?)
ULONG *ClCount, //???
ULONG *FileSize //file size
Everything is in the comments, and it's not hard to guess from the name of the argument.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question