⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 命令行方式的硬盘工具 可以在dos和nt下运行。 需要djgpp和vs7.0以上
💻 CPP
字号:
/*

Command Line Tools for DOS(V32) and WINNT Prgram Main Prgram v10.1 write by 孙宝建
6-20-2004
(暂停)
*/
/*

暂停原因:
1。文件系统复杂,没有时间了

以后的工作:
1。学习msdn
2。《数据恢复技术》《硬盘扇区读写技术-修复硬盘与恢复文件》
3。使用WINHEX
4。定义基本结构,文件系统类型有fat12,fat16,big fat16,fat32,big fat32
5。定义物理盘,定义分区,定义逻辑盘,定义BPB
6。每一个物理盘有几个主分区,多个扩展分区(用链表存),每个分区代表一个逻辑盘,一个逻辑盘包括几种文件格式
7。两种方法把数据装入结构	(1)用绝对扇区号 (2)用当前的缓冲区内容(3)文件(考虑ing)
8。详尽的测试
*/
/*
根目录的第一个文件的文件名就是卷标
*/
#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;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -