?? main.cpp
字號(hào):
/*
Command Line Tools for DOS(V32) and WINNT Prgram Main Prgram v10.1 write by 孫寶建
6-20-2004
(暫停)
*/
/*
暫停原因:
1。文件系統(tǒng)復(fù)雜,沒有時(shí)間了
以后的工作:
1。學(xué)習(xí)msdn
2。《數(shù)據(jù)恢復(fù)技術(shù)》《硬盤扇區(qū)讀寫技術(shù)-修復(fù)硬盤與恢復(fù)文件》
3。使用WINHEX
4。定義基本結(jié)構(gòu),文件系統(tǒng)類型有fat12,fat16,big fat16,fat32,big fat32
5。定義物理盤,定義分區(qū),定義邏輯盤,定義BPB
6。每一個(gè)物理盤有幾個(gè)主分區(qū),多個(gè)擴(kuò)展分區(qū)(用鏈表存),每個(gè)分區(qū)代表一個(gè)邏輯盤,一個(gè)邏輯盤包括幾種文件格式
7。兩種方法把數(shù)據(jù)裝入結(jié)構(gòu) (1)用絕對(duì)扇區(qū)號(hào) (2)用當(dāng)前的緩沖區(qū)內(nèi)容(3)文件(考慮ing)
8。詳盡的測(cè)試
*/
/*
根目錄的第一個(gè)文件的文件名就是卷標(biāo)
*/
#include "stdafx.h"
#define OUT_PUT_MSG(x) cout<<x;
#define OUT_PUT_MSG2(x, y) \
tostringstream s;\
s<< x << _T(" exception = ") << y <<endl;\
cout<< s.str() ;
#ifndef __commcpp_h
#include "commcpp.hpp"
#endif
#ifdef WIN32
#ifndef _INCLUDE_SDBG_HPP_INCLUDE
#include "sdbg.hpp"
#endif
#endif //WIN32
#ifndef _INCLUDE_SLIB_ERROR_HPP_INCLUDE
#include "slib_error.hpp"
#endif
#ifndef _INT13_H
#include "int13.hpp"
#endif
#ifndef _NTFS_H
#include "ntfs.hpp"
#endif
#ifndef _DRIVE_H
#include "drive.hpp"
#endif
#ifndef _SEARCH_H
#include "srch.hpp"
#endif
#ifndef _CMDTOOLS_H
#include "cmdtools.hpp"
#endif
#ifndef _MAIN_H
#include "main.hpp"
#endif
using namespace SLib;
#ifdef _WIN32
#ifndef _INC_CRTDBG
#include <crtdbg.h>
#endif
#endif //_WIN32
#ifdef __DJGPP__
#include <stdlib.h>
#ifndef __dj_include_go32_h_
#include <go32.h>
#endif
#endif //__DJGPP__
extern CCmdToolError g_Error;
CHAR *szCmdLine;
CHAR * pCmdLineTmp;
int main(int argc,char *argv[])
{
try
{
/*
cout<<"tagBoot32 " << sizeof(tagBoot32)<<" " <<endl
<<"tagBoot16 " << sizeof(tagBoot16)<<" " <<endl
<<"tagCluster " << sizeof(tagCluster)<<" "<<endl
<<"tagFdt " << sizeof(tagFdt)<<" "<<endl
<<"tagFdt32 " << sizeof(tagFdt32)<<" "<<endl
<<"tagHardDiskInfo " << sizeof(tagHardDiskInfo)<<" "<<endl
<<"tagInt13AddrPackage " << sizeof(tagInt13AddrPackage)<<" "<<endl
<<"tagLogicalHardDiskInfo " << sizeof(DISK_EX_INT13_INFO)<<" "<<endl
<<"tagMbr " << sizeof(tagMbr)<<" "<<endl
<<"tagPartition " << sizeof(tagPartition)<<" "<<endl
<<"tagFirstCluster " << sizeof(tagFirstCluster)<<" "<<endl;
cout<<"BOOT_BLOCK " << sizeof(BOOT_BLOCK)<<" " <<endl;
cout<<"BOOT32 " << sizeof(BOOT32)<<" " <<endl;
return 0; return 0;
*/
#ifdef _WIN32
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
//_CrtSetBreakAlloc(295);
SDbgInit(SLib::c_iSDBG_INIT_EXCEPTION_HANDLE);
#endif //_WIN32
///////////////
#ifndef _WIN32
textmode(C4350);
#endif
auto_ptr<CTools> pTools(new CTools(&g_Error));
szCmdLine=(CHAR*)new CHAR [(_MAX_PATH*sizeof(CHAR))];
auto_ptr<char >szCmdLine_p( szCmdLine);
pCmdLineTmp=(CHAR *)new CHAR[(_MAX_PATH*sizeof(CHAR))];
auto_ptr<char >pCmdLineTmp_p( pCmdLineTmp);
cout.unsetf(ios_base::dec);
cout.unsetf(ios_base::left);
cout.setf( ios_base::showbase|ios_base::hex |ios_base::uppercase| ios_base::right);
cout.fill('0') ;
memset(szCmdLine,0,(_MAX_PATH*sizeof(CHAR)));
memset(pCmdLineTmp,0,(_MAX_PATH*sizeof(CHAR)));
pTools->Init();
DWORD tmperr=pTools->m_pError->GetLastError();
if( !(tmperr==ERR_NO_ERROR||tmperr==ERR_NO_FOUND_ERROR) )
{
//cout<< endl << "Init Fail! ErrorCode=";
//cout.widen(8);
// cout<< pTools->m_pError->GetLastError() << endl;
//#ifdef _WIN32
// SDbgClose();
//#endif
pTools->m_pError->ReportAllError();
pTools->m_pError->ClearAllError();
//return 0;
}
cout<< endl<<endl
#ifdef _WIN32
<<"Toolsnt(V32 for Nt,2K,XP,2003)"
#endif //_WIN32
#ifdef __DJGPP__
<<"Toolsdos(V32 for DOS,WIN95/98,NOT ME)"
#endif //__DJGPP__
<<" V1.1.0 Compiled on " << __TIME__", " << __DATE__ << endl
<< "Written by SunBaoJian E-mail:s_b_j@sina.com" << endl
<< "Refer to README.TXT for more details in Chinese." << endl
<< "Please feel free to report any bugs or problems to me, thanks!" << endl
<< "Updated for DJGpp2.03 and VC7.1 compatibility."
<< endl;
int i=1;
while(i<argc)
{
strcat(szCmdLine,argv[i]);
strcat(szCmdLine," ");
i++;
}
i=0;
int j=0;
while(szCmdLine[i])
{
if(szCmdLine[i]=='-')
{
do
{
pCmdLineTmp[j]=szCmdLine[i];
i++;
j++;
}while(szCmdLine[i]!='-'
&&szCmdLine[i]
&&szCmdLine[i]!='>'
&&szCmdLine[i]!='<');
pCmdLineTmp[j]='\0';
pTools->Run(pCmdLineTmp);
if(pTools->m_pError->GetLastError()==c_CMD_T_CM_QUIT)
goto Quit;
j=0;
}
else
i++;
}
pTools->Run(NULL);
Quit:
#ifndef _WIN32
textmode(C80);
#endif
cout<< endl
<<"This program comes with NO WARRANTY." << endl
<< "Refer to README.TXT for more details in Chinese."<< endl
<< "To let me know where my program gets to, thanks !" << endl
<< "E-mail:s_b_j@sina.com"
<< endl;
#ifdef _WIN32
SDbgClose();
#endif
return 0;
}
S_CATCH_ALL_SLIB_EXCEPTION
//catch(...)
//{
// cout<<"Memory erro will be catched." <<endl;
//}
char ch;
cout<<"Press Enter key to quit" <<endl;
cin.get(ch);
return 1;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -