I need to know how to access the floppy disk serial number (and name(s)) using
c. Any help would be appreciated.
--Torpid_rat--
"The truth doesn't care if you believe it or not."
http://www.members.aol.com:/desmith7
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
The structure of each (32 byte) directory entry is as follows:
offset size meaning
00h 8 bytes file name
08h 3 bytes file extension
0Bh byte file attribute (hidden, etc)
0Ch 10 bytes reserved (unused)
16h word time of last update
18h word date of last update
1Ah word beginning disk cluster
1Ch Dword file size.
But, the very first directory entry will be the volume label.
The volume label contains special codes at 0Bh that indicate
its character: Namely, if bit 4 of the byte is set to "1" it
is a volume label. If bit 3 is set to "1" then the first
directory entry is a "system" file like IO.SYS.
/ph
- - - - - - - -
Hi torpil_rat,
Ignore my first post, I copied the wrong correspondence in
answer to your question. Here is the correct info:
Okay, please note that BPB varies in size between DOS 3.3
and the later versions which include serial number, volume
label, etc. Briefly, here's how it goes:
The first (logical not physical) sector of the diskette
contains 512 bytes of info known as boot-sector info. And
as you read this text you ought to be using Norton, ProView
or some other hex viewer to examine the first logical sector
of a properly formatted diskette (doesn't need to be bootable).
The first three bytes will be a (short) jump instruction,
followed by a single NOP (90h) byte.
The following eight bytes will contain OEM name, but actually
you can put in anything you please.
The BIOS PARAMETER BLOCK (BPB) begins at offset 11, and its
layout refered to its starting position is as follows:
byte offset field length sample value meaning
00h Word 0200 number of bytes/sector
02h byte 02 number of sects/cluster
03h word 0001 number of reserved sects
05h byte 02 number of FAT's
06h word 0070 max root dir. entries
08h word 02D0 total number of sects
0Ah byte FD media descriptor
0Bh word 0002 num sects per FAT
0Dh word 0009 num sects per track
0Fh word 0002 num of heads
11h word 0000 num hidden sectors
13h 13 bytes ---- reserved before v3.0
v3.x extensions:
15h Dword 00000000 total num sects if 08h=0
19h 7 bytes ------- reserved ( aux BPB )
v4.x extensions:
19h byte 00 physical drive number
1Ah byte 00 reserved
1Bh byte 29 signature extend boot record
1Ch Dword 203D10CC vol serial num
20h 11 bytes NO NAME vol label
2Bh 8 bytes FAT12 reserved
That's it! ... Since you know from the BPB how many FAT's you have
and hou many sectors each of them uses, you may then calculate the
beginning sector for your directory. Search your directory for the
filename, then continue by tracing the FAT entries.
Hope this helps,
/ph
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-------------------------------
http://oak.oakland.edu/simtel.net/
diskutil/
bootfun0 23516 950305 changes floppy boot program or SERIAL NUMBER
serino_2 27940 990102 changes floppy or hard disk's SERIAL NUMBER
zmodem/
zmod-snp 11525 891031 automate insertion of SERIAL NUMBER for dsz
-------------------------------
diskutil/
serino_1 changes SERIAL NUMBER floppy or hard disk, m. aydin
--
=-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
al aab, seders moderator sed u soon
it is not zat we do not see the s o l u t i o n
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
>> I need to know how to access the floppy disk serial number (and name(s)) using
>> c. Any help would be appreciated.
>
>The structure of each (32 byte) directory entry is as follows:
That is NOT the disk serial number.
Adrian
WWW WWW Adrian Gothard
WWW ww WWW White Horse Design
WWWWWWWWWW
WWWW WWWW w...@zetnet.co.uk, http://www.users.zetnet.co.uk/whd
---
Designers of video capture/filter/processing systems for aircraft
>> I need to know how to access the floppy disk serial number (and name(s)) using
>> c. Any help would be appreciated.
/* ts:4
*
* This software is copyright (c) Adrian Gothard and may be freely
* distributed for private use provided that it is NOT to be used
either
* for commercial gain or by a commercial company. No warranties of
any
* kind are provided and by using the program the user assumes all
risk.
*/
/*
* sn -- read serial number of disk
* copyright (c) 1989-1996, Adrian Gothard
*
* usage: sn [-aA] [drive]
*
* Reads the serial number from the specified or default drive by
* using internal dos4 service (if dos is version 4) or by reading
* the boot sector and extracting the serial number if present, or
* by using get ioctl block generic dos request (seems better
* supported under DOS emulation operating environments such as
* OS/2, Win95, and in particular Win31).
*/
/* Manx Aztec C v5.2a */
#define VER 102
/* Standard library headers */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
/* Manx Aztec C v5.2a */
#ifdef MONITOR
#include <monitor.h>
#endif
/* Private headers */
#ifdef BOOT_SECTOR_METHOD
#include <doserr.h>
#include <dskerr.h>
#endif
#define MAXVOL 11
#define MAXFAT 8
#define PARMS "[-aA] [drive]"
#define PROG "sn"
#define DESC PROG" -- read serial number of disk v1.02"
#define USAGE "Usage:\t"PROG" "PARMS"\n"
#define AUTHOR "Adrian Gothard"
#define COMPANY "White Horse Design"
/* Exit status */
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif
static int version = VER;
static char *prog = PROG;
static char *copyright = "@(#) copyright (c) "AUTHOR" 1989-1998\n";
static char *author = AUTHOR;
static char *company = COMPANY;
static char *compiler = COMPILER;
static char usage[ MAX_FILENAME ];
static char progname[ MAX_FILENAME ];
struct wREGS {unsigned int ax,bx,cx,dx,si,di,ds,es;};
struct bREGS {unsigned char al,ah,bl,bh,cl,ch,dl,dh;};
union REGS
{
struct wREGS x;
struct bREGS h;
};
/* Initialise version data */
VER version =
{
VER_MAJOR,
VER_MINOR,
VER_BUILD,
VER_REVISION,
VER_DATE,
VER_TIME,
VER_DESCRIPTION
};
#ifdef BOOT_SECTOR_METHOD
long serial_boot_record(int drive);
#endif
extern int readabs(void);
extern long dos_get_serial_number_40(int drive);
extern long dos_get_serial_number(int drive);
extern int dos_get_current_drive(void);
extern int dos_get_version(void);
static long serialno(int drive);
static int isdos4(void);
/*
* main_monitor()
*
* Desc:
*
* Entry: None.
*
* Exit:
*
* Notes: This is for "profiling"
*/
#ifdef MONITOR
int main_monitor( int argc, char **argv, char **envp );
int main( int argc, char **argv, char **envp )
{
uint monbuf[ 4096 ];
void _Corg();
void _Cend();
/* Turn on monitoring */
_intr_sp( 60 );
monitor( _Corg, _Cend, monbuf, sizeof( monbuf ) / 2, 0 );
/* Monitor main code */
main_monitor( argc, argv );
/* Turn off monitoring */
monitor(( void *) 0, ( void *) 0, ( int *) 0, 0, 0 );
}
int main_monitor( int argc, char **argv )
#else
/*
* main()
*
* Desc:
*
* Entry: None.
*
* Exit:
*
* Notes: This is NOT for "profiling"
*/
int main( int argc, char **argv )
{
int alt = 0;
long sn;
/* do switches */
while ( --argc && **++argv == '-' )
{
register char *p;
for ( p = *argv + 1; *p; ++p )
{
switch(*p)
{
case 'a':
alt = 1;
break;
case 'A':
alt = 2;
break;
default:
fprintf( stderr, "%s\n%s\n", DESC, USAGE );
exit( 1 );
break;
}
}
}
if ( sn = serialno( argc ? ( tolower( **argv ) - 'a' ) :
dos_get_current_drive() ))
{
switch ( alt )
{
case 1:
printf( "%04lx:%04lx\n", ( sn >> 16 ) & 0x0000ffff, sn
& 0x0000ffff );
break;
case 2:
printf( "%04lX:%04lX\n", ( sn >> 16 ) & 0x0000ffff, sn
& 0x0000ffff );
break;
case 0:
default:
printf( "%08lx\n", sn );
break;
}
}
}
#endif
/*
* process()
*
* Desc:
*
* Entry: None.
*
* Exit:
*
* Notes:
*/
/* serialno() -- return the serial number for drive */
long serialno( int drive )
{
return (long) ( isdos4() ?
dos_get_serial_number_40 : dos_get_serial_number )( ++drive );
}
/*
* serial_boot_record()
*
* Desc: Get disk serial number by reading boot record.
*
* Entry: None.
*
* Exit:
*
* Notes:
*/
#ifdef BOOT_SECTOR_METHOD
long serial_boot_record( char n )
{
char buffer[ 512 ];
int dskerr;
struct
{
unsigned long sector;
unsigned int count;
far char *bptr;
} ctl;
ctl.sector = 0;
ctl.count = 1;
ctl.bptr = (far char*) buffer;
if ( dskerr = readabs( n, &ctl ))
{
fprintf( stderr, "%c: %s\n", n + 'a', dsk_errlist[ dskerr ] );
exit( dskerr );
}
return ( buffer[ 0x26 ] == 0x29 ) /* check signature */ ?
*( unsigned long * )( buffer + 0x27 ) : ( long ) 0;
}
#endif
/*
* help()
*
* Desc:
*
* Entry: None.
*
* Exit:
*
* Notes: None.
*/
int help( char *prog )
{
fprintf( stderr, "%s -- "DESCRIPTION" v%u.%02u %c, build %u\n",
prog,
version.major, version.minor,
version.revision, version.build );
fprintf( stderr, "%s\n", usage );
fprintf( stderr, "-h\tdisplay this help text\n" );
return 1;
}
/*
* isdos4()
*
* Desc:
*
* Entry: None.
*
* Exit:
*
* Notes:
*/
int isdos4( void )
{
return ( dos_get_version() & 0xff ) == 4;
}
/* end */
Did you read my correction posted only a few minutes later?
/ph
- - - - - - - - -
> WWW WWW Adrian Gothard
> WWW ww WWW White Horse Design
> WWWWWWWWWW
> WWWW WWWW w...@zetnet.co.uk, http://www.users.zetnet.co.uk/whd
> ---
> Designers of video capture/filter/processing systems for aircraft
>
-----------== Posted via Deja News, The Discussion Network ==----------