Skip to content
API Documentation
BastionGuard™
anonymous_namespace{ntfs_probe.cpp} Namespace Reference

Functions

uint16_t le16 (const unsigned char *p)
uint64_t le64 (const unsigned char *p)
bool is_ntfs_boot_sector (const std::array< unsigned char, 512 > &sector)
uint64_t record_size_from_descriptor (int8_t descriptor, uint64_t cluster_size)

Variables

constexpr uint64_t SECTOR_SIZE = 512ull

Function Documentation

◆ is_ntfs_boot_sector()

bool anonymous_namespace{ntfs_probe.cpp}::is_ntfs_boot_sector ( const std::array< unsigned char, 512 > & sector)

Definition at line 28 of file ntfs_probe.cpp.

28 {
29 return std::string(reinterpret_cast<const char*>(sector.data() + 3), 8) == "NTFS " &&
30 sector[510] == 0x55 && sector[511] == 0xAA;
31}

References is_ntfs_boot_sector().

Referenced by is_ntfs_boot_sector().

◆ le16()

uint16_t anonymous_namespace{ntfs_probe.cpp}::le16 ( const unsigned char * p)

Definition at line 13 of file ntfs_probe.cpp.

13 {
14 return static_cast<uint16_t>(p[0]) | (static_cast<uint16_t>(p[1]) << 8);
15}

References le16().

Referenced by le16().

◆ le64()

uint64_t anonymous_namespace{ntfs_probe.cpp}::le64 ( const unsigned char * p)

Definition at line 17 of file ntfs_probe.cpp.

17 {
18 return static_cast<uint64_t>(p[0]) |
19 (static_cast<uint64_t>(p[1]) << 8) |
20 (static_cast<uint64_t>(p[2]) << 16) |
21 (static_cast<uint64_t>(p[3]) << 24) |
22 (static_cast<uint64_t>(p[4]) << 32) |
23 (static_cast<uint64_t>(p[5]) << 40) |
24 (static_cast<uint64_t>(p[6]) << 48) |
25 (static_cast<uint64_t>(p[7]) << 56);
26}

References le64().

Referenced by le64().

◆ record_size_from_descriptor()

uint64_t anonymous_namespace{ntfs_probe.cpp}::record_size_from_descriptor ( int8_t descriptor,
uint64_t cluster_size )

Definition at line 33 of file ntfs_probe.cpp.

33 {
34 if (descriptor > 0) {
35 return static_cast<uint64_t>(descriptor) * cluster_size;
36 }
37 // Bug #3/#4 fix: descriptor==0 means invalid; descriptor < 0 is shift exponent.
38 // Range valid for NTFS: 1..30 (records from 2 bytes to 1 GiB).
39 if (descriptor == 0) return 0;
40 const int exponent = -static_cast<int>(descriptor);
41 if (exponent >= 1 && exponent <= 30) {
42 return 1ull << exponent;
43 }
44 return 0; // invalid: caller must reject volume
45}

References record_size_from_descriptor().

Referenced by record_size_from_descriptor().

Variable Documentation

◆ SECTOR_SIZE

uint64_t anonymous_namespace{ntfs_probe.cpp}::SECTOR_SIZE = 512ull
constexpr

Definition at line 11 of file ntfs_probe.cpp.