/* Delete Non-DOS Partition User Interface */ void Delete_N_DOS_Partition_Interface() { int input=0; Clear_Screen(0); Print_Centered(4,"Delete Non-DOS Partition",BOLD); Display_Primary_Partition_Information_SS(); BlinkPrintAt(4,18,"WARNING!"); printf(" Data in the deleted Non-DOS Partition will be lost."); printAt(4,19,"What Non-DOS Partition do you want to delete..? "); flags.esc=FALSE; input=(int)Input(1,52,19,NUM,1,4,ESCR,-1,0,NULL,NULL); /* 4 needs changed to the max num of partitions */ if(flags.esc==FALSE) { Delete_Primary_Partition(input-1); Clear_Screen(0); Print_Centered(4,"Delete Non-DOS Partition",BOLD); Display_Primary_Partition_Information_SS(); cprintAt(4,21,"Non-DOS Partition deleted"); printAt(4,24," "); Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); } }
/* Delete Extended DOS Partition Interface */ void Delete_Extended_DOS_Partition_Interface() { int input=0; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; Clear_Screen(0); Print_Centered(4,"Delete Extended DOS Partition",BOLD); Display_Primary_Partition_Information_SS(); BlinkPrintAt(4,18,"WARNING!"); printf(" Data in the deleted Extended DOS Partition will be lost."); printAt(4,19,"Do you wish to continue (Y/N).................? "); flags.esc=FALSE; input=(int)Input(1,52,19,YN,0,0,ESCR,0,0,NULL,NULL); if( (flags.esc==FALSE) && (input==TRUE) ) { Delete_Primary_Partition(int(pDrive->ptr_ext_part-pDrive->pri_part)); Clear_Extended_Partition_Table(flags.drive_number-128); Clear_Screen(0); Print_Centered(4,"Delete Extended DOS Partition",BOLD); Display_Primary_Partition_Information_SS(); cprintAt(4,21,"Extended DOS Partition deleted"); printAt(4,24," "); Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); } }
/* Display/Modify Partition Information */ void Display_Partition_Information() { int input; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; Beginning: Clear_Screen(0); if(flags.extended_options_flag==FALSE) Print_Centered(4,"Display Partition Information",BOLD); else Print_Centered(4,"Display/Modify Partition Information",BOLD); Display_Primary_Partition_Information_SS(); if(pDrive->num_of_log_drives>0) { printAt(4,17,"The Extended DOS Partition contains Logical DOS Drives."); printAt(4,18,"Do you want to display the logical drive information (Y/N)......?"); if(flags.extended_options_flag==TRUE) { printAt(4,19," (Optional: Type the number of the partition to modify.)"); input=(int)Input(1,69,18,YN,0,0,ESCR,1,0,"1","4"); if( ((input-48)>=1) && ((input-48)<=4) ) { Modify_Primary_Partition_Information((input-48)); goto Beginning; } } else input=(int)Input(1,69,18,YN,0,0,ESCR,1,0,NULL,NULL); if(input==TRUE) { Display_Or_Modify_Logical_Drive_Information(); if(flags.extended_options_flag==TRUE) goto Beginning; } } else { if(flags.extended_options_flag==FALSE) Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); else { printAt(4,18,"Enter the number of the partition you want to modify (1-4)......?"); flags.esc=FALSE; input=(int)Input(1,69,18,NUM,1,4,ESCR,1,0,NULL,NULL); if(flags.esc==FALSE) { Modify_Primary_Partition_Information(input); goto Beginning; } } } }
/* Change Current Fixed Disk Drive */ void Change_Current_Fixed_Disk_Drive() { int new_drive_number; int old_drive_number=flags.drive_number; Clear_Screen(0); Print_Centered(0,"Change Current Fixed Disk Drive",BOLD); Display_All_Drives(); printAt(4,21,"Enter Fixed Disk Drive Number (1-%d)......................." ,(flags.maximum_drive_number-127)); new_drive_number=(int)Input(1,62,21,NUM,1,(flags.maximum_drive_number-127) ,ESCR,(flags.drive_number-127),0,NULL,NULL); if( (new_drive_number<=0) || (new_drive_number>(flags.maximum_drive_number-127)) ) { flags.drive_number=old_drive_number; } else { flags.drive_number=new_drive_number+127; } }
/* Delete Primary DOS Partition Interface */ void Delete_Primary_DOS_Partition_Interface() { int input=0; int partition_to_delete; Clear_Screen(0); Print_Centered(4,"Delete Primary DOS Partition",BOLD); Display_Primary_Partition_Information_SS(); BlinkPrintAt(4,19,"WARNING!"); printf(" Data in the deleted Primary DOS Partition will be lost."); printAt(4,20,"What primary partition do you want to delete..? "); flags.esc=FALSE; input=(int)Input(1,52,20,NUM,1,4,ESCR,-1,0,NULL,NULL); /* 4 needs changed to the max num of partitions */ if(flags.esc==FALSE) { partition_to_delete=input-1; printAt(4,22,"Are you sure (Y/N)..............................? "); flags.esc=FALSE; input=(int)Input(1,54,22,YN,0,0,ESCR,0,0,NULL,NULL); if( (input==TRUE) && (flags.esc==FALSE) ) { Delete_Primary_Partition(partition_to_delete); Clear_Screen(0); Print_Centered(4,"Delete Primary DOS Partition",BOLD); /* */ Display_Primary_Partition_Information_SS(); cprintAt(4,21,"Primary DOS Partition deleted"); Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); } } }
/* Ask user if they want to use large disk support (FAT 32) */ void Ask_User_About_FAT32_Support() { Clear_Screen(0); Print_Centered(5,"Free FDISK is capable of using large disk support to allow you to ",0); Print_Centered(6,"create partitions that are greater than 2,048 MB by using FAT32 ",0); Print_Centered(7,"partitions. If you enable large disk support, any partitions or ",0); Print_Centered(8,"logical drives greater than 512 MB will be created using FAT32. ",0); Print_Centered(10,"IMPORTANT: If you enable large disk support, some operating systems ",0); Print_Centered(11,"will be unable to access the partitions and logical drives that are ",0); Print_Centered(12,"over 512 MB in size. ",0); Print_Centered(17,"Do you want to use large disk (FAT32) support (Y/N)....? ",0); flags.fat32=(int)Input(1,62,17,YN,0,0,NONE,1,0,NULL,NULL); }
/* List the Partition Types */ void List_Partition_Types() { int index=0; int row=4; int column=0; do { if( (index==0) || (index==64) || (index==128) || (index==192) ) { Clear_Screen(0); Print_Centered(1,"List Partition Types",BOLD); row=4; column=0; } if( row==20 ) { row=4; column += 20; } cprintAt(column,row,"%3d ",index); printf("%s",partition_lookup_table_buffer_long[index]); if( (index==63) || (index==127) || (index==191) || (index==255) ) { printAt(0,23,"Press ");cprintf("Any Key");printf(" to continue"); asm{ mov ah,7 int 0x21 } } row++; index++; }while(index<=255);
/* Check for interrupt 0x13 extensions */ void Check_For_INT13_Extensions() { int carry; int drive_number=0x80; //- unsigned int ah_register; unsigned char ah_register; unsigned int bx_register; unsigned int cx_register; #ifdef DEBUG if(debug.lba==TRUE) { Clear_Screen(NULL); Print_Centered(0,"void Check_For_INT13_Extensions() debugging screen",BOLD); printf("\n\n drive int 0x13 ext? access w/packet\n\n"); } #endif do { // carry=99; carry=0; asm{ mov ah,0x41 mov bx,0x55aa mov dl,BYTE PTR drive_number int 0x13 mov BYTE PTR ah_register,ah mov WORD PTR bx_register,bx mov WORD PTR cx_register,cx // jnc carry_flag_not_set /* Jump if the carry flag is clear */ // } /* If the carry flag is clear, then */ // /* the extensions exist. */ // carry=1; // part_table[(drive_number-128)].ext_int_13=FALSE; adc WORD PTR carry,0 /* Set carry if CF=1 */ } // carry_flag_not_set: // if( (carry==99) && (bx_register==0xaa55) ) part_table[(drive_number-128)].ext_int_13=FALSE; if( (!carry) && (bx_register==0xaa55)) { flags.use_extended_int_13=TRUE; part_table[(drive_number-128)].ext_int_13=TRUE; if((cx_register&0x0001)==1) part_table[(drive_number-128)].device_access_using_packet_structure=TRUE; else part_table[(drive_number-128)].device_access_using_packet_structure=FALSE; part_table[(drive_number-128)].ext_int_13_version=ah_register; #ifdef DEBUG if(debug.lba==TRUE) { printf(" 0x%2x yes",drive_number); if((cx_register&0x0001)==1) printf(" yes"); else printf(" no"); printf("\n"); } #endif } #ifdef DEBUG else if(debug.lba==TRUE) printf(" 0x%2x no\n",drive_number); #endif drive_number++; }while(drive_number<0x88); #ifdef DEBUG if(debug.lba==TRUE) { printf("\n\n\n"); Pause(); } #endif }
/* Display Or Modify Logical Drive Information in the extended partition */ void Display_Or_Modify_Logical_Drive_Information() { char char_number[1]; int continue_loop; int index; int input; int input_ok; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; Beginning: Clear_Screen(NOEXTRAS); if(flags.extended_options_flag==FALSE) Print_Centered(1,"Display Logical DOS Drive Information",BOLD); else Print_Centered(1,"Display/Modify Logical DOS Drive Information",BOLD); Display_Extended_Partition_Information_SS(); if(flags.extended_options_flag==FALSE) Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); else { printAt(4,18,"Enter the character of the logical drive you want to modify.....?"); Determine_Drive_Letters(); continue_loop=TRUE; do { flags.esc=FALSE; if( (flags.del_non_dos_log_drives==TRUE) && (pDrive->num_of_non_dos_log_drives>0) ) { if(pDrive->num_of_non_dos_log_drives>9) pDrive->num_of_non_dos_log_drives=9; itoa(pDrive->num_of_non_dos_log_drives,char_number,10); input=(int)Input(1,69,18,CHAR,68,90,ESCC,0,0,"1",char_number); } else input=(int)Input(1,69,18,CHAR,68,90,ESCC,0,0,NULL,NULL); if(flags.esc==FALSE) { /* Ensure that the entered character is legitimate. */ index=4; do { if( (drive_lettering_buffer[(flags.drive_number-128)] [index]>0) && (drive_lettering_buffer[(flags.drive_number-128)] [index]==input) ) { input=index-4; input_ok=TRUE; index=30; /* break out of the loop */ } index++; }while(index<=26); } if(input_ok==TRUE) continue_loop=FALSE; if(flags.esc==TRUE) continue_loop=FALSE; }while(continue_loop==TRUE); if( (input_ok==TRUE) && (flags.esc==FALSE) ) { Modify_Extended_Partition_Information(input); goto Beginning; } } }
/* Delete Logical Drive Interface */ int Delete_Logical_Drive_Interface() { char char_number[2]; int drive_to_delete=0; int index=0; int input=0; int input_ok; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; Clear_Screen(0); Print_Centered(1,"Delete Logical DOS Drive(s) in the Extended DOS Partition",BOLD); Display_Extended_Partition_Information_SS(); BlinkPrintAt(4,19,"WARNING!"); printf(" Data in a deleted Logical DOS Drive will be lost."); printAt (4,20,"What drive do you want to delete...............................? "); Determine_Drive_Letters(); //char drive_lettering_buffer[8] [27]; this line is for reference /* Place code to find the min and max drive letter here. */ input_ok=FALSE; do { flags.esc=FALSE; if( (flags.del_non_dos_log_drives==TRUE) && (pDrive->num_of_non_dos_log_drives>0) ) { if(pDrive->num_of_non_dos_log_drives>9) pDrive->num_of_non_dos_log_drives=9; itoa(pDrive->num_of_non_dos_log_drives,char_number,10); input=(int)Input(1,69,20,CHAR,67,90,ESCR,0,0,"1",char_number); } else input=(int)Input(1,69,20,CHAR,67,90,ESCR,0,0,NULL,NULL); /* Note: min_range and max_range will need adjusted!!!!! */ /* Changes will have to be made because the first logical drive letter */ /* on the selected drive may not be D:, the drive letters on the */ /* drive may not be sequential. */ if(flags.esc==TRUE) return(1); if(flags.esc==FALSE) { /* Ensure that the entered character is legitimate. */ index=4; do { if( (drive_lettering_buffer[(flags.drive_number-128)] [index]>0) && (drive_lettering_buffer[(flags.drive_number-128)] [index]==input) ) { input=index-4; input_ok=TRUE; index=30; /* break out of the loop */ } index++; }while(index<=26); } }while(input_ok==FALSE); drive_to_delete=input; printAt(4,22,"Are you sure (Y/N)..............................? "); flags.esc=FALSE; input=(int)Input(1,54,22,YN,0,0,ESCR,0,0,NULL,NULL); if( (input==TRUE) && (flags.esc==FALSE) ) { Delete_Logical_Drive(drive_to_delete); Clear_Screen(0); Print_Centered(1,"Delete Logical DOS Drive(s) in the Extended DOS Partition",BOLD); Display_Extended_Partition_Information_SS(); input=(int)Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); } return(0); }
/* Returns a 0 if successful and a 1 if unsuccessful */ int Create_Logical_Drive_Interface() { long input=0; int drive_created=FALSE; int maximum_possible_percentage; int numeric_type; long maximum_partition_size_in_MB; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; Determine_Free_Space(); if(pDrive->ext_part_largest_free_space>=2) { do { if(flags.fprmt==TRUE) flags.fat32=TRUE; maximum_partition_size_in_MB = Max_Log_Part_Size_In_MB(); Clear_Screen(0); if(drive_created==TRUE) { cprintAt(4,22,"Logical DOS Drive created, drive letters changed or added"); } Print_Centered(1,"Create Logical DOS Drive in the Extended DOS Partition",BOLD); Display_Extended_Partition_Information_SS(); if('Z'==Determine_Drive_Letters()) { printAt(4,22," "); cprintAt(4,22,"Maximum number of Logical DOS Drives installed."); Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); if(flags.fprmt==TRUE) flags.fat32=FALSE; return(1); } printAt(4,17,"Total Extended DOS Partition size is "); if( (flags.version==4) || (flags.version==5) || (flags.version==6) ) cprintf("%4d",pDrive->ext_part_size_in_MB); else Print_UL_B(pDrive->ext_part_size_in_MB); printf(" Mbytes (1 Mbyte = 1048576 bytes)"); printAt(4,18,"Maximum space available for partition is "); if( (flags.version==4) || (flags.version==5) || (flags.version==6) ) cprintf("%4d",maximum_partition_size_in_MB); else Print_UL_B(maximum_partition_size_in_MB); printf(" Mbytes "); maximum_possible_percentage = Convert_To_Percentage(maximum_partition_size_in_MB ,pDrive->ext_part_size_in_MB); cprintf("(%3d%%)",maximum_possible_percentage); printAt(4,20,"Enter logical drive size in Mbytes or percent of disk space (%)..."); flags.esc=FALSE; if( (flags.version==4) || (flags.version==5) || (flags.version==6) ) input=Input(4,70,20,NUMP,1,maximum_partition_size_in_MB,ESCR ,maximum_partition_size_in_MB,maximum_possible_percentage,NULL,NULL); else input=Input(6,70,20,NUMP,1,maximum_partition_size_in_MB,ESCR ,maximum_partition_size_in_MB,maximum_possible_percentage,NULL,NULL); if(flags.esc==TRUE) { if(flags.fprmt==TRUE) flags.fat32=FALSE; return(1); } if( (flags.fprmt==TRUE) && (input>=128) && (input<=2048) ) { printAt(4,21,"This drive is a FAT32 by default, switch to FAT16 (Y/N)? "); flags.fat32=!Input(1,61,21,YN,0,0,NONE,1,0,NULL,NULL); } numeric_type=6; numeric_type=Partition_Type_To_Create(input,numeric_type); Create_Logical_Drive(numeric_type,input); drive_created=TRUE; }while(pDrive->ext_part_largest_free_space>=2); } Clear_Screen(0); Print_Centered(1,"Create Logical DOS Drive in the Extended DOS Partition",BOLD); Display_Extended_Partition_Information_SS(); cprintAt(4,22,"All available space in the Extended DOS Partition"); cprintAt(4,23,"is assigned to logical drives."); Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); if(flags.fprmt==TRUE) flags.fat32=FALSE; return(0); }
/* Create DOS Partition Interface */ int Create_DOS_Partition_Interface(int type) { int numeric_type; int partition_created=FALSE; int partition_slot_just_used; long maximum_partition_size_in_MB; long maximum_possible_percentage; unsigned long input=0; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; maximum_partition_size_in_MB = Max_Pri_Part_Size_In_MB(type); if(type==PRIMARY) { Clear_Screen(0); Print_Centered(4,"Create Primary DOS Partition",BOLD); printAt(4,6,"Current fixed disk drive: "); cprintf("%d",(flags.drive_number-127)); printAt(4,8,"Do you wish to use the maximum available size for a Primary DOS Partition"); if((flags.drive_number-128)==0) { printAt(4,9,"and make the partition active (Y/N).....................? "); } else { printAt(4,9,"(Y/N)...................................................? "); } flags.esc=FALSE; input=Input(1,62,9,YN,0,0,ESCR,1,0,NULL,NULL); if(flags.esc==TRUE) return(1); if(input==1) { input=maximum_partition_size_in_MB; numeric_type=6; /* Set the numeric type to 6 so that it will be */ /* decided by Partition_Type_To_Create(). */ if( (flags.fprmt==TRUE) && (type==PRIMARY) && (input>=128) && (input<=2048) ) { printAt(4,22,"This drive is a FAT32 by default, switch to FAT16 (Y/N)? "); flags.fat32=!Input(1,61,22,YN,0,0,NONE,1,0,NULL,NULL); } /* Use the maximum available free space to create a DOS Partition */ /* Adjust numeric type depending upon partition size and the FDISK */ /* version emulated. */ numeric_type=Partition_Type_To_Create(input,numeric_type); partition_slot_just_used=Create_Primary_Partition(numeric_type,input); if((flags.drive_number-128)==0) Set_Active_Partition(partition_slot_just_used); partition_created=TRUE; } } if(partition_created==FALSE) { Clear_Screen(0); if(type==PRIMARY) Print_Centered(4,"Create Primary DOS Partition",BOLD); else Print_Centered(4,"Create Extended DOS Partition",BOLD); printAt(4,6,"Current fixed disk drive: "); cprintf("%d",(flags.drive_number-127)); Display_Primary_Partition_Information_SS(); printAt(4,15,"Maximum space available for partition is "); if( (flags.version==W95) || (flags.version==W95B) || (flags.version==W98) ) Print_UL_B(maximum_partition_size_in_MB); else cprintf("%4d",maximum_partition_size_in_MB); printf(" Mbytes "); maximum_possible_percentage = Convert_To_Percentage(maximum_partition_size_in_MB ,pDrive->total_hard_disk_size_in_MB); cprintf("(%3d%%)",maximum_possible_percentage); printAt(4,18,"Enter partition size in Mbytes or percent of disk space (%) to"); if(type==PRIMARY) printAt(4,19,"create a Primary DOS Partition.................................: "); else printAt(4,19,"create an Extended DOS Partition...............................: "); flags.esc=FALSE; if( (flags.version==4) || (flags.version==5) || (flags.version==6) ) input=Input(4,69,19,NUMP,1,maximum_partition_size_in_MB,ESCR ,maximum_partition_size_in_MB,maximum_possible_percentage,NULL,NULL); else input=Input(6,69,19,NUMP,1,maximum_partition_size_in_MB,ESCR ,maximum_partition_size_in_MB,maximum_possible_percentage,NULL,NULL); if(flags.esc==TRUE) return(1); if( (flags.fprmt==TRUE) && (type==PRIMARY) && (input>=128) && (input<=2048) ) { printAt(4,22,"This drive is a FAT32 by default, switch to FAT16 (Y/N)? "); flags.fat32=!Input(1,61,22,YN,0,0,NONE,1,0,NULL,NULL); } if(type==PRIMARY) numeric_type=Partition_Type_To_Create(input,0); else numeric_type=5; Create_Primary_Partition(numeric_type,input); } if(flags.fprmt==TRUE) flags.fat32=FALSE; Clear_Screen(0); if(type==PRIMARY) Print_Centered(4,"Create Primary DOS Partition",BOLD); else Print_Centered(4,"Create Extended DOS Partition",BOLD); printAt(4,6,"Current fixed disk drive: "); cprintf("%d",(flags.drive_number-127)); Display_Primary_Partition_Information_SS(); Position_Cursor(4,21); if(type==PRIMARY) cprintf("Primary DOS Partition created"); else cprintf("Extended DOS Partition created"); Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); if(type==EXTENDED) Create_Logical_Drive_Interface(); return(0); }