NTFS下的文件粉碎机.docx

上传人:b****1 文档编号:2475271 上传时间:2022-10-29 格式:DOCX 页数:16 大小:19.40KB
下载 相关 举报
NTFS下的文件粉碎机.docx_第1页
第1页 / 共16页
NTFS下的文件粉碎机.docx_第2页
第2页 / 共16页
NTFS下的文件粉碎机.docx_第3页
第3页 / 共16页
NTFS下的文件粉碎机.docx_第4页
第4页 / 共16页
NTFS下的文件粉碎机.docx_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

NTFS下的文件粉碎机.docx

《NTFS下的文件粉碎机.docx》由会员分享,可在线阅读,更多相关《NTFS下的文件粉碎机.docx(16页珍藏版)》请在冰豆网上搜索。

NTFS下的文件粉碎机.docx

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;IdxNtfs.UsaCount;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;IdxNtfs.UsaCount;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=ZeroSectorNum);Idx+=ZeroSectorNum){

    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;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 职业规划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1