FIXPART.C
资源名称:schdgurd.zip [点击查看]
上传用户:yugezi
上传日期:2007-01-06
资源大小:18k
文件大小:5k
源码类别:
磁盘编程
开发平台:
Others
- #include<stdio.h>
- #include<bios.h>
- #include<stdlib.h>
- #include<alloc.h>
- #include<fcntl.h>
- #include<sysstat.h>
- #include<dos.h>
- char Sector1[512]=
- { 0xFA,0x33,0xC0,0x8E,0xD0,0xBC,0x00,0x7C,0x8B,0xF4,0x50,0x07,
- 0x50,0x1F,0xFB,0xFC,0xBF,0x00,0x06,0xB9,0x00,0x01,0xF2,0xA5,
- 0xEA,0x1D,0x06,0x00,0x00,0xBE,0xBE,0x07,0xB3,0x04,0x80,0x3C,
- 0x80,0x74,0x0E,0x80,0x3C,0x00,0x75,0x1C,0x83,0xC6,0x10,0xFE,
- 0xCB,0x75,0xEF,0xCD,0x18,0x8B,0x14,0x8B,0x4C,0x02,0x8B,0xEE,
- 0x83,0xC6,0x10,0xFE,0xCB,0x74,0x1A,0x80,0x3C,0x00,0x74,0xF4,
- 0xBE,0x8B,0x06,0xAC,0x3C,0x00,0x74,0x0B,0x56,0xBB,0x07,0x00,
- 0xB4,0x0E,0xCD,0x10,0x5E,0xEB,0xF0,0xEB,0xFE,0xBF,0x05,0x00,
- 0xBB,0x00,0x7C,0xB8,0x01,0x02,0x57,0xCD,0x13,0x5F,0x75,0x0C,
- 0x33,0xC0,0xCD,0x13,0x4F,0x75,0xED,0xBE,0xA3,0x06,0xEB,0xD3,
- 0xBE,0xC2,0x06,0xBF,0xFE,0x7D,0x81,0x3D,0x55,0xAA,0x75,0xC7,
- 0x8B,0xF5,0xEA,0x00,0x7C,0x00,0x00,0x49,0x6E,0x76,0x61,0x6C,
- 0x69,0x64,0x20,0x70,0x61,0x72,0x74,0x69,0x74,0x69,0x6F,0x6E,
- 0x20,0x74,0x61,0x62,0x6C,0x65,0x00,0x45,0x72,0x72,0x6F,0x72,
- 0x20,0x6C,0x6F,0x61,0x64,0x69,0x6E,0x67,0x20,0x6F,0x70,0x65,
- 0x72,0x61,0x74,0x69,0x6E,0x67,0x20,0x73,0x79,0x73,0x74,0x65,
- 0x6D,0x00,0x4D,0x69,0x73,0x73,0x69,0x6E,0x67,0x20,0x6F,0x70,
- 0x65,0x72,0x61,0x74,0x69,0x6E,0x67,0x20,0x73,0x79,0x73,0x74,
- 0x65,0x6D,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x80,0x01,0x01,0x00,0x04,0x04,0xD1,0x02,0x11,0x00,
- 0x00,0x00,0xEE,0xFF,0x00,0x00,0x00,0x00,0xC1,0x03,0x05,0x04,
- 0xD1,0xFE,0xFF,0xFF,0x00,0x00,0xAC,0x53,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x55,0xAA};
- void CopyPart(char *src,char *dest);
- void copyright();
- void reboot(void)
- {
- void (far *reboot_ptr)(void);
- unsigned int far *i_ptr;
- clrscr();
- i_ptr=MK_FP(0x0040,0x0072);
- *i_ptr=0x1234;
- reboot_ptr=MK_FP(0xF000,0xFFF0);
- reboot_ptr();
- }
- main()
- {
- char filename[20];
- char *buffer;
- FILE *fp;
- copyright();
- printf("n BACKUP Filename: ");
- scanf("%s",filename);
- printf("n Backuping File %s ...... ",filename);
- fp=fopen(filename,"wb");
- if(fp==NULL){puts("na Open file error");exit(1);}
- buffer=(char *)malloc(512);
- if(biosdisk(0x02,0x80,0,0,1,1,buffer))
- {
- printf("n Read HD Master Boot Sector error!n");
- exit(1);
- }
- fwrite(buffer,512,1,fp);
- fclose(fp);
- printf(" OK!n");
- CopyPart(buffer+0x1be,Sector1+0x1be);
- printf("n Write Old HD Master Boot Sector to Sector 3 ...... ");
- if(biosdisk(0x03,0x80,0,0,3,1,buffer))
- {
- printf("n Write Old HD Master Boot Sector to Sector 3 error!n");
- exit(1);
- }
- printf(" OK!n");
- printf("n Write Old HD Master Boot Sector to Sector 7 ...... ");
- if(biosdisk(0x03,0x80,0,0,7,1,buffer))
- {
- printf("n Write Old HD Master Boot Sector to Sector 7 error!n");
- exit(1);
- }
- printf(" OK!n");
- free(buffer);
- printf("n Write New Data to HD Master Boot Sector ...... ");
- if(biosdisk(0x03,0x80,0,0,1,1,Sector1))
- {
- printf("n Restore HD Master Boot Sector error!n");
- exit(1);
- }
- printf(" OK!n");
- printf("n Now,your Hard-Disk is all right!");
- printf("n Prees any key to reboot your system.n");
- getch();
- reboot();
- }
- void copyright()
- {
- printf("n Babysoft (R) HD Master Boot Sector Fixer version 1.0.");
- printf("n Copyright (C) 1997.9 LiuYading,Babysoft Corp.n");
- }
- void CopyPart(char *src,char *dest)
- {
- char Plength;
- Plength=0x40;
- while(Plength>=0)
- {
- *(dest+Plength)=*(src+Plength);
- Plength--;
- }
- }