-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnwdump.c
More file actions
115 lines (89 loc) · 2.17 KB
/
Copy pathnwdump.c
File metadata and controls
115 lines (89 loc) · 2.17 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/***************************************************************************
*
* Copyright (c) 1997-2022 Jeff V. Merkey All Rights
* Reserved.
*
* AUTHOR : Jeff V. Merkey (jeffmerkey@gmail.com)
* FILE : NWVOL.C
* DESCRIP : NWVOL Utility
* DATE : November 23, 1998
*
*
***************************************************************************/
#include "globals.h"
BYTE Sector[IO_BLOCK_SIZE];
WORD partitionSignature;
WORD stamp;
ULONG atox(BYTE *p)
{
register ULONG c = 0;
if (!p)
return 0;
while (*p)
{
if (*p >= '0' && *p <= '9')
c = (c << 4) | (*p - '0');
else
if (*p >= 'A' && *p <= 'F')
c = (c << 4) | (*p - 'A' + 10);
else
if (*p >= 'a' && *p <= 'f')
c = (c << 4) | (*p - 'a' + 10);
else
break;
p++;
}
return (c);
}
unsigned long ipause(void)
{
register unsigned long key;
#if (DOS_UTIL)
extern int getch(void);
#endif
printf(" --- More --- ");
key = getch();
printf("%c %c", '\r', '\r');
if (key == 0x1B) // ESCAPE
return 1;
else
return 0;
}
int main(int argc, char *argv[])
{
register ULONG retCode, total, lba, disk;
extern BYTE *dumpRecordBytes(BYTE *, ULONG);
extern void UtilScanVolumes(void);
if (argc < 2)
{
NWFSPrint("USAGE: nwdump <sector> <disk>\n");
return 0;
}
lba = atox(argv[1]);
if (argc > 2)
disk = atol(argv[2]);
else
disk = 0;
if (disk > 128)
{
NWFSPrint("invalid disk-%d\n", (int)disk);
return 0;
}
InitNWFS();
UtilScanVolumes();
if (!SystemDisk[disk])
return 0;
total = (ULONG)(SystemDisk[disk]->Cylinders *
SystemDisk[disk]->TracksPerCylinder *
SystemDisk[disk]->SectorsPerTrack);
retCode = ReadDiskSectors(disk, lba, Sector, 1, 1);
if (!retCode)
return 0;
dumpRecordBytes(Sector, 256);
ipause();
dumpRecordBytes(&Sector[256], 256);
NWFSVolumeClose();
RemoveDiskDevices();
FreePartitionResources();
return 0;
}