aboutsummaryrefslogtreecommitdiff
path: root/zenserver/experimental/usnjournal.h
blob: 910eb7d06df0af1cd9f1808f09b175af4bddffa5 (plain) (blame)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#if ZEN_PLATFORM_WINDOWS

#	include <zencore/windows.h>
#	include <zencore/zencore.h>

ZEN_THIRD_PARTY_INCLUDES_START
#	include <winioctl.h>
ZEN_THIRD_PARTY_INCLUDES_END

#	include <filesystem>

namespace zen {

class UsnJournalReader
{
public:
	UsnJournalReader();
	~UsnJournalReader();

	bool Initialize(std::filesystem::path VolumePath);

private:
	void*					 m_VolumeHandle;
	READ_USN_JOURNAL_DATA_V1 m_ReadUsnJournalData;
	bool					 m_IncursSeekPenalty = true;

	uint8_t* m_JournalReadBuffer = nullptr;
	uint64_t m_ReadBufferSize	 = 64 * 1024;

	struct Frn
	{
		uint8_t IdBytes[16];

		Frn() = default;

		Frn(const FILE_ID_128& Rhs) { memcpy(IdBytes, Rhs.Identifier, sizeof IdBytes); }
		Frn& operator=(const FILE_ID_128& Rhs) { memcpy(IdBytes, Rhs.Identifier, sizeof IdBytes); }

		Frn(const uint64_t& Rhs)
		{
			memcpy(IdBytes, &Rhs, sizeof Rhs);
			memset(&IdBytes[8], 0, 8);
		}

		Frn& operator=(const uint64_t& Rhs)
		{
			memcpy(IdBytes, &Rhs, sizeof Rhs);
			memset(&IdBytes[8], 0, 8);
		}

		std::strong_ordering operator<=>(const Frn&) const = default;
	};

	enum class FileSystemType
	{
		ReFS,
		NTFS
	};

	FileSystemType m_FileSystemType = FileSystemType::NTFS;
};

}  // namespace zen

#endif	// ZEN_PLATFORM_WINDOWS