Closed Thread
Page 1 of 5 123 ... LastLast
Results 1 to 10 of 46

Thread: How to get floppy disk information ?!!

  1. #1
    Master's Avatar
    Master is offline Newbie
    Join Date
    Jun 2007
    Location
    Somwhere Nearby,Who cares...
    Posts
    13
    Rep Power
    0

    How to get floppy disk information ?!!

    hi guys ..im asking for your help on solving this mind boggling problem ...
    you know 2 or 3 month ago i wrote this piece of code in order to get the floppy disk geometry ...and it was as follows:
    Code:
    //In the name of GOD
    
    
    #include <conio.h>
    #include <stdio.h>
    #include <process.h>
    #include <dos.h>
    #include <stdlib.h>
    main(void){
    int i,k,start,sector;
    char x[512];
    clrscr();
    gotoxy(27,5);
    textcolor(2);
    cprintf("In the name of God\n");
    gotoxy(22,7);
    printf ("First project  Project\n\n");
    cprintf ("         This program will show you the information stored on sector 0  of your Floppy disk.\n              if you are ready press any key to continue ");
    for (k=0;k<=4;k++){
    delay(500);
    cprintf(".");       }
    getch();
    sector =0;
    if (absread (0, 1, sector, &x)!=0){
    cprintf ("Error");
    exit(1);
    }
    gotoxy(30,8);
    cprintf("Read Successful!\n\n\n");
    for (i=0;i<=512;i++)
    cprintf("%c",x[i]);
    getch();
    return 0;
    }
    after that i see some irrelevant characters on screen ... i just went after it and found some progs and also information concerning FAT
    and it was :
    Code:
    {
      char jumpCode[3];//0 - 2 	Assembly Instruction for jump code.
       char oemName[8];//3 - 10 	OEM Name.
       char bytes_Sector[2];//*11 - 12 	Bytes per sector.
       char sec_Cluster;//13 	Sector per cluster.
       char size_Sector_Reserved[2];//14 - 15 	Number of reserved sector(Boot Sector)
       char fatCount;//16 	Number of File Allocation Table
       char Max_Root_Entry[2];//17 - 18 	Maximum entries possible under root directory.
       char Total_Sector_FS[2];//19 - 20 	Total number of sectors in file system.
       char Media_Type;//21 	Media Type(According to Microsoft 0xf8 for fixed disk and 0xf0 for removable disk.
       char sectors_per_fat[2];//22 - 23 	Sectors allocated for each File allocation table.
       char sectors_per_track[2];//24 - 25 	Sectors per track.
       char total_Head_Count[2];//26 - 27 	Number of head in storage device.
       char no_Sectors_Before_Part[4];//28 - 31 	Number of sectors before start of partition(Not applicable for floppy).
       char no_Sector_FS32[4];//32 - 35 	Number of sectors in file system(32-bit value, not applicable for floppy).
       char BIOS_13h_Drive_No;//36 	BIOS INT13h drive number.
       char reserved;//37 	Not Used.
       char ext_Boot_Part_Signature;//38 	Extended boot signature.
       char vol_Serial_Number[4];//39 - 42 	Volume Serial Number.
       char vol_Lebel_Name[11];//43 - 53 	Volume label in ASCII.
       char FS_Type[8];//54 - 61 	File System Type.
       char boot_Code[448];//62 - 509 	Boot Code, otherwise contains information to replace disk.
       char signature[2];//510 - 511 	Signature for File System.
    i just tried to use loops to save the data of the specific regions of the floppy disk on the screen for example i used:
    Code:
    for(j=0;j<=2;j++)
    printf("Assembly instruction for jump code : %C",&x[j])
    but again no luck !!
    im really confused !!! how to deal with it in C?
    (ive already noticed the VC++ equivalent but i have not worked on Vc++ ,so i dont know anything about that ...please tell me and help me on C .... tell me how i can do it under C

    oh by the way i was using TC 3 ..thats why it looks ancient ..( im using Pelles C now ..but it seems it doesnt have some header files such as Dos.h ..so i just used TC )

    many tanx in advand
    Last edited by Master; 11-08-2007 at 10:02 PM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    TkTech's Avatar
    TkTech is offline The Crazy One
    Join Date
    Jun 2006
    Location
    Canada
    Posts
    1,412
    Blog Entries
    1
    Rep Power
    31
    the first sector of any fat disk is the bootsector. This stores a program that can be used to load a kernel or a boostrap, and it also stores the header information for the fat12 filesystem. it will always be padded to take up the entire section, anything else is a corrupt disk. use the structure you posted and sizeof() to load in the data for the filesystem table.

  4. #3
    Master's Avatar
    Master is offline Newbie
    Join Date
    Jun 2007
    Location
    Somwhere Nearby,Who cares...
    Posts
    13
    Rep Power
    0
    would you mind if i ask you to show me how to do that ?
    i mean usuing sizeof ? you mean sth like this ?
    scanf("%c ",&sizeof(fdi.jumpcodes);
    you mean sth like this ? if not i will be very thankfull if you correct me

    tanx a million

  5. #4
    Master's Avatar
    Master is offline Newbie
    Join Date
    Jun 2007
    Location
    Somwhere Nearby,Who cares...
    Posts
    13
    Rep Power
    0
    ive changed the code completely.. and here it is ,,,
    Code:
    //In the name of GOD
    #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;
        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 your hard Drive.\n              if you are ready press any key to continue ");
        for (k=0;k<=4;k++){
        //delay(50);
        printf(".");       }
        getch();
        sector =0;
        if (absread (0, 1, sector, buf)!=0)
    	{
        printf ("Error");
        exit(1);
           }
    
    
       printf("Read Successful!\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("\a                  Phase One is now being started\n\n\n");
    		for(j=0;j<=2;j++)
    			printf("Assembly Jump COde is: %#02x \n\n",buf[j]);
    
    			printf("OEM IS:  %7s\n\n",&buf[j]);
    	      for(j=11;j<12;j++);
    		       printf("Bytes per sector:  %d\n\n",buf[j]);
    
    		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("fat count :   %d\n\n",buf[j]);
    		printf("\a\aPhase 2:get ready for the next infos, when readly press enter\n\n\n\n\n");
    		getch();
    		delay(1000);
    
    		for(j=17;j<18;j++)
    		 printf("Max root entry is:   %d\n\n",buf[j]);
    
    
    	    for(j=19;j<=20;j++)
    		    printf("Total number of sectors in file system is:  %d\n\n\n ",  buf[j]);
    
    	    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",buf[j]);
    
    		printf("Phase 3: this is going to be the third part, get ready and press Enter\a\a\a\n\n\n");
    		getch();
    		delay(1000);
    
    	      // 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:        %d\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 Numberis  %d\n",buf[j]);
    
    	       for(j=43;j<=53;j++)
    	       printf("Volume label in ASCII %11s\n\n",buf[j]);
    
    
    	      for(j=54;j<=61;j++);
    	      printf("File System Type %c\n\n",buf[j]);
    	     printf("\a\a\a\aPhase 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++)
    		printf("%#x",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("     Date November 10th 2007 equals to 20 Aban 1386");
        getch();
        return 0;
    }
    Please tell me if any thing is wrong ..
    tanx in advance

  6. #5
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,514
    Blog Entries
    8
    Rep Power
    59
    Close, but not right. Try using this:

    scanf("%*c",sizeof(fdi.jumpcodes),&fdi.jumpcodes);

  7. #6
    Master's Avatar
    Master is offline Newbie
    Join Date
    Jun 2007
    Location
    Somwhere Nearby,Who cares...
    Posts
    13
    Rep Power
    0
    tanx

  8. #7
    Master's Avatar
    Master is offline Newbie
    Join Date
    Jun 2007
    Location
    Somwhere Nearby,Who cares...
    Posts
    13
    Rep Power
    0
    by the way i made it some how .. but there is a slight problem here ..
    i have difficulties on three point :
    1. Bytes per sector(instead of getting 512 , i get 1!)
    2.Number of files for root directory(instead of getting 224 , i get 64)
    3.Total number of sectors in file system is (instead of geting 2880 i get sth else ..1 or 11 i think ... )

    i tried using Sizeof() but id ddint help ... i even used "&" before the Buf[j], but i get a negative number !!!, i really dont know why ..
    and after all , i made me add those variables to correct the information ..
    is there any body who knows why this is happenig ? or why this gave me a negative numbers ..
    here is what i wrote :








    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;
    }

  9. #8
    Master's Avatar
    Master is offline Newbie
    Join Date
    Jun 2007
    Location
    Somwhere Nearby,Who cares...
    Posts
    13
    Rep Power
    0
    well , i decided to use a structure to hold data ..tell me if anything is wrong ... thanks
    Code:
    //In the name of GOD
    /* Using Structure to hold data 
    version 0.1
    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*/
    //||||||||||||||||||Define Session||||||||||||||||||||||
    typedef unsigned char BYTE;
    typedef short int     WORD;
    typedef int          DWORD;
    //|||||||||||||||||||Main Session|||||||||||||||||||||||
    void profile_1(void);
    #include <stdio.h>
    #include <process.h>
    #include <string.h>
    #include <conio.h>
    #include <dos.h>
    
     int main(void)
    {
    //|||||||||||||||||||Structure To hold data|||||||||||||
    struct Floppy_DISK_INFORMATION
    {
       BYTE jumpCode[3];
       BYTE oemName[8];
       WORD bytes_Sector;
       BYTE sec_Cluster;
       WORD size_Sector_Reserved;
       BYTE fatCount;
       WORD Max_Root_Entry;
       WORD Total_Sector_FS;
       BYTE Media_Type;
       WORD sectors_per_fat;
       WORD sectors_per_track;
       WORD total_Head_Count;
       DWORD no_Sectors_Before_Part;
       DWORD no_Sector_FS32;
       BYTE BIOS_13h_Drive_No;
       BYTE reserved;
       BYTE ext_Boot_Part_Signature;
       DWORD vol_Serial_Number;
       BYTE vol_Lebel_Name[11];
       BYTE FS_Type[8];
       BYTE boot_Code[448];
       WORD signature;
    } fdi;
    
    //|||||||||||||||||||Declaring variables|||||||||||||||||
        int j,i,start,sector;
        char buf[512];
        profile_1();
        sector =0;
    //|||||||||||||||||Reading From Floppy Disk |||||||||||||
        if (absread (0, 1, sector,&fdi)!=0)
    	{
        printf ("An Error Has Occurred!");
        exit(1);
           }
    
    
       printf("Read Seccessfully !\n");
    
     // fptr=fopen("D:\temp.fds","w");
     // for (i=0;i<=1;i++)
       //	{	    // Print floppy information on Console.
    
       printf("Floppy Disk Information: \n");
       printf("===========================\n");
       printf("Assembly Instruction to jump to Boot code: 0x%x\n",
    	  fdi.jumpCode);
       printf("OEM Name: %s\n",&fdi.oemName);
       printf("Bytes per sector: %d\n",fdi.bytes_Sector);
       printf("Sector per cluster: %d\n", fdi.sec_Cluster);
       printf("Size in sector for reserved area(Boot Sector): %d\n",
    	  fdi.size_Sector_Reserved);
       printf("Number of FATs(File Allocation Table): %d\n",
    	  fdi.fatCount);
       printf("Number of files for root directory: %d\n",
    	   fdi.Max_Root_Entry);
       printf("Number of Sectors in File System: %d\n",
    	  fdi.Total_Sector_FS);
       printf("Media Type\n(According to Microsoft,0xF8 == fixed disk and 0xF0 == Removable disk):0x%x\n", fdi.Media_Type);
       printf("Number of Sectors for each FAT: %d\n",
    	  fdi.sectors_per_fat);
       printf("Sectors per track: %d\n", fdi.sectors_per_track);
       printf("Number of head in storage device: %d\n",
    	  fdi.total_Head_Count);
       printf("BIOS INT13h Drive number: 0x%x\n", fdi.BIOS_13h_Drive_No);
       printf("Volume Serial Number: %d\n", fdi.vol_Serial_Number);
       printf("Volume label Name: %s\n", fdi.vol_Lebel_Name);
       printf("Boot Sector Signature: 0x%x\n", fdi.signature);
    	     printf("                 Programed By Seyyed Hossein Hasan Pour\n");
    	     printf("                         November 10th 2007 ");
    	 printf("\n                          wWw.Persianos.org ");    
    getch();
         return 0;
        }
    void profile_1(void)
    {   int k;
        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();
        }
    Last edited by Master; 11-25-2007 at 06:11 PM.

  10. #9
    dinklebaga is offline Newbie
    Join Date
    Mar 2009
    Posts
    23
    Rep Power
    0

    Re: How to get floppy disk information ?!!

    Master,
    I have read the article where you originally got this from and was interested in doing it in c myself but when i try and print out the data it is no formatting it correctly. Did you obtain a working solution to this?

  11. #10
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,514
    Blog Entries
    8
    Rep Power
    59

    Re: How to get floppy disk information ?!!

    What're you printing out? Some strings, like the OEM, aren't null terminated. Could you post your code? (And please put it in between the CODE tags. Click on the pound sign thing when posting.)

Closed Thread
Page 1 of 5 123 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Loose disk??
    By bbqroast in forum Technology Ramble
    Replies: 3
    Last Post: 10-16-2010, 11:37 PM
  2. Disk Failure
    By lor in forum The Lounge
    Replies: 15
    Last Post: 10-08-2010, 03:24 AM
  3. Floppy DUO | Metallica - Fade To Back
    By Turk4n in forum The Lounge
    Replies: 10
    Last Post: 05-04-2009, 04:19 PM
  4. Compilers that fit on floppy?
    By jayrare in forum General Programming
    Replies: 24
    Last Post: 07-03-2008, 07:37 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts