-
Notifications
You must be signed in to change notification settings - Fork 1
/
DOSDUMP.C
157 lines (121 loc) · 4.45 KB
/
DOSDUMP.C
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* DOSDUMP.C
* DOS Dump Support
*
* by Jeff Parsons 20-Apr-1993
*/
#include <all.h>
ASSERTMOD(dosdump.c);
// Function prototypes
VOID DOSDumpArena(VOID);
// Internal data structures
PSZ apszDOSDump[] = {"arena"};
PFNVOID apfnDOSDump[] = {DOSDumpArena};
BOOL DOSDumpCommand(PESF pesf, PCHAR pchCmd)
{
INT i;
if (*pchCmd == '?') {
printf("DOS dump commands\n"
"\tdos arena\tdump memory arena\n"
"\tdos dpb\t\tdump drive parameter blocks\n"
);
return TRUE;
}
if (*pchCmd) {
pchCmd += nstrskip(pchCmd, ' ');
i = istrtoken(&pchCmd, apszDOSDump, ARRAYSIZE(apszDOSDump));
if (i >= 0) {
(*apfnDOSDump[i])();
return TRUE;
}
}
return FALSE;
}
VOID DOSDumpArena()
{
PDOS pdos;
PMSDOS pmsdos;
PMCB pmcbPrev, pmcbNext;
PSZ pszDesc;
CHAR szTmp[9];
register PMCB pmcb, pmcbSystem;
printf("DOS I/O segment @%04X\n", SEG_DOSDATA, 0);
pdos = SEGPTOLINP(SEG_DOSDATA,0);
printf("I/O code segment @%04X:%04X (from %04X:%04X)\n",
pdos->BiosCodeSeg, pdos->cdev_off, SEGLINP(pdos), OFFSETOF(DOS,cdev_off));
printf("DOS data segment @%04X (from %04X:%04X)\n",
pdos->DosDataSeg, SEGLINP(pdos), OFFSETOF(DOS,DosDataSeg));
pmsdos = SEGPTOLINP(pdos->DosDataSeg,0);
printf("DOS code segment @%09X (from %04X:%04X)\n",
pmsdos->DosIntTable[2], SEGLINP(pmsdos), OFFSETOF(MSDOS,DosIntTable));
printf("DOS arena header @%04X (from %04X:%04X)\n",
pmsdos->arena_head, SEGLINP(pmsdos), OFFSETOF(MSDOS, arena_head));
pmcb = SEGPTOLINP(pmsdos->arena_head,0);
flKeyEvent &= ~KEYEVENT_ABORT;
while (pmcb->signature == ARENA_SIG || pmcb->signature == ARENA_SIG_END) {
// Get next MCB, too
pmcbNext = pmcb + pmcb->size + 1;
nstrcpyn(szTmp, pmcb->name, sizeof(szTmp)-1);
nsanitize(szTmp);
printf("MCB @%04X: Sig=%c Owner=%04X Size=%04X Name=\"%8s\"\n",
SEGLINP(pmcb), pmcb->signature, pmcb->owner, pmcb->size, szTmp);
// If this is a "system data" arena, then it should have a sub-arena
if (pmcb->owner == 0x0008 && pmcb->name[0] == 'S' && pmcb->name[1] == 'D') {
pmcbSystem = pmcb+1;
while (_isalpha(pmcbSystem->signature)) {
pszDesc = "Unknown";
switch(_tolower(pmcbSystem->signature)) {
case 'b':
case 'c':
pszDesc = "Buffers";
break;
case 'd':
pszDesc = "Device";
break;
case 'f':
pszDesc = "Files";
break;
case 'g':
pszDesc = "BDSs";
break;
case 'l':
pszDesc = "Lastdrive";
break;
case 's':
pszDesc = "Stacks";
break;
case 't':
pszDesc = "Install";
break;
case 'x':
pszDesc = "FCBs";
break;
case 'y':
pszDesc = "Drivemap";
break;
}
nstrcpyn(szTmp, pmcbSystem->name, sizeof(szTmp)-1);
nsanitize(szTmp);
printf("SYSMCB @%04X Sig=%c Seg=%04X Size=%04X Name=\"%8s\" (%s)\n",
SEGLINP(pmcbSystem), pmcbSystem->signature,
pmcbSystem->owner, pmcbSystem->size, szTmp, pszDesc);
pmcbSystem += pmcbSystem->size + 1;
if (pmcbSystem >= pmcbNext) {
if (pmcbSystem != pmcbNext)
printf("Possible error in SYSMCBs (expected end @%04X, actual end @%04X)\n",
SEGLINP(pmcbNext), SEGLINP(pmcbSystem));
break;
}
}
}
// Check for exit condition
if (pmcb->signature == ARENA_SIG_END)
return;
// Advance to next MCB
pmcbPrev = pmcb;
pmcb = pmcbNext;
if (flKeyEvent & KEYEVENT_ABORT)
return;
}
printf("Error in DOS arena @%09X\n", LINPTOADDR(pmcb));
}