1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
| #include <windows.h>
#include <stdio.h>
#include <conio.h>
#pragma pack( 1 )
struct boot
{
BYTE jump [ 3 ] ;
char bsOemName [ 8 ] ;
WORD bytesperSector ;
BYTE sectorspercluster ;
WORD sectorsreservedarea ;
BYTE copiesFAT ;
WORD maxrootdirentries ;
WORD totalSectors ;
BYTE mediaDescriptor ;
WORD sectorsperFAT ;
WORD sectorsperTrack ;
WORD sides ;
WORD hiddenSectors ;
char reserve [ 480 ] ;
} ;
void ReadSector ( char*src, int ss, int num, void* buff ) ;
void display_buff(char *);
**** unsigned char *ptr;
****
**** int i, j, k;
****
**** struct boot b ;
void main()
{ ****
****ReadSector ( "\\\\.\\F:", 0, 1, &b ) ;
****
****printf ( "Boot Sector name: %s\n", b.bsOemName ) ;
****printf ( "Bytes per Sector: %d\n", b.bytesperSector ) ;
****printf ( "Sectors per Cluster: %d\n", b.sectorspercluster ) ;
****printf ( "jump : %c%c%c\n",************b.jump[0], b.jump[1], b.jump[2] );
****printf ( "sectorsreservedarea: %d\n", ****b.sectorsreservedarea) ;
****printf ( "copiesFAT: %d\n", ************b.copiesFAT) ;
****printf ( "maxrootdirentries: %d\n", ****b.maxrootdirentries) ;
****printf ( "totalSectors: %d\n", ************b.totalSectors) ;
****printf ( "mediaDescriptor: %d\n", ********b.mediaDescriptor) ;
****printf ( "sectorsperFAT: %d\n", ********b.sectorsperFAT) ;
****printf ( "sectorsperTrack: %d\n", ********b.sectorsperTrack) ;
****printf ( "sides: %d\n", ****************b.sides) ;
****printf ( "hiddenSectors: %d\n", ********b.hiddenSectors) ;
****display_buff(&b);
****for(k = 0; k < 10; k++)
****{****
********ReadSector ( "\\\\.\\F:", k, 1, &b );
********display_buff(&b);
****}
}
void ReadSector ( char *src, int ss, int num, void* buff )
{
****HANDLE h ;
****unsigned int br ;
****h = CreateFile ( src, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0 ) ;
****printf("\nsource name: %s\n", src);
****printf("file handler: %d\n", h);
****SetFilePointer ( h, ( ss * 512 ), NULL, 0 ) ;
****ReadFile ( h, buff, 512 * num, &br, NULL );
****CloseHandle ( h ) ;
}
void display_buff(char *buff)
{
****ptr = buff;
****
****for(j = 0; (j*16+i) < 512; j++)
****{
********printf("\n");
********for(i = 0; i < 16 && (j*16+i) < 512 ; i++)****
********printf("%.2X ", *ptr++);
********printf(" ");
********ptr -= i;
********for(i = 0; i < 16 && (j*16+i) < 512 ; i++)****
********if(*ptr >= ' ')
********printf("%c", *ptr++);
********else
********printf(".", *ptr++);
****}
} |