1

ファイルの最後のクラスターを見つける方法を明確にする必要があります。クラスター情報を取得する方法のコード スニペットを次に示します。

hFile = CreateFile(result,                          
        GENERIC_READ | GENERIC_WRITE,   
        FILE_SHARE_READ | FILE_SHARE_WRITE,
        NULL,                           
        OPEN_EXISTING,                  
        FILE_ATTRIBUTE_NORMAL,          
        NULL);          

while (error == ERROR_MORE_DATA){

    DWORD bytesReturned;

    returns = DeviceIoControl(hfile.hanFile,
        FSCTL_GET_RETRIEVAL_POINTERS,
        &startVcn,
        sizeof(startVcn),
        &output,
        sizeof(output),
        &bytesReturned,
        NULL);
    error = GetLastError();
    DWORD lastExtentN = retrievalBuffer->ExtentCount - 1;
LONGLONG lastExtent = retrievalBuffer->Extents[lastExtentN].Lcn.QuadPart;
LONGLONG lengthOfCluster = retrievalBuffer->Extents[lastExtentN].NextVcn.QuadPart - retrievalBuffer->Extents[lastExtentN - 1].NextVcn.QuadPart;         

switch (error){

    case ERROR_HANDLE_EOF:
        //file sizes 0-1kb will return EOF error 
        cout << "ERROR_HANDLE_EOF" << endl;
        returns = true;
        break;

    case ERROR_MORE_DATA:
        cout << "ERROR_MORE_DATA" << endl;
        startVcn.StartingVcn = retrievalBuffer->Extents[0].NextVcn; 

        case NO_ERROR:

    cout << "NO_ERROR, here is some info: " << endl 
    cout << "This is the lcnextent : "<<retrievalBuffer->Extents[lastExtentN].Lcn.QuadPart << endl;
    cout << "This is the nextvnc: " << retrievalBuffer->Extents[lastExtentN].NextVcn.QuadPart << endl;
    cout << "This is the Extent count: " << retrievalBuffer->ExtentCount << endl;
    cout << "This is the Starting Vnc" << retrievalBuffer->StartingVcn.QuadPart << endl;
    cout << " The length of the cluster is: " << lengthOfCluster << endl;
    cout << " The last cluster is: " << lastExtent + lengthOfCluster - 1 << endl << endl << endl;
            break;

        default:
            cout << "Error in the code or input error" << endl;
            break;
        }
}

正しいクラスターが見つかったかどうかはわかりません。最後のクラスターを見つけるために、最初に最後のクラスターのサイズを見つけ、次に+ Extents[lastExtentN].NextVcn.QuadPart- 1Extents[lastExtentN - 1].NextVcn.QuadPartで場所を見つけました。たとえば、私の出力では次のようになります。Extents[lastExtentN].Lcn.QuadPartlengthOfCluster

This is the lcnextent : 76638
This is the nextvnc: 285
This is the Extent count: 3
This is the Starting Vnc 0
The length of the cluster is: 1
The last cluster is: 76638

私のコードと出力は意味がありますか? 出力される数値はバイト単位ですか?

4

0 に答える 0