summaryrefslogtreecommitdiff
path: root/src/ntfsx.h
blob: 586b36b1355c48a3b8cb7e1fa2ff7a2d5e820459 (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// 
// AUTHOR
// N. Nielsen
//
// VERSION
// 0.7
// 
// LICENSE
// This software is in the public domain.
//
// The software is provided "as is", without warranty of any kind,
// express or implied, including but not limited to the warranties
// of merchantability, fitness for a particular purpose, and
// noninfringement. In no event shall the author(s) be liable for any
// claim, damages, or other liability, whether in an action of
// contract, tort, or otherwise, arising from, out of, or in connection
// with the software or the use or other dealings in the software.
// 
// SUPPORT
// Send bug reports to: <nielsen@memberwebs.com>
//


// ntfsx
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_NTFSX__9363C7D2_D3CC_4D49_BEE0_27AD025670F2__INCLUDED_)
#define AFX_NTFSX__9363C7D2_D3CC_4D49_BEE0_27AD025670F2__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "ntfs.h"

class NTFS_DataRun
{
public:
	NTFS_DataRun(byte* pClus, byte* pDataRun);
	~NTFS_DataRun()
		{ refrelease(m_pMem); }

	bool First();
	bool Next();

	uint64 m_firstCluster;
	uint64 m_numClusters;
	bool m_bSparse; 

protected:
	byte* m_pMem;
	byte* m_pDataRun;
	byte* m_pCurPos;
};

class NTFS_Cluster
{
public:
	NTFS_Cluster()
		{ m_pCluster = NULL; };
	~NTFS_Cluster()
		{ Free(); }

	bool New(PartitionInfo* pInfo);
	bool Read(PartitionInfo* pInfo, uint64 begSector, HANDLE hIn);
	void Free()
		{ if(m_pCluster) refrelease(m_pCluster); }
	
	uint32 m_cbCluster;
	byte* m_pCluster;
};
	
class NTFS_Attribute
{
public:
	NTFS_Attribute(NTFS_Cluster& clus, NTFS_AttribHeader* pHeader);
	~NTFS_Attribute()
		{ refrelease(m_pMem); }

	NTFS_AttribHeader* GetHeader()
		{ return m_pHeader; }

	void* GetResidentData();
	uint32 GetResidentSize();

	NTFS_DataRun* GetDataRun();

	bool NextAttribute(uint32 attrType);


protected:
	NTFS_AttribHeader* m_pHeader;
	byte* m_pMem;
	uint32 m_cbMem;
};

class NTFS_Record : public NTFS_Cluster
{
public:
	NTFS_Record(PartitionInfo* pInfo);
	~NTFS_Record();

	bool Read(uint64 begSector, HANDLE hIn);
	NTFS_RecordHeader* GetHeader()
		{ return (NTFS_RecordHeader*)m_pCluster; }

	NTFS_Attribute* FindAttribute(uint32 attrType, HANDLE hIn);

protected:
	PartitionInfo* m_pInfo;
};

#endif // !defined(AFX_NTFSX__9363C7D2_D3CC_4D49_BEE0_27AD025670F2__INCLUDED_)