-
Notifications
You must be signed in to change notification settings - Fork 0
/
details.c
214 lines (141 loc) · 4.42 KB
/
details.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#define EXTERN extern
#include "pmdll.h"
#define MAX_EXPORT_ENTRIES 1024
#define MAX_IMPORT_MODULES 256
static BOOL _FillExportedProcedures (HWND hDlg, USHORT DetailEntry,
PSZ ErrorStr);
static BOOL _FillImportedModules (HWND hDlg, USHORT DetailEntry, PSZ ErrorStr);
MRESULT EXPENTRY DetailsDllWndProc (HWND hDlg, USHORT Msg, MPARAM mp1, MPARAM mp2)
{
static PSHORT pDetailEntry;
CHAR TitleStr[41];
switch (Msg)
{
case WM_INITDLG:
pDetailEntry = PVOIDFROMMP (mp2);
strcpy (TitleStr, "Details ");
strcat (TitleStr, pShowTableData[*pDetailEntry].Name);
WinSetWindowText (hDlg, TitleStr);
/*--- get current libpath --*/
if (!GetLibPath (Libpath, MAX_LIBPATH_SIZE, ErrorStr))
{
WinMessageBox (HWND_DESKTOP, hWndFrame, ErrorStr,
ApplTitle, 0, MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
WinDismissDlg (hDlg, FALSE);
break;
}
/*--- fill exported procedures ---*/
if (!_FillExportedProcedures (hDlg, *pDetailEntry, ErrorStr))
{
WinMessageBox (HWND_DESKTOP, hWndFrame, ErrorStr,
ApplTitle, 0, MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
WinDismissDlg (hDlg, FALSE);
break;
}
/*--- fill imported modules ---*/
if (!_FillImportedModules (hDlg, *pDetailEntry, ErrorStr))
{
WinMessageBox (HWND_DESKTOP, hWndFrame, ErrorStr,
ApplTitle, 0, MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
WinDismissDlg (hDlg, FALSE);
break;
}
CenterDialog (HWND_DESKTOP, hDlg);
WinSetFocus (HWND_DESKTOP, WinWindowFromID (hDlg, LID_DETAILS_DLL_EXP_RES));
return ((MRESULT) TRUE);
case WM_COMMAND:
switch (SHORT1FROMMP(mp1))
{
case DID_CANCEL:
WinDismissDlg (hDlg, FALSE);
break;
}
break;
default:
return WinDefDlgProc (hDlg, Msg, mp1, mp2);
}
return NULL;
}
static BOOL _FillExportedProcedures (HWND hDlg, USHORT DetailEntry,
PSZ ErrorStr)
{
PEXPORT_TABLE_DATA pExportTable;
CHAR ModuleName[9], LbStr[MAX_EXPORT_NAME_LENGTH + 20];
APIRET rc;
USHORT NrOfEntries, i;
BOOL Bit32, Result;
rc = DosAllocMem ((PPVOID) &pExportTable,
MAX_EXPORT_ENTRIES * sizeof (EXPORT_TABLE_DATA),
PAG_READ | PAG_WRITE | PAG_COMMIT);
if (rc)
{
strcpy (ErrorStr, "Couldn't allocate memory");
return (FALSE);
}
NrOfEntries = MAX_EXPORT_ENTRIES;
CursorWait ();
Result = ExeHdrGetExports (pShowTableData[DetailEntry].Path, &Bit32,
&NrOfEntries, pExportTable, ModuleName,
LbStr, ErrorStr);
CursorNormal ();
if (!Result)
{
DosFreeMem (pExportTable);
return (FALSE);
}
WinSetDlgItemText (hDlg, TID_DETAILS_DLL_MOD_NAME, ModuleName);
if (Bit32)
WinSetDlgItemText (hDlg, TID_DETAILS_DLL_1632, "32");
else
WinSetDlgItemText (hDlg, TID_DETAILS_DLL_1632, "16");
WinSetDlgItemText (hDlg, TID_DETAILS_DLL_DESCR, LbStr);
for (i = 0; i < NrOfEntries; ++i)
{
sprintf (LbStr, "@%u %s", pExportTable[i].Ordinal,
pExportTable[i].Name);
if (pExportTable[i].Resident)
{
WinSendDlgItemMsg (hDlg, LID_DETAILS_DLL_EXP_RES, LM_INSERTITEM,
MPFROMSHORT (LIT_END), MPFROMP (LbStr));
}
else
{
WinSendDlgItemMsg (hDlg, LID_DETAILS_DLL_EXP_NRES, LM_INSERTITEM,
MPFROMSHORT (LIT_END), MPFROMP (LbStr));
}
}
DosFreeMem (pExportTable);
return (TRUE);
}
static BOOL _FillImportedModules (HWND hDlg, USHORT DetailEntry, PSZ ErrorStr)
{
PIMPORT_TABLE_DATA pImportTable;
APIRET rc;
USHORT NrOfEntries, i;
BOOL Bit32, Result;
rc = DosAllocMem ((PPVOID) &pImportTable,
MAX_IMPORT_MODULES * sizeof (IMPORT_TABLE_DATA),
PAG_READ | PAG_WRITE | PAG_COMMIT);
if (rc)
{
strcpy (ErrorStr, "Couldn't allocate memory");
return (FALSE);
}
NrOfEntries = MAX_IMPORT_MODULES;
CursorWait ();
Result = ExeHdrGetImports (pShowTableData[DetailEntry].Path, FALSE, Libpath,
&Bit32, &NrOfEntries, pImportTable, ErrorStr);
CursorNormal ();
if (!Result)
{
DosFreeMem (pImportTable);
return (FALSE);
}
for (i = 0; i < NrOfEntries; ++i)
{
WinSendDlgItemMsg (hDlg, LID_DETAILS_DLL_IMP_MOD, LM_INSERTITEM,
MPFROMSHORT (LIT_END), MPFROMP (pImportTable[i].Name));
}
DosFreeMem (pImportTable);
return (TRUE);
}