|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
| Sponsored Links |
|
|
|
|||
|
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.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||||
|
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;
}
tanx in advance |
|
|||
|
Close, but not right. Try using this:
scanf("%*c",sizeof(fdi.jumpcodes),&fdi.jumpcodes); |
| Sponsored Links |
|
|
|
|||||
|
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;
}
|
|
|||||
|
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 09:11 PM. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Get installed software information | IUnknown | Software Development Tools | 5 | 10-15-2007 07:29 PM |
| speed up your hard disk | pranky | Tutorials | 4 | 07-12-2007 05:43 PM |
| Getting Hardware Information | Guitar22891 | Visual Basic Programming | 1 | 05-09-2007 03:08 PM |
| Hide information | Chan | JavaScript and CSS | 1 | 11-08-2006 02:51 PM |
| Password Reset Disk | PC101 | Technology Ramble | 0 | 09-12-2006 09:42 PM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |