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

📄 main.cpp

📁 命令行方式的硬盘工具 可以在dos和nt下运行。 需要djgpp和vs7.0以上
💻 CPP
字号:
#include <cstdio>
#include <iostream>
#include <conio.h>

#include "commcpp.hpp"
#include "serror.hpp"
#include "int13.hpp"
//#include "srch.hpp"
using namespace std;
using namespace SLib;
#ifdef __DJGPP__
#include <stdlib.h>
#include <sys/movedata.h>
#include <go32.h>
#endif

const ULONG c_ulMAX_TEST_SECTORS =126;	//((ULONG)128)
const ULONG c_ulBEGIN_SECTOR		= 0;
//#define MAX_TEST_SECTORS ((ULONG)128)


static const ERROR_STRING g_allErrorString[] =
    {
        DEFIN_ERR_STRING( c_ERR_NO_ERROR,No Error.),
        DEFIN_ERR_STRING( c_ERR_BAD_PARAMETER,Invalid Parameters.),
        DEFIN_ERR_STRING( c_ERR_FIRST_SEARCH,No Search Strings.),
        DEFIN_ERR_STRING( c_ERR_HELP,Type h For Help.),
        DEFIN_ERR_STRING( c_ERR_SRCH_NO_FIND,No Found.),
        DEFIN_ERR_STRING( c_ERR_NO_MEMORY,No memory.),
        DEFIN_ERR_STRING( c_ERR_BAD_COMMAND,Bad Command.),
        DEFIN_ERR_STRING( c_ERR_UNKNOW_ERROR,Unknwon Error.),
        DEFIN_ERR_STRING( c_ERR_FILE_TOO_LONG,File Too Long or Buffer is Small.),
        DEFIN_ERR_STRING( c_ERR_FILE_OPEN,Can"'"t Open File.),
        DEFIN_ERR_STRING( c_ERR_FILE_WRITE,Can"'"t  write file.),	
        DEFIN_ERR_STRING( c_ERR_FILE_READ,Can"'"t read file.),	
        DEFIN_ERR_STRING( c_ERR_FILE_SIZE_LARGE,Can"'"t read or write bufffer size bytes.),
        DEFIN_ERR_STRING( c_ERR_SEARCH_BUFF_SMALL,Buffer is Small when Searching.),
        DEFIN_ERR_STRING( c_ERR_BUF_SMALL,Overflow Bufffer Size.),
        DEFIN_ERR_STRING( c_ERR_CINT13_NO_DISK,No Found Disk.),
        DEFIN_ERR_STRING( c_ERR_CINT13_READ_DISK,Can"'"t Read Disk.),
//        DEFIN_ERR_STRING( ERR_COMMAND_ABORT,Command Aborted),
        DEFIN_ERR_STRING( c_ERR_SEARCH_DONE,Search Complete In Buffer.),
        DEFIN_ERR_STRING( c_ERR_MBR_SIZE,Invalid Mbr Number.),
        DEFIN_ERR_STRING( c_ERR_SEARCH_INIT_FAIL,Search Init Fail.),
        DEFIN_ERR_STRING( c_ERR_NO_CLUSTER,Cluster Not Loaded or Cluster Number too Large.),
        DEFIN_ERR_STRING( c_ERR_NO_FOUND_ERROR,Error list is Empty.),
        DEFIN_ERR_STRING( c_ERR_FAT32_LOAD_FAT32,LoadFat32.),
        DEFIN_ERR_STRING( c_ERR_CINT13_BUF_SMALL,CInt13::GetDiskParameter.),
      	{0,(""),("")}
    };
    
class CCmdToolError : public  CSError
{

public:
    CCmdToolError();
    ~CCmdToolError();
    virtual void OutputMsg(const tstring & msg)const ;
};

CCmdToolError::CCmdToolError(void): CSError((ERROR_STRING *)&g_allErrorString)
{

}

CCmdToolError::~CCmdToolError()
{

}

void CCmdToolError::OutputMsg(const tstring & msg)const 
{
    cout<< msg ;
}
CCmdToolError g_Error;
int main(void)
{
//    UINT64 i64=0;
//    scanf("%lld",&i64);
//    cin>>i64;
//    cout<<endl<<i64;
//    return 0;
    BYTE  *buff=NULL;
    ULONG ulLen;
    ULONG i=0 ;
    char argv[]="55 aa";

    CInt13 *pInt13=new CInt13(&g_Error);
    if(pInt13==NULL)
    {
        cout<<"no int 13 mem"<<endl;
        goto endmain;
    }
    ulLen=c_ulMAX_TEST_SECTORS ;
    ulLen=ulLen*c_uBYTES_PER_SECTOR;
    buff=new BYTE [ulLen*sizeof(BYTE)];
    if(buff==NULL)
    {
        cout<<"no buff mem"<<endl;
        goto endmain;
    }
/*   CSectorSrch * pSrch=new CSectorSrch(0x80);
    if(pSrch==NULL)
    {
        cout<<"no srch mem"<<endl;
        goto endmain;
    }



    if(pSrch->Init(buff,argv,ulLen-c_uBYTES_PER_SECTOR))
    {
        // getch();
        pSrch->FindAtOffset(0,63,0x1fe,TRUE);
        //      pSrch->Find(0);
    }
    else
        printf("error");
  */

    for(i=0;i<c_uBYTES_PER_SECTOR*c_ulMAX_TEST_SECTORS;i++)
        buff[i]=i;


    if((pInt13->ReadSector(c_ulBEGIN_SECTOR,1,buff)) )
    {
        printf("ok\n");
    }
   else
        g_Error.ReportAllError();
    for(i=0;i<512;i++)
        printf("%02X ",buff[i]);
    /*	buff[509]=0x0;
    if((pInt13->WriteSector(c_ulBEGIN_SECTOR,1,buff)) )
    {
    printf("ok\n");
    }
    else
    printf("error:%x\n",pInt13->GetLastError());
    */
    getch();
    /*  Param.unSectors=1;
    Param.ulStartSector=0;
    Param.pBuff=buff;
    Param.uDiskNum=0x80;
    Param.uCommand=DISK_READ;
    Int13.DisplayInfo();
    if(!pInt13->Int13(Param))
    {
    printf("ok\n");

    }
    else
    printf("error:%x\n",pInt13->m_ErrCode);
    for(i=c_uBYTES_PER_SECTOR*126;i<c_uBYTES_PER_SECTOR*127;i++)
    printf("%02x ",(UCHAR)buff[i]);
    cout<<"ok"<<endl;
    getch();
    Param.unSectors=1000;
    Param.ulStartSector=128;
    Param.pBuff=buff;
    Param.uDiskNum=0x80;
    Param.uCommand=DISK_READ;
    if(!pInt13->Int13(Param))
    {
    printf("ok\n");

    }
    else
    printf("error:%x\n",pInt13->m_ErrCode);
    for(i=c_uBYTES_PER_SECTOR*127;i<c_uBYTES_PER_SECTOR*128;i++)
    printf("%02x ",(UCHAR)buff[i]);
    cout<<"ok"<<endl;
    getch();
    */
endmain :
    delete pInt13;
    if(buff!=NULL)
        delete []buff;
    return 0;
    //  int13test();
}

⌨️ 快捷键说明

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