-
Notifications
You must be signed in to change notification settings - Fork 11
/
DiskImgFile32.h
executable file
·176 lines (131 loc) · 6.98 KB
/
DiskImgFile32.h
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// DiskImgFile32.h: interface for the DiskImgFile32 class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DISKIMGFILE32_H__82F327B6_EE20_4D24_812A_1E4D68AADA45__INCLUDED_)
#define AFX_DISKIMGFILE32_H__82F327B6_EE20_4D24_812A_1E4D68AADA45__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "DiskImgFile.h"
class DiskImgFile32 : public DiskImgFile
{
public:
DiskImgFile32();
virtual ~DiskImgFile32();
public:
virtual UINT RelatAddrToCluster(IN UINT uRetAddr); // 映射函数从实际实际偏移位置到簇
virtual UINT ClusterToRelatAddr(IN UINT uCluNm); // 映射函数从簇到实际偏移位置
BOOL SetCurrentDirectory(IN LPCTSTR lptPathName); // 设置当前路径
BOOL ParaDirectoryFromStr(IN LPCTSTR lptDirName, OUT vector<Fat_Directory>& fatDir);
BOOL GetDirectoryTab(OUT Fat_Directory& dir, IN UINT clus, IN LPCTSTR longName) ;
BOOL CreateDirectoryEx(IN LPCTSTR lpFullDir);
UINT GetFirstFreeClusNum(); // 返回空闲的簇号,从2开始
BOOL GetDirectoryTabEx(OUT Fat_Directory& dir, OUT LPTSTR lptLongName, IN OUT INT& nIndex); // 返回当前目录下第nIndex个目录
BOOL GetDirectoryTab(OUT Fat_Directory& dir, IN OUT INT& nIndex); // 返回当前目录下第nIndex个目录
// BOOL GetDirectoryTab(OUT Fat_Directory& dir, IN LPCSTR longName); // 返回当前目录长名为longName 的目录
BOOL GetDirectoryTabEx(OUT Fat_Directory& dir, IN UINT clus, OUT LPTSTR lptLongName, IN OUT INT& nIndex); // 返回簇clus下目录下第nIndex个目录
// BOOL GetDirectoryTab(OUT Fat_Directory& dir, IN UINT clus, IN OUT INT& nIndex); // 返回簇clus下目录下第nIndex个目录
// BOOL GetDirectoryTab(OUT Fat_Directory& dir, IN UINT clus, IN LPCSTR longName); // 返回簇clus下目录下长名为longName的目录
BOOL TrimDirEntrySpace(); // 整理删除文件或者目录后FAT_Directory Entries的空间
//////////////////////////////////////////////////////////////////////////
// GetFreeSpace
public:
//////////////////////////////////////////////////////////////////////////
// inside operator
BOOL ImgCreateDirectory(IN LPCTSTR lptDirName); // 在当前目录下建立目录函数 --
BOOL ImgCreateFile(IN const LPCTSTR lptFileName,
IN PBYTE pbuffer,
IN const BYTE bFileAttr,
IN const UINT nSize,
HANDLE& hFile); // 创建文件函数
BOOL ImgDeleteDirectory(IN LPCTSTR lptDirName); // 当前目录下删除目录函数
BOOL ImgDeleteDirectory(UINT clusNum); // 删除在该簇开始地方的目录 递归调用
BOOL ImgDeleteFile(IN LPCTSTR lptFileName); // 当前目录下删除文件函数
BOOL ImgMoveFile(IN LPCSTR lpFileName,
IN LPCSTR lpSrcDir,
IN LPCSTR lpDesFileName,
IN LPCSTR lpDesDir); // 移动文件函数
BOOL ImgMoveDirectory(IN LPCSTR lpSrcDir,
IN LPCSTR lpDesDir); // 移动目录函数
// BOOL ImgGetFileStaus(IN LPCSTR lpFileName,
// OUT ImgFileStatus& status);
// BOOL ImgOpenFile(IN LPCSTR lpFileName, // 打开文件函数
// OUT PBYTE pBuffer,
// IN DWORD nBufferLen) ;
//////////////////////////////////////////////////////////////////////////
// virtual Function
virtual int BytesPerSec() {return _imgBpb.BPB_BytsPerSec;}
virtual int SecPerClus() {return _imgBpb.BPB_SecPerClus;}
virtual int RsvdSecCnt() {return _imgBpb.BPB_RsvdSecCnt;}
virtual int RootEntCnt() {return _imgBpb.BPB_RootEntCnt;}
virtual int TolSec() {return _imgBpb.BPB_TotSec16 + _imgBpb.BPB_TotSec32;}
virtual int FatSz() {return _imgBpb.BPB_FATSz16;}
virtual UINT FatType() {return FAT32_TYPE;}
virtual BOOL SetVolLabel(LPCSTR lpVolLabel);
virtual BOOL GetVolLabel(LPSTR lpLabel);
virtual void InitializeClus(IN UINT clusNum); // 初始化簇
virtual BOOL SetClus(IN UINT clusNum, IN UINT nValue); // 设置簇链
virtual BOOL SetClusEx(IN UINT StartClusNum, IN UINT nNeedMoreClus); // 设置簇链 , Add by Joelee
virtual BOOL SetClusFreeStatus(IN UINT StartClusNum);
virtual DWORD SetFilePointerEx(HANDLE hFile, // handle of file
LONG lDistanceToMove, // number of bytes to move file pointer
PLONG lpDistanceToMoveHigh, // pointer to high-order DWORD of distance to move
DWORD dwMoveMethod // how to move
);
virtual BOOL ReadFileEx(HANDLE hFile, OUT PBYTE pBuffer, IN DWORD nBufferLen, OUT PDWORD nRead);
virtual BOOL WriteFileEx(HANDLE hFile, IN PBYTE pBuffer, IN DWORD nBufferLen,OUT PDWORD nWrite);
virtual BOOL RenameFileEx(LPCSTR lpSrcName, LPCSTR lpNewFileName);
virtual HANDLE CreateFileEx(LPCTSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile
);
virtual HANDLE FindFirstFile(LPCTSTR lptFileName, // pointer to name of file to search for
LPWIN32_FIND_DATA lpFindFileData // pointer to returned information
);
/*
virtual HANDLE FindFirstFileEx(
LPCSTR lpFileName, // pointer to the name of the file to search for
FINDEX_INFO_LEVELS fInfoLevelId, // information level of the returned data
LPVOID lpFindFileData, // pointer to the returned information
FINDEX_SEARCH_OPS fSearchOp, // type of filtering to perform
LPVOID lpSearchFilter, // pointer to search criteria
DWORD dwAdditionalFlags // additional search control flags
);
*/
virtual BOOL FindNextFile(
HANDLE hFindFile, // handle to search
LPWIN32_FIND_DATA lpFindFileData // pointer to structure for data on found file
) ;
virtual BOOL FindClose(HANDLE hFindFile);
//////////////////////////////////////////////////////////////////////////
// GetFreeSpace
virtual LPTSTR RootPath();
virtual DWORD SectorsPerCluster();
virtual DWORD BytesPerSector();
virtual DWORD NumberOfFreeClusters();
virtual UINT ImgFileType();
virtual LPTSTR GetMirrorFileName();
virtual LONGLONG TotoleSpace();
//////////////////////////////////////////////////////////////////////////
// Outside Operator
BOOL CreateImageFile(IN LPCSTR lpFileName, IN UINT fatType = FAT32_TYPE, IN LONGLONG diskSize = 536870912); // 536870912 = 256M // 创建镜像文件
BOOL FormatImgFile(IN LPCSTR lpVolLab, IN UINT fatType = FAT16_TYPE, IN LONGLONG diskSize = 536870912); // 格式化镜像文件
void Iinitialize(LPCSTR lpVolab, IN UINT fatType, IN LONGLONG diskSize); // 初始化
BOOL OpenImgFile(IN LPCSTR lpFileName, IN LONGLONG diskSize = 536870912 ); // 打开镜像文件
BOOL RefreshFatTable();
//BOOL IsFileExist(LPCSTR lpFileName);
BootSector_BPB32 _imgBpb; //保留扇区信息
protected:
//virtual BOOL CalcNewPos(HANDLE hFile);
virtual BOOL IniWrite(HANDLE hFile , DWORD dwWriteLen);
private:
//BootSector_BPB32 _imgBpb_sFat; //保留扇区信息
Fat_FsInfo _fsInfo;
// vector<DWORD> _fats;
BYTE* _imgContent;
};
#endif // !defined(AFX_DISKIMGFILE32_H__82F327B6_EE20_4D24_812A_1E4D68AADA45__INCLUDED_)