Code:
//In the name of GOD
//VERSION 1.0.2
/* These Codes were written in order to extract floppy geometry information ,i tested this snippets of code under Dos 16 bit based Compilers such as Tc
and it run great !
A Piece of COde that extracts floppy disk geometry information, its been writen in pure C and has been tested and ran seccessfully under TC 3 ...
Cod3r :Seyyed HOssein hasn pour in NOvember 12th 2007
www.PersianOs.org
Floppy DIsk information grabber ... fixed some bugs :lol
runs perfecly under Dos 16 bit based compilers... like TC (ancient fossil compiler :lol)
*/
#include <stdio.h>
#include <process.h>
#include <string.h>
#include <conio.h>
#include <dos.h>
int main(void)
{
int j,i,k,start,sector;
char buf[512],ch;
int C_S=1030; //Correct Sector
int S_R=735;//Correct File Numbers for Root Directory
int S_F=3389;//Correct Sector numbers In File System
clrscr();
gotoxy(27,5);
printf("In the name of God\n");
gotoxy(22,7);
printf("A S.Hossein hasan pour Project\n\n");
printf ("This program will show you the information stored on sector 0 of the Floppy Disk\n\n (FAT TABLE INFORMATION).\n\n\n if you are ready press any key to continue ");
for (k=0;k<=3;k++){
//delay(50);
printf("."); }
getch();
sector =0;
if (absread (0, 1, sector, buf)!=0)
{
printf ("Error");
exit(1);
}
printf("Read Seccessfully !\n");
// fptr=fopen("D:\temp.fds","w");
// for (i=0;i<=1;i++)
// {
printf("\n\n Begining Of the readind Infos from floppy disk\n\n\n");
printf(" Phase One is now being started\n\n\n");
for(j=0;j<=2;j++)
printf("Assembly Jump COde for byte\" %d\" is: %#x \n\n",j,buf[j]);
printf("OEM IS: %s\n\n",&buf[j]); //by formating the floppy disk you will get diffrent OEM names.to test this , just quick-format the floppy disk and run the program(make sure the flopy disk remains empty)
for(j=11;j<12;j++);
printf("Bytes per sector: %d *\n\n",&buf[j+C_S]);
for(j=13;j<14;j++);
printf("sector per cluster is : %d\n\n",buf[j]);
for(j=14;j<15;j++)
printf("number of reserved sectors : %d\n\n",buf[j]);
for(j=16;j<17;j++)
printf("Number of Fats(File Allocation Table) : %d\n\n\n",buf[j]);
printf(" Phase 2:get ready for the next infos, when readly press enter\n\n\n\n\n");
getch();
delay(500);
for(j=17;j<=18;j++);
printf("Number of files for root directory: %d *\n\n",&buf[j+S_R]);
for(j=19;j<=20;j++);
printf("Total number of sectors in file system is: %d *\n\n\n ",&buf[j+S_F]);
for(j=21;j<22;j++)
printf("Media Typeis:%#x\n\n",buf[j]);
printf("According to Microsoft 0xf8 for fixed disk and 0xf0 for removable disk\n\n\n");
for(j=22;j<23;j++)
printf("Sectors allocated for each File allocation table is: %d\n\n ",buf[j]);
for(j=24;j<25;j++)
printf("Sectors per track is: %d\n\n",buf[j]);
for(j=26;j<27;j++)
printf("Number of head in storage device is: %d\n\n\n",buf[j]);
printf(" Phase 3: this is going to be the third part, get ready and press Enter\n\n\n\n");
getch();
delay(500);
// for(j=28;j<=31;j++)
//printf("Number of sectors before start of partition(Not applicable for floppy)%d\n ",buf[j]);
// for(j=32;j<=35;j++)
// printf(" Number of sectors in file system(32-bit value, not applicable for floppy).%d\n",buf[j]);
for(j=36;j<37;j++)
printf("BIOS INT13h drive numberis: 0x%x\n\n",buf[j]);
for(j=38;j<39;j++);
printf("Extended boot signature is: %#x\n\n",buf[j]);
for(j=39;j<=42;j++);
printf("Volume Serial Numbers %d\n",buf[j]);
for(j=43;j<=43;j++)
printf("Volume label in ASCII %8s\n\n",buf[j]);
for(j=54;j<=61;j++);
printf("File System Type %c\n\n",buf[j]);
printf("Phase 4:Now get ready for the boot sector infos \n\n\n");
getch();
printf(" Boot Code, otherwise contains information to replace disk( in Assembly codes)\n\n");
for(j=65;j<=509;j++)
//note that you can also use "%#x"instead of"%c" to see the whole codes in hex,and also in that case meaningful,
//This contains both boot sector stuffs and the message altogether ,but as i mentioned before they will be printed as Hex codes
printf("%c",buf[j]);
for(j=510;j<511;j++);
printf("\n\nSignature for File System is: %#x\n\n\n",buf[j]);
printf(" Programed By Seyyed Hossein Hasan Pour\n");
printf(" November 10th 2007 ");
printf("\n wWw.Persianos.org ");
getch();
return 0;
}
Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum