How to get floppy disk information ?!!

This is a discussion on How to get floppy disk information ?!! within the C Programming forums, part of the General Programming Boards category; What part do you want to "know if it works"? I don't have a TC compiler, nor am I going ...

  1. #31
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    What part do you want to "know if it works"? I don't have a TC compiler, nor am I going to install one, so I can't really test your code out. Not that my machine has a floppy drive anyways.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  2. #32
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,851
    Well I count 3 mistakes just from looking at it.

    I've got a floppy drive, but no inclination to use TurboC.

    Also printing "\a" is one of those things which seems really neat on the first day you write a program, and it gets really old really fast thereafter.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #33
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    so what are those mistakes? salem?

  4. #34
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,851
    for(j=11;j<12;j++);
    A trailing ;, and you do this in 3 places.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #35
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    ive changed some parts and now , it works great..tanx to you guys for your kind answers and patience ..
    here it is

    Code:
    //In the name of GOD
    //VERSION 1.0.1
    /* 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
    
    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;
        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\" &#37;d\" is: %#x \n\n",j,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\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("Max root entry is:   %#X\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\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:        %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 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                                Thats All  ");
        getch();
        return 0;
    }
    and salem about what you mentioned above,, i gotta say that in TC there is no error ..even a warning thats why i just left it blank ...

  6. #36
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    A semicolon after a for-loop doesn't give an error - it may well be what you actually want in some cases, as it means "don't do anything in the loop". For example, we can write code like this:
    Code:
    for(i = 0; i < 10; i++) sum += i;
    or:
    Code:
    for(i = 0; i< 10; sum += i, i++) ;
    Both do the same thing, one does things IN the loop, the other doesn't.

    But I'm sure in your case, you actually want to print two values from 13 to 14, etc.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #37
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,851
    Compare
    for ( i = 0 ; i < 10 ; i++ ) printf("%d\n", i );

    With
    for ( i = 0 ; i < 10 ; i++ ); printf("%d\n", i );

    One character difference in the source code, very different results.
    Both are perfectly valid C, yet one of them doesn't do what you want.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #38
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    so now i see ...
    tanx for the tip . .. let me go over the prog again ...

  9. #39
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    hey guys im sorry om back on this topic again .. but i got a slihgt problem and solved that in a weird way
    i know this is not a correct way of solving problems specially in programing ..but i had no other choices .. i noticed that all of the information concerning the floppy disk geometry grabbed by my program is true but 3 of them ...and they are:
    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\" &#37;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;
    }

  10. #40
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,851
    Dunno, your code contains the same mistakes I pointed out a week ago.

    I really can't be bothered to play this game any more, you're not going to listen anyway, so there's really no point is there?

    So I guess you'll just have to ask some other god for help instead.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  11. #41
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    well , you told me sth about loops and for .. but if i do so , i wont get the correct answer , thats why i just left them blank .. ( i mean i didnt use ";" after my loops )
    if use them the result would be completely different . i tried what you ve told me ..but i got erros .. ( well as default procedure ... i use ";" for every loop .. i know what you meant by that .. thanks for that .. but if you can remember , i mentioned that there would be errors concerning this matter

    So , to cut a long story short , i DID not mean to offend you or to cop with your ideas .... I realy appreciate your kindness and generosity of sharing your time and knowledge to help me out ..
    i really admit that .i ow you guys very much ... i fi did sth , contrary to your opinion , i didnt mean anything , please forgive me for any mis understanding

    well at last , i think i made it a bit clearer ...
    by the way , you know the reason i sticked to this dos based compiler is that ... to me as mat told me to .. to finish the job i ve started .. and if there is any means ( even primitive and ancient ) that can be used to get what i want out of a floppy disk .. i must do it ... this is considered a challenge to me . and i need your experience and knowledge to overcome this challenge ...
    thank you again .. and im so sorry if i did sth wrong that made such a mis understanding ...

  12. #42
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Surely a 512 bytes sector doesn't contain the right information at an offset described by:
    Code:
    int C_S=1030; //Correct Sector
    This is roughly two times the size of the data you read... This is CLEARLY not the right way to solve your problem.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #43
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    Quote Originally Posted by matsp View Post
    Surely a 512 bytes sector doesn't contain the right information at an offset described by:
    Code:
    int C_S=1030; //Correct Sector
    This is roughly two times the size of the data you read... This is CLEARLY not the right way to solve your problem.

    --
    Mats
    well , thats why im here bro ..
    i need to know first of all why this is happening ...everything seemed to be ok but ..
    now what do you say ? ?!!

  14. #44
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Masterx View Post
    well , thats why im here bro ..
    i need to know first of all why this is happening ...everything seemed to be ok but ..
    now what do you say ? ?!!
    What I'm saying is that you don't understand what we're saying, and you are just GUESSING on the solution by doing strange things. Adding 1030 to an index into a buffer of 512 is obviously not the right solution. Listen to what Salem and I have been saying - you are printing rubbish in some places, because you are NOT printing inside the loop. If you have a loop that goes for(i = 0; i < 6; i++), when the loop is finished, i will be 6, which is probably not what you wanted to print to show index 0..5, right?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  15. #45
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    Yep .. got it ... let me do sth and i l inform ya ..
    tanx

Page 3 of 4 FirstFirst 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. floppy disk filesystems
    By Leeman_s in forum Tech Board
    Replies: 5
    Last Post: 12-10-2003, 04:54 PM
  2. Going out of scope
    By nickname_changed in forum C++ Programming
    Replies: 9
    Last Post: 10-12-2003, 07:27 PM
  3. Formatting Output
    By Aakash Datt in forum C++ Programming
    Replies: 2
    Last Post: 05-16-2003, 09:20 PM
  4. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-21-2002, 12:35 AM
  5. Information about disk
    By GaPe in forum C Programming
    Replies: 18
    Last Post: 08-05-2002, 07:48 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21