NTFS下的文件粉碎机.docx
- 文档编号:2475271
- 上传时间:2022-10-29
- 格式:DOCX
- 页数:16
- 大小:19.40KB
NTFS下的文件粉碎机.docx
《NTFS下的文件粉碎机.docx》由会员分享,可在线阅读,更多相关《NTFS下的文件粉碎机.docx(16页珍藏版)》请在冰豆网上搜索。
NTFS下的文件粉碎机
代码很经典(不过很多都是REACTOS里面的)~~学习学习:
(多谢pixiebox了~~)
#include
#include
#include
#include"ntfs.h"
ULONG BytesPerFileRecord;
UINT BytesPerCluster;
BOOT_BLOCK BootBlk;
PFILE_RECORD_HEADERMFT;
HANDLE hVolume;
FILE *pFLog;
#defineFIXOFFSET(x,y)((CHAR*)(x)+(y))
BOOLBitSet(PUCHARBitmap,ULONGIdx)
{
return(Bitmap[Idx>>3]&(1<<(Idx&7)))!
=0;
}
VOIDFixupUpdateSequenceArray(PFILE_RECORD_HEADERFileRecord)
{
PUSHORTUsAry=PUSHORT(FIXOFFSET(FileRecord,FileRecord->Ntfs.UsaOffset));
PUSHORTSector=PUSHORT(FileRecord);
for(ULONGIdx=1;Idx
//Note:
if(UsAry[0]!
=Sector[255])thenthissectoriscorruptorbroken
Sector[255]=UsAry[Idx];
Sector+=256;
}
}
VOIDZeroSequenceArray(PFILE_RECORD_HEADERFileRecord)
{
PUSHORTUsAry=PUSHORT(FIXOFFSET(FileRecord,FileRecord->Ntfs.UsaOffset));
for(ULONGIdx=1;Idx
UsAry[Idx]=0x3030;
}
}
VOIDReadSector(ULONGLONGSector,ULONGCnt,PVOIDBuffer)
{
ULARGE_INTEGEROffset;
OVERLAPPEDOverlap={0};
ULONGReadBytes,CntIdx=0,NeedReadByte=Cnt*BootBlk.BytesPerSector;
Offset.QuadPart =Sector*BootBlk.BytesPerSector;//Assignthephysicalposition.
Overlap.Offset =Offset.LowPart; //SetpositiontoOverlap.
Overlap.OffsetHigh=Offset.HighPart;
ReadFile(hVolume,Buffer,NeedReadByte,&ReadBytes,&Overlap);
if(ReadBytes!
=NeedReadByte){
//if(GetLastError()==ERROR_WORKING_SET_QUOTA||
// GetLastError()==ERROR_NO_SYSTEM_RESOURCES){
while(CntIdx Overlap.Offset =Offset.LowPart; //SetpositiontoOverlap. Overlap.OffsetHigh=Offset.HighPart; ReadFile(hVolume,Buffer,BootBlk.BytesPerSector,&ReadBytes,&Overlap); if(ReadBytes! =BootBlk.BytesPerSector){ printf("ReadSectorfailed: %d: %d: %d\n",Offset.LowPart,Cnt*BootBlk.BytesPerSector,ReadBytes); return; } Buffer=(UCHAR*)Buffer+BootBlk.BytesPerSector; Offset.QuadPart+=BootBlk.BytesPerSector; //Updatethephysicalposition. ++CntIdx; } //}else{ //printf("Error%d...\n",GetLastError()); //} } return; } VOIDReadLCN(ULONGLONGLCN,ULONGCnt,PVOIDBuffer) { ReadSector(LCN*BootBlk.SectorsPerCluster,Cnt*BootBlk.SectorsPerCluster,Buffer); } VOIDWriteSector(ULONGLONGSector,ULONGCnt,PVOIDBuffer) { ULARGE_INTEGEROffset; OVERLAPPEDOverlap={0}; ULONGWritten; Offset.QuadPart =Sector*BootBlk.BytesPerSector;//Assignthephysicalposition. Overlap.Offset =Offset.LowPart; //SetpositiontoOverlap. Overlap.OffsetHigh=Offset.HighPart; WriteFile(hVolume,Buffer,Cnt*BootBlk.BytesPerSector,&Written,&Overlap); if(Written! =Cnt*BootBlk.BytesPerSector)printf("Wrotefailed: %d: %d: %d\n",Overlap.Offset,Cnt*BootBlk.BytesPerSector,Written); } VOIDWriteLCN(ULONGLONGLCN,ULONGCnt,PVOIDBuffer) { WriteSector(LCN*BootBlk.SectorsPerCluster,Cnt*BootBlk.SectorsPerCluster,Buffer); } VOIDZeroLCN(ULONGLONGLCN,ULONGCnt) { ULONGLONGZeroSectorNum=512; BYTE*p512Sector=newBYTE[(UINT)BootBlk.BytesPerSector*(UINT)ZeroSectorNum]; ULONGLONGSectorNum=Cnt*(UINT)BootBlk.SectorsPerCluster; ULONGLONGSectorSrtIdx=LCN*BootBlk.SectorsPerCluster,Idx; ULONGLONGSectorEndIdx=SectorSrtIdx+SectorNum; printf("->SectorStartIndex: %d,ZeroSectornumberis%d\n",(UINT)SectorSrtIdx,(UINT)SectorNum); memset(p512Sector,'0',(UINT)BootBlk.BytesPerSector*(UINT)ZeroSectorNum); if(p512Sector){ Idx=SectorSrtIdx; while((SectorNum>0)&&(ZeroSectorNum>0)){ printf("\n%3d--->",ZeroSectorNum); for(;(Idx WriteSector(Idx,(UINT)ZeroSectorNum,p512Sector); SectorNum-=ZeroSectorNum; printf("."); } ZeroSectorNum>>=1; } if(SectorNum){ assert(SectorNum==1); WriteSector(Idx,1,p512Sector); printf("\n%3d--->.",1); } printf("\n"); delete[]p512Sector; } } ULONGAttributeLength(PATTRIBUTEAttr) { returnAttr->Nonresident==FALSE ? PRESIDENT_ATTRIBUTE(Attr)->ValueLength : ULONG(PNONRESIDENT_ATTRIBUTE(Attr)->DataSize); } ULONGAttributeLengthAllocated(PATTRIBUTEAttr) { returnAttr->Nonresident==FALSE ? PRESIDENT_ATTRIBUTE(Attr)->ValueLength : ULONG(PNONRESIDENT_ATTRIBUTE(Attr)->AllocatedSize); } ULONGRunLength(PUCHARRun) { return(*Run&0xf)+((*Run>>4)&0xf)+1; } ULONGLONGRunCount(PUCHARRun) { UCHARIdx=*Run&0xF; //GetEndIndex. ULONGLONGCnt=0; for(;Idx>0;Idx--) Cnt=(Cnt<<8)+Run[Idx]; returnCnt; } LONGLONGRunLCN(PUCHARRun) { UCHARVCNNumEndIdx=*Run&0xf;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- NTFS 文件 粉碎机
![提示](https://static.bdocx.com/images/bang_tan.gif)