#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    2
    Rep Power
    0

    Question How to make Norton Ghost ??


    How to make:
    Norton Ghost 2002 includes the following:
    -Back up function:Lets you select a hard disk or partion to back up to an image file.
    -Restore function:Lets you restore a hard disk or partion from an image file.

    using Borland C++ under Dos...
    Note:
    The base function is to read a hard disk or partion as bytes not as folders and files
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    191
    Originally Posted by esraa_sc
    How to make:
    Norton Ghost 2002 includes the following:
    -Back up function:Lets you select a hard disk or partion to back up to an image file.
    -Restore function:Lets you restore a hard disk or partion from an image file.

    using Borland C++ under Dos...
    Note:
    The base function is to read a hard disk or partion as bytes not as folders and files
    I don't think Borland C++ comes with any libraries for that. But the BIOS interface to raw hard disk data is int13h: http://www.pcguide.com/ref/hdd/bios/biosInt13h-c.html

    Note: It will not work in a dos window. You need DOS. Windows 98 or 95 in DOS MODE is ok too.

    hth
    M.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    2
    Rep Power
    0

    Question Thanks alot


    I make it but i use The functions that wrap the assembly language opcodes are:
    In BIOS.H file contains:
    biosdisk();
    but i find unlogical errors ???

    The source code is:

    Code:
    #include <bios.h>
    #include <alloc.h>
    
    #include <ctype.h>
    #include <dir.h>
    #include <dos.h>
    #include <io.h>
    #include <fcntl.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <string.h>
    
    #define FALSE	0
    #define TRUE	(!FALSE)
    
    #define SECTORSIZE	512
    
    // BIOS Int13 services we make use of
    #define	RESET	0
    #define	LAST	1
    #define	READ	2
    #define	WRITE	3
    #define	VERIFY	4
    #define	FORMAT	5
    
    int density;// How many sectors are in a track
    
    void msg(char (*s))
    {
    	printf("%s\n", s);
    	_exit(1);
    }
    
    // Identify the error code with a real error message.
    void Error(int (status))
    {
    	switch (status)
    		{
    //		case 0x00:msg("Operation Successful");				break;
    		case 0x01:msg("Bad command");					break;
    		case 0x02:msg("Address mark not found");			break;
    		case 0x03:msg("Attempt to write on write-protected disk");	break;
    		case 0x04:msg("Sector not found");				break;
    		case 0x05:msg("Reset failed (hard disk)");			break;
    //		case 0x06:msg("Disk changed since last operation");		break;
    		case 0x07:msg("Drive parameter activity failed");		break;
    		case 0x08:msg("DMA overrun");					break;
    		case 0x09:msg("Attempt to DMA across 64K boundary");		break;
    		case 0x0A:msg("Bad sector detected");				break;
    		case 0x0B:msg("Bad track detected");				break;
    		case 0x0C:msg("Unsupported track");				break;
    		case 0x10:msg("Bad CRC/ECC on disk read");			break;
    		case 0x11:msg("CRC/ECC corrected data error");			break;
    		case 0x20:msg("Controller has failed");				break;
    		case 0x40:msg("Seek operation failed");				break;
    		case 0x80:msg("Attachment failed to respond");			break;
    		case 0xAA:msg("Drive not ready (hard disk only");		break;
    		case 0xBB:msg("Undefined error occurred (hard disk only)");	break;
    		case 0xCC:msg("Write fault occurred");				break;
    		case 0xE0:msg("Status error");					break;
    		case 0xFF:msg("Sense operation failed");			break;
    		default:return;
    		}
    	_exit(1);
    }
    
    void format_track(int drive,int track)
    {
    	struct FORMAT_ARRAY
    	{
    		char track,head,sector,bytes;
    	} array[30];
    	int i;
    	int head;
    
    	for(head=0;head<=1;head++)
       {
    		for(i=0;i<density;i++)
    		{
    			array[i].track=(char)track;
    			array[i].head=(char)head;
    			array[i].sector=(char)(i+1);
    			array[i].bytes=(char)2;
    		}
    
    		Error(biosdisk(FORMAT,drive,head,track,1,density,&array));
       }
    }
    
    int main(void)
    {
       char str[80];
       int  drive, head, track, buflength;
       char *buffer,*pbuf='';
      enum _MEDIA_TYPE{
    	Unknown,        //Format is unknown
    	F5_1Pt2_512,    //5.25", 1.2MB, 512 bytes/sector
    	F3_1Pt44_512,   //3.5",  1.44MB,512 bytes/sector
    	F3_2Pt88_512,   //3.5",  2.88MB,512 bytes/sector
    	F3_20Pt8_512,   //3.5",  20.8MB,512 bytes/sector
    	F3_720_512,     //3.5",  720KB, 512 bytes/sector
    	F5_360_512,     //5.25", 360KB, 512 bytes/sector
    	F5_320_512,     //5.25", 320KB, 512 bytes/sector
    	F5_320_1024,    //5.25", 320KB, 1024 bytes/sector
    	F5_180_512,     //5.25", 180KB, 512 bytes/sector
    	F5_160_512,     //5.25", 160KB, 512 bytes/sector
    	RemovableMedia, //Removable Media other than floopy
    	FixedMedia	//Fixed hard disk media
    	} MEDIA_TYPE;
      struct _LARGE_INTEGER{
    	DWORD LowPart;
    	long HighPart;
       }LARGE_INTEGER;
    
      struct _DISK_GEOMETRY{
    	LARGE_INTEGER Cylinders;
    	MEDIA_TYPE MediaType;
    	DWORD TracksPerCylinder;
    	DWORD SectorsPerTrack;
    	DWORD BytesPerSector;
    	}DISK_GEOMETRY;
    
    	struct _SECURITY_ATTRIBUTES{
    	DWORD nLength;
    	LPVOID lpSecurityDescriptor;
    	bool bInheritHandle;
    	}SECURITY_ATTRIBUTES;
       char FileName[80];
       FILE *fp;
       int option;
       puts("IF u want to make Buckup to some Drive........press 1\n");
    	puts("IF u want to make Restore to some Drive.......press 2\n");
       puts("IF u want to Exit.............................press 3\n");
    
       gets(str);
       option=(int)str[0];
       if(option==1)
       {
       	printf("Enter no of drive u want to Backup:");
    	   gets(str);
       	if(!*str)
    			exit(0);
    
    		drive = *str;
       	drive = (islower(drive) ? toupper(drive) : drive) - 'A';
    
    	   // Determine number of sectors per track and allocate buffers.
          LPCTSTR DName="\\?\";
    		DName+=drive;
          DName+=":\";
          handle hDevice=CreateFile(DName,GENERIC_READ,0,SECURITY_ATTRIBUTES,
          OPEN_EXISTING);
          LPVOID IpOutBuffer;
          bool flgresult=DeviceIoControl(hDevice,IOCTL_DISK_GET_DRIVE_GEOMETRY,
          NULL,//pointer to buffer to supply input data
    		0,//size of input buffer
    		IpOutBuffer,//pointer to buffer receive DISK_GEUMETRY data structure
    		DWORD nOutBufferSize,//size of output buffer
    		LPDWORD IpBytesReturned,//pointer to variable to receive output byte count
    		);
    		int tracks =(int)IpOutBuffer.DISK_GEOMETRY.TracksPerCylinder;
          density =(int)IpOutBuffer.DISK_GEOMETRY.SectorsPerTrack;
    
    	   printf("\n\n\nEnter File name u want to copy on :\n");
       	gets(FileName);
    
    		printf("%i tracks, %i sectors per track\n",tracks,density);
       	if( (fp=fopen(FileName,"wb"))==NULL)
       	{
    			perror(FileName);
    			exit(1);
    		}
    
    
    
    		for(track=0;track<=tracks;track++)
    		{
    			for(head=0;head<=1;head++)
    			{
    				Error(biosdisk(2, drive, head, track, 1, density, pbuf));
    				fwrite(pbuf,512,density,fp);
    				printf("Track: %i, Head: %i\r",track,head);
    			}
    		}
          fclose(fp);
          printf("\n Do u want to copy from this File to some Drive(Y/N):");
          if(toupper(getch())=='Y')
    			option=2;
    
       }
       ///Restore contents into some drive
       if(option==2)
       {
       	printf("\n\nEnter the destination drive u want: ");
    		gets(str);
    		putch('\n');
       	if(!*str)
    			exit(0);
    
    		drive = *str;
    	   drive = (islower(drive) ? toupper(drive) : drive) - 'A';
          // Determine number of sectors per track and allocate buffers.
          LPCTSTR DName;
    		DName="\\?\";
    		DName=DName+(char*)drive;
          DName=DName+":\";
          handle hDevice=CreateFile(DName,GENERIC_READ,0,SECURITY_ATTRIBUTES,
          OPEN_EXISTING);
          bool flgresult=DeviceloControl(hDevice,IOCTL_DISK_GET_DRIVE_GEOMETRY,
          NULL,//pointer to buffer to supply input data
    		0,//size of input buffer
    		LPVOID IpOutBuffer,//pointer to buffer receive DISK_GEUMETRY data structure
    		DWORD nOutBufferSize,//size of output buffer
    		LPDWORD IpBytesReturned,//pointer to variable to receive output byte count
    		);
    		int tracks =(int)IpOutBuffer.DISK_GEOMETRY.TracksPerCylinder;
          density =(int)IpOutBuffer.DISK_GEOMETRY.SectorsPerTrack;
    
    		printf("\n\n\nEnter File name u want to copy from :\n");
       	gets(FileName);
    
    		printf("%i tracks, %i sectors per track\n",tracks,density);
    
    		fp=fopen(FileName,"rb");
    		for(track=0;track<=tracks;track++)
          {
    			format_track(drive,track);
    			for(head=0;head<=1;head++)
    			{
    				fread(pbuf,512,density,fp);
    				Error(biosdisk(3, drive, head, track,1, density, pbuf));
    				printf("Track: %i, Sector: %i, Head: %i\r",track,0,head);
    			}
    		}
    
    		printf("\nDone.\n");
    		biosdisk(2, drive, 0, 0, 1, 1, buffer);		/* Retract head	*/
    		fclose(fp);
    
    
       }
    
       return 0;
    }
    /////////////////////
    Please see it and reply as soon as u can
    Last edited by M.Hirsch; November 25th, 2004 at 05:51 AM. Reason: added code tags

IMN logo majestic logo threadwatch logo seochat tools logo