Mission accomplished !!:Lol
After all i decided to use a structure to hold data ( i was tired of using loops to give a variable different numbers in order to get what i want(ex.going exactly to the Byte "12" of the floppy disk and then try to read it .. as you guys kindly mentioned it before that This is not correct , ( i know , but i couldnt get what oyu were telling me ) after all the codes are complete;t different ... here it is , tell me if any thing is wrong .. if all are alright .. if there is a better way of expressing it i would be very thankful if you tell me
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();
}
by the way how can i edit my posts? !!! i just wanted to edit some post , but i noticed i cant