-
Notifications
You must be signed in to change notification settings - Fork 2
/
EFAT.cpp
32 lines (28 loc) · 890 Bytes
/
EFAT.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "EFAT.h"
#include <iostream>
#include "windows.h"
#include "stdio.h"
using namespace std;
bool EFAT::ReadClusterSize()
{
BYTE sector[512];
DWORD bytesRead;
DWORD bytesToRead = sizeof(sector);
LARGE_INTEGER sectorSizeOffset;
sectorSizeOffset.QuadPart = 0;
if (!SetFilePointerEx(fileHandler, sectorSizeOffset, NULL, FILE_BEGIN)) {
throw std::invalid_argument("Set FilePointer error");
CloseHandle(fileHandler);
return false;
}
if (!ReadFile(fileHandler, sector, bytesToRead, &bytesRead, NULL))
{
throw std::invalid_argument("ReadFile error");
CloseHandle(fileHandler);
return false;
}
unsigned int sectorSize = pow (2, sector[108]); //ðàçìåð ñåêòîðà
unsigned int classCoeff = pow (2, sector[109]); //êëàñòåðíûé ìíîæèòåëü
clusterSize = sectorSize * classCoeff;
return true;
}