//--------------------------------------------------------------------------- int put_sector(int drive, int head, int track, int sector, void* data) { int result; result = biosdisk(_DISK_RESET, drive, head, track, sector, 1, data); if((result >> 8) == 0) { result = biosdisk(_DISK_WRITE, drive, head, track, sector, 1, data); } return result >> 8; }
int main(int argc,char * argv[]) { int result; char buffer[512]; FILE *fp; if (argc == 1) helpmsg(); if (* argv[1] == 's' || *argv[1] == 'S') /*保存分区表功能*/ { result = biosdisk(2,0x80,0,0,0,1,buffer); /*调用biosdisk,将错误类型返回给result,内容存在buffer中*/ if (!result){ /*如果成功读取分区表*/ printf(" Read partition table successfully!\n"); if (( fp == fopen("c:part.doc","wb+"))==NULL) /*将结果写到C:\part.doc文件中*/ { fprintf(stderr," Can't creat file:c:\\part.doc \n"); /*如果写文件失败*/ exit(1); } fwrite(buffer,1,512,fp); fclose(fp); printf(" Partition table save successfully!\n"); return 0; } else { /*如果读取失败*/ fprintf(stderr," Fail to read partition table!"); exit(1); } } if ( * argv[1] == 'r' || * argv[1] == 'S') /*恢复分区表功能,顺序相反,操作与上面类似*/ { if ((fp == fopen("c:part.doc","rb+"))==NULL) { fprintf(stderr," Can't open file!"); exit(1); } fread (buffer,1,512,fp); result = biosdisk(3,0x80,0,0,1,1,buffer); if (! result){ printf(" Partition table restore successfully!\n"); fclose(fp); return 0; } else{ fprintf(stderr," Failt to restore partition table!"); fclose(fp); exit(1); } } printf("\n Press any key to quit..."); getch(); return 0; }
void main() { clrscr(); _setcursortype(_NOCURSOR); int drive=0;//DRIVE A int head=0;//FIRST SIDE int track=0;//CYLINDER/TRACK ZERO int sector=1;//STARTING SECTOR int no_of_sectors=18;//NO OF SECTORS TO FORMAT char buffer[512];//DATA BUFFER int disk_status; int i; puts("--------------------------------------------------------------------------------"); textcolor(7); cprintf(" 3.5 INCH,1.44 MB FLOPPY DISK FORMATTIING TOOL"); textcolor(11); cprintf("\r\n\n DEVELOPED BY HEMENDRA SINGH & SURYA RAJ,S.R.C.E.M.,GWALIOR,M.P.,INDIA "); puts("--------------------------------------------------------------------------------"); disk_status=biosdisk(_DISK_VERIFY,drive,head,track,sector,1,buffer); if(disk_status==0X01) { gotoxy(30,20); printf("\n\n\t\t\tDISKETTE NOT READY YET.\n\n\t\t\tPRESS ANY KEY TO CONTINUE..."); getch(); exit(0); } else { puts("\n\n\nFORMATTING STARTED..."); //FORMAT FIRST SIDE for(i=0;i<=79;i++) { biosdisk(_DISK_FORMAT,drive,head,track+i,sector,no_of_sectors,buffer); } //FORMAT SECOND SIDE head=1; for(i=0;i<=79;i++) { biosdisk(_DISK_FORMAT,drive,head,track+i,sector,no_of_sectors,buffer); } puts("\n\nFORMATTING COMPLETED.THE FILE SYSTEM IS RAW"); getch(); } }
void main(void) { char buffer[8192]; // Try reading head 1, track 1, sector 1 if (biosdisk(2, 0, 1, 1, 1, 1, buffer)) printf("Error accessing drive\n"); else printf("Drive ready\n"); }
/* Read/write NSEC sectors starting from SECTOR in DRIVE disk with GEOMETRY from/into SEGMENT segment. If READ is BIOSDISK_READ, then read it, else if READ is BIOSDISK_WRITE, then write it. If an geometry error occurs, return BIOSDISK_ERROR_GEOMETRY, and if other error occurs, then return the error number. Otherwise, return 0. */ int biosdisk (int read, int drive, struct geometry *geometry, int sector, int nsec, int segment) { int err; if (geometry->flags & BIOSDISK_FLAG_LBA_EXTENSION) { struct disk_address_packet { unsigned char length; unsigned char reserved; unsigned short blocks; unsigned long buffer; unsigned long long block; } __attribute__ ((packed)) dap; /* XXX: Don't check the geometry by default, because some buggy BIOSes don't return the number of total sectors correctly, even if they have working LBA support. Hell. */ #ifdef NO_BUGGY_BIOS_IN_THE_WORLD if (sector >= geometry->total_sectors) return BIOSDISK_ERROR_GEOMETRY; #endif /* NO_BUGGY_BIOS_IN_THE_WORLD */ /* FIXME: sizeof (DAP) must be 0x10. Should assert that the compiler can't add any padding. */ dap.length = sizeof (dap); dap.block = sector; dap.blocks = nsec; dap.reserved = 0; /* This is undocumented part. The address is formated in SEGMENT:ADDRESS. */ dap.buffer = segment << 16; err = biosdisk_int13_extensions ((read + 0x42) << 8, drive, &dap); /* #undef NO_INT13_FALLBACK */ #ifndef NO_INT13_FALLBACK if (err) { if (geometry->flags & BIOSDISK_FLAG_CDROM) return err; geometry->flags &= ~BIOSDISK_FLAG_LBA_EXTENSION; geometry->total_sectors = (geometry->cylinders * geometry->heads * geometry->sectors); return biosdisk (read, drive, geometry, sector, nsec, segment); } #endif /* ! NO_INT13_FALLBACK */ } else {
int write_sector (int drive_number,dword head,dword cylinder,dword sector,byte *buffer) { int i; boolean done=false; for (i=0;i<3;i++) { if (!biosdisk (WRITE_SECTOR,drive_number,head,cylinder,sector,1,buffer)) { done=true; break; } reset_drives(); } if (!done) return (-1); return (verify_sector (drive_number,head,cylinder,sector,buffer)); }
void main() { clrscr(); _setcursortype(_NOCURSOR); int drive=0;//DRIVE A int head=0;//FIRST SIDE int track=0;//CYLINDER/TRACK ZERO int sector=1;//STARTING SECTOR int no_of_sectors=18;//NO OF SECTORS TO FORMAT char file_path[80]; char file_data[3805]; int file_size; int i=0; puts("\t\t3.5 INCH,1.44 MB FLOPPY DISK WRITTING TOOL"); puts("\n\t DEVELOPED BY HEMENDRA SINGH & SURYA RAJ,S.R.C.E.M.,GWALIOR"); cout<<"\n\nENTER HEAD[0/1] = "; cin>>head; cout<<"\nENTER TRACK[0-79] = "; cin>>track; cout<<"\nENTER STARTING SECTOR[1-18] = "; cin>>sector; cout<<"\nENTER FILE PATH = "; cin>>file_path; ifstream openfile(file_path,ios::binary,ios::beg); if(!openfile) { cout<<"\n\aFILE I/O ERROR"; } else { while(!openfile.eof()) { openfile.read((char *)&file_data,sizeof(file_data)); cout<<file_data; i++; } file_size=sizeof(file_data); puts("\n-------------------------------------------------------------------------------"); cout<<"\nFILE SIZE = "<<file_size<<" BYTES"; puts("\n\n\nWRITTING STARTED..."); biosdisk(_DISK_WRITE,drive,head,track,sector,8,file_data); puts("\n-------------------------------WRITING COMPLETED-------------------------------"); } getch(); }
int verify_sector (int drive_number,dword head,dword cylinder,dword sector,byte *buffer) { if (biosdisk (VERIFY_SECTOR,drive_number,head,cylinder,sector,1,buffer)) return (-1); return 0; }
void main() { clrscr(); char file_data[9216]; int i; int head,track,starting_sector=1,sectors_to_read=17,drive=0; cout<<"\t\t\tMoksha Operating System Image Mounter"; cout<<"\n\nMounting Image....."; for(head=0;head<=0;head++) { for(track=0;track<=20;track++) { switch(head) { case 0: // If Head is 0 { switch(track) { case 0:{ ifstream readfile("H0Trk0.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 1:{ ifstream readfile("H0Trk1.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 2:{ ifstream readfile("H0Trk2.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 3:{ ifstream readfile("H0Trk3.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 4:{ ifstream readfile("H0Trk4.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 5:{ ifstream readfile("H0Trk5.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 6:{ ifstream readfile("H0Trk6.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 7:{ ifstream readfile("H0Trk7.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 8:{ ifstream readfile("H0Trk8.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 9:{ ifstream readfile("H0Trk9.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 10:{ ifstream readfile("H0Trk10.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 11:{ ifstream readfile("H0Trk11.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 12:{ ifstream readfile("H0Trk12.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 13:{ ifstream readfile("H0Trk13.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 14:{ ifstream readfile("H0Trk14.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 15:{ ifstream readfile("H0Trk15.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 16:{ ifstream readfile("H0Trk16.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 17:{ ifstream readfile("H0Trk17.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 18:{ ifstream readfile("H0Trk18.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 19:{ ifstream readfile("H0Trk19.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 20:{ ifstream readfile("H0Trk20.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} /* case 21:{ ifstream readfile("H0Trk21.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 22:{ ifstream readfile("H0Trk22.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 23:{ ifstream readfile("H0Trk23.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 24:{ ifstream readfile("H0Trk24.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 25:{ ifstream readfile("H0Trk25.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 26:{ ifstream readfile("H0Trk26.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 27:{ ifstream readfile("H0Trk27.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 28:{ ifstream readfile("H0Trk28.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 29:{ ifstream readfile("H0Trk29.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 30:{ ifstream readfile("H0Trk30.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 31:{ ifstream readfile("H0Trk31.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 32:{ ifstream readfile("H0Trk32.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 33:{ ifstream readfile("H0Trk33.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 34:{ ifstream readfile("H0Trk34.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 35:{ ifstream readfile("H0Trk35.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 36:{ ifstream readfile("H0Trk36.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 37:{ ifstream readfile("H0Trk37.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 38:{ ifstream readfile("H0Trk38.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 39:{ ifstream readfile("H0Trk39.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 40:{ ifstream readfile("H0Trk40.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 41:{ ifstream readfile("H0Trk41.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 42:{ ifstream readfile("H0Trk42.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 43:{ ifstream readfile("H0Trk43.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 44:{ ifstream readfile("H0Trk44.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 45:{ ifstream readfile("H0Trk45.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 46:{ ifstream readfile("H0Trk46.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 47:{ ifstream readfile("H0Trk47.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 48:{ ifstream readfile("H0Trk48.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 49:{ ifstream readfile("H0Trk49.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 50:{ ifstream readfile("H0Trk50.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 51:{ ifstream readfile("H0Trk51.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 52:{ ifstream readfile("H0Trk52.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 53:{ ifstream readfile("H0Trk53.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 54:{ ifstream readfile("H0Trk54.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 55:{ ifstream readfile("H0Trk55.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 56:{ ifstream readfile("H0Trk56.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 57:{ ifstream readfile("H0Trk57.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 58:{ ifstream readfile("H0Trk58.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 59:{ ifstream readfile("H0Trk59.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 60:{ ifstream readfile("H0Trk60.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 61:{ ifstream readfile("H0Trk61.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 62:{ ifstream readfile("H0Trk62.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 63:{ ifstream readfile("H0Trk63.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 64:{ ifstream readfile("H0Trk64.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 65:{ ifstream readfile("H0Trk65.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 66:{ ifstream readfile("H0Trk66.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 67:{ ifstream readfile("H0Trk67.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 68:{ ifstream readfile("H0Trk68.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 69:{ ifstream readfile("H0Trk69.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 70:{ ifstream readfile("H0Trk70.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 71:{ ifstream readfile("H0Trk71.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 72:{ ifstream readfile("H0Trk72.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 73:{ ifstream readfile("H0Trk73.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 74:{ ifstream readfile("H0Trk74.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 75:{ ifstream readfile("H0Trk75.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 76:{ ifstream readfile("H0Trk76.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 77:{ ifstream readfile("H0Trk77.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 78:{ ifstream readfile("H0Trk78.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} case 79:{ ifstream readfile("H0Trk79.os",ios::binary); readfile.read((char *)&file_data,sizeof(file_data)); readfile.close(); biosdisk(_DISK_WRITE,drive,head,track,starting_sector,sectors_to_read, file_data); for(i=0;i<=9215;i++) { file_data[i]=' ';} break;} */ }// Switch for track block ends break;} } // Switch for head block ends } } cout<<"\n\nImage Mounted Successfully."; getch(); }
/* Read/write NSEC sectors starting from SECTOR in DRIVE disk with GEOMETRY from/into SEGMENT segment. If READ is BIOSDISK_READ, then read it, else if READ is BIOSDISK_WRITE, then write it. If an geometry error occurs, return BIOSDISK_ERROR_GEOMETRY, and if other error occurs, then return the error number. Otherwise, return 0. */ int biosdisk (int read, int drive, struct geometry *geometry, int sector, int nsec, int segment) { int err; if (geometry->flags & BIOSDISK_FLAG_LBA_EXTENSION) { struct disk_address_packet { unsigned char length; unsigned char reserved; unsigned short blocks; unsigned long buffer; unsigned long long block; } dap; /* XXX: Don't check the geometry by default, because some buggy BIOSes don't return the number of total sectors correctly, even if they have working LBA support. Hell. */ #ifdef NO_BUGGY_BIOS_IN_THE_WORLD if (sector >= geometry->total_sectors) return BIOSDISK_ERROR_GEOMETRY; #endif /* NO_BUGGY_BIOS_IN_THE_WORLD */ /* FIXME: sizeof (DAP) must be 0x10. Should assert that the compiler can't add any padding. */ dap.length = sizeof (dap); dap.block = sector; dap.blocks = nsec; dap.reserved = 0; /* This is undocumented part. The address is formated in SEGMENT:ADDRESS. */ dap.buffer = segment << 16; err = biosdisk_int13_extensions (read + 0x42, drive, &dap); #ifndef NO_INT13_FALLBACK if (err) { geometry->flags &= ~BIOSDISK_FLAG_LBA_EXTENSION; geometry->total_sectors = (geometry->cylinders * geometry->heads * geometry->sectors); return biosdisk (read, drive, geometry, sector, nsec, segment); } #endif /* ! NO_INT13_FALLBACK */ } else { int cylinder_offset, head_offset, sector_offset; int head; /* SECTOR_OFFSET is counted from one, while HEAD_OFFSET and CYLINDER_OFFSET are counted from zero. */ sector_offset = sector % geometry->sectors + 1; head = sector / geometry->sectors; head_offset = head % geometry->heads; cylinder_offset = head / geometry->heads; if (cylinder_offset >= geometry->cylinders) return BIOSDISK_ERROR_GEOMETRY; err = biosdisk_standard (read + 0x02, drive, cylinder_offset, head_offset, sector_offset, nsec, segment); } return err; }