Closed Thread
Page 2 of 5 FirstFirst 1234 ... LastLast
Results 11 to 20 of 46

Thread: How to get floppy disk information ?!!

  1. #11
    dinklebaga is offline Newbie
    Join Date
    Mar 2009
    Posts
    23
    Rep Power
    0

    Re: How to get floppy disk information ?!!

    Its simply the same as master was posting apart from i have had to change a few of the printf statements because the compiler is supplying negative values on output (signed values instead of unsigned)

    Code:
        typedef unsigned char BYTE;
        typedef short int WORD;
        typedef long DWORD;
        typedef struct _BOOT_SECTOR
        {
            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;
            WORD no_Sectors_Before_Part;
            WORD no_Sector_FS32;
            BYTE BIOS_13h_Drive_No;
            BYTE reserved;
            BYTE ext_Boot_Part_Signature;
            WORD vol_Serial_Number;
            BYTE vol_Label_Name[11];
            BYTE FS_Type[8];
            BYTE boot_Code[448];
            WORD signature;
        } BS;
    
        BS _boot;
        unsigned char* memsectptr = (unsigned char *)0x10000000;
        cyl = 0; /*first cylinder*/
        hd = 0; /* first head*/
        sect = 1; /*sector 1*/
    
        asm
        {
            mov bx, 0x1000;
            mov es,bx;
            mov bx,0;
            mov ah,02; /* BIOS read command */
            mov al,1; /*read 1 sector */
            mov ch,cyl; /*cylinder */
            mov cl,sect; /*start @ sector 1 */
            mov dh,hd; /*head */
            mov dl,dr; /*drive */
            int 0x13;  /*run code*/
            mov status,ah;
        }
        memcpy(&_boot, memsectptr, 512);
    
        printf("Floppy Disk Information: \n");
        printf("===========================\n");
        printf("Assembly Instruction to jump to Boot code: 0x%x\n", _boot.jumpCode);
        printf("OEM Name: %s\n",&_boot.oemName);
        printf("Bytes per sector: %u\n",_boot.bytes_Sector);
        printf("Sector per cluster: %d\n", _boot.sec_Cluster);
        printf("Size in sector for reserved area(Boot Sector): %d\n",_boot.size_Sector_Reserved);
        printf("Number of FATs(File Allocation Table): %d\n",_boot.fatCount);
        printf("Number of files for root directory: %d\n", _boot.Max_Root_Entry);
        printf("Number of Sectors in File System: %d\n", _boot.Total_Sector_FS);
        printf("Media Type\n(According to Microsoft,0xF8 == fixed disk and 0xF0 == Removable disk):0x%x\n", _boot.Media_Type);
        printf("Number of Sectors for each FAT: %d\n", _boot.sectors_per_fat);
        printf("Sectors per track: %u\n", _boot.sectors_per_track);
        printf("Number of head in storage device: %d\n", _boot.total_Head_Count);
        printf("BIOS INT13h Drive number: 0x%x\n", _boot.BIOS_13h_Drive_No);
        printf("Volume Serial Number: %lu\n", _boot.vol_Serial_Number);
        printf("Volume label Name: %s\n", &_boot.vol_Label_Name);
        printf("Boot Sector Signature: 0x%x\n", _boot.signature);

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #12
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: How to get floppy disk information ?!!

    Change
    Code:
    printf("OEM Name: %s\n",&_boot.oemName);
    to

    Code:
    printf("OEM Name: %8c\n",_boot.oemName);
    The OEM name is not guaranteed to be null-padded.

  4. #13
    dinklebaga is offline Newbie
    Join Date
    Mar 2009
    Posts
    23
    Rep Power
    0

    Re: How to get floppy disk information ?!!

    Thanks for getting back to me on this dargueta. This is now restricting the length of the string (have done the same for the volume label as well) but now it isn't displaying the text which was previously being displayed (MSDOS 5.0 for OEM NAME and FAT12... for VolLabel) The hex output on the jumpcode etc is also not being displayed correctly. I know what the values of these fields should be as i'm running winHex to display the bootsector to me but really need this coded solution to work!

    Thanks,
    Dinklebaga

  5. #14
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: How to get floppy disk information ?!!

    I didn't see that, actually. The boot code isn't a single number, but actually three individual bytes. Display it as such:

    Code:
    printf("Boot code: %02X %02X %02X\n",_boot.jumpCode[0],_boot.jumpCode[1],_boot.jumpCode[2]);
    The same should be done with the boot sector signature, since the code is 55AAH and not AA55H as a little-endian machine would display it. A shortcut: instead of putting "0x%x" in your printf strings, just put "%#x". It should do the same thing, and will work for any base, including octal and decimal.

    Also, several things wrong with the way you're retrieving the boot sector:
    1) You don't save ES. That's potentially disastrous. Stick in push es as the first line, and pop es as the last line in that block.
    2) Hard-coded pointers: BAD. Each program runs in its own address space, and you have no idea what you're overwriting. You're better off using the address operator and loading the data directly into your BS structure.
    3) Interrupts - NO! This will crash in 32-bit Windows for sure, it's slow, and not guaranteed to work on all computers, even ones with the same OS. Use operating system API. I can show you how to do this on a Windows machine, and you can probably find docs on how to do it on other OSes. If you want an explanation of why this'll crash, I'll be more than happy to write a detailed explanation for you.

    So what exactly are you getting for the OEM and volume label, then?

  6. #15
    dinklebaga is offline Newbie
    Join Date
    Mar 2009
    Posts
    23
    Rep Power
    0

    Re: How to get floppy disk information ?!!

    Thanks dargueta,
    now when i run the code instead of getting 'EB 3C 90' i am getting 'FFEB 3C FF90'. You mentioned something about little endian machines, i know the difference between the two and their importance in a computer system but it appears to me that the code i have is outputting the data into little endian format when the 'big endian' should be the one taking precedence. This maybe why i am getting 258 for the number of bytes in the sector instead of 512 (which is the correct value and stored at offset 0B in the bootsector)?

  7. #16
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: How to get floppy disk information ?!!

    You're probably not zeroing everything before you read into the struct. Try this before you read anything into the boot sector:

    Code:
    memset(&_boot,NULL,sizeof(BS));
    Could you post your current code?

  8. #17
    dinklebaga is offline Newbie
    Join Date
    Mar 2009
    Posts
    23
    Rep Power
    0

    Re: How to get floppy disk information ?!!

    I'm still getting the same result with the leading FF's.
    I had to replace the NULL value with this to get it through the compiler:
    Code:
    memset(&_boot,'\0',sizeof(BS));
    Could it be something to do with the memory model i'm using? I'm using a large model but when i use the small memory model i get: 45 52 52

  9. #18
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: How to get floppy disk information ?!!

    This is really bizarre. I did exactly the same thing a while ago (with this exact thread, actually), and I didn't have this sort of problem. I take it you're using a Borland compiler?

    EDIT: Try changing "%8c" to "%8s". Doubt it'll do anything, but it might.

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

    Re: How to get floppy disk information ?!!

    I'm using the digital mars compiler with the 16bit DOS extender.
    Chagin the code back from "%8c" to "%8c" brings back the "MSDOS 5.0" and the "NO NAME" but i dont think the 11 or 8 (character limitation) is making a difference as extra characters are being added to the label name

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

    Re: How to get floppy disk information ?!!

    So you're still having a problem with extra characters for the jump code?

Closed Thread
Page 2 of 5 FirstFirst 1234 ... 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