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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
|
/*++
Copyright (c) 1993 Microsoft Corporation
Module Name:
vwdll.c
Abstract:
ntVdm netWare (Vw) IPX/SPX Functions
Vw: The peoples' network
VDD functions for DOS/WOW IPX/SPX support
Contents:
VwDllEntryPoint
VwInitialize
VWinInitialize
VwDispatcher
VwInvalidFunction
Author:
Richard L Firth (rfirth) 30-Sep-1993
Environment:
User-mode Win32
Revision History:
30-Sep-1993 rfirth
Created
--*/
#include "vw.h"
#pragma hdrstop
//
// private prototypes
//
PRIVATE
VOID
VwInvalidFunction(
VOID
);
//
// private data
//
PRIVATE
VOID
(*VwDispatchTable[])(VOID) = {
VwIPXOpenSocket, // 0x00
VwIPXCloseSocket, // 0x01
VwIPXGetLocalTarget, // 0x02
VwIPXSendPacket, // 0x03
VwIPXListenForPacket, // 0x04
VwIPXScheduleIPXEvent, // 0x05
VwIPXCancelEvent, // 0x06
VwIPXScheduleAESEvent, // 0x07
VwIPXGetIntervalMarker, // 0x08
VwIPXGetInternetworkAddress, // 0x09
VwIPXRelinquishControl, // 0x0A
VwIPXDisconnectFromTarget, // 0x0B
VwInvalidFunction, // 0x0C
VwInvalidFunction, // 0x0D old-style GetMaxPacketSize
VwInvalidFunction, // 0x0E
VwInvalidFunction, // 0x0F internal send packet function
VwSPXInitialize, // 0x10
VwSPXEstablishConnection, // 0x11
VwSPXListenForConnection, // 0x12
VwSPXTerminateConnection, // 0x13
VwSPXAbortConnection, // 0x14
VwSPXGetConnectionStatus, // 0x15
VwSPXSendSequencedPacket, // 0x16
VwSPXListenForSequencedPacket, // 0x17
VwInvalidFunction, // 0x18
VwInvalidFunction, // 0x19
VwIPXGetMaxPacketSize, // 0x1A
VwInvalidFunction, // 0x1B
VwInvalidFunction, // 0x1C
VwInvalidFunction, // 0x1D
VwInvalidFunction, // 0x1E
VwIPXGetInformation, // 0x1F
VwIPXSendWithChecksum, // 0x20
VwIPXGenerateChecksum, // 0x21
VwIPXVerifyChecksum // 0x22
};
#define MAX_IPXSPX_FUNCTION LAST_ELEMENT(VwDispatchTable)
WSADATA WsaData = {0};
HANDLE hAesThread = NULL;
//
// global data
//
SOCKADDR_IPX MyInternetAddress;
WORD MyMaxPacketSize;
int Ica;
BYTE IcaLine;
//
// not-really-global data
//
extern CRITICAL_SECTION SerializationCritSec;
extern CRITICAL_SECTION AsyncCritSec;
//
// functions
//
BOOL
WINAPI
VwDllEntryPoint(
IN PVOID DllHandle,
IN ULONG Reason,
IN PCONTEXT Context OPTIONAL
)
/*++
Routine Description:
Called when the process attaches (LoadLibrary/init) and detaches (FreeLibrary/
process termination) from this DLL
Attach:
initialize Winsock DLL
get internet address for this station
get maximum packet size supported by transport (IPX)
create AES thread
Detach:
terminate Winsock DLL
Arguments:
DllHandle - unused
Reason - checked for process attach/detach
Context - unused
Return Value:
BOOLEAN
--*/
{
DWORD aesThreadId; // unused outside of this function
static BOOL CriticalSectionsAreInitialized = FALSE;
UNREFERENCED_PARAMETER(DllHandle);
UNREFERENCED_PARAMETER(Context);
IPXDBGSTART();
IPXDBGPRINT((__FILE__, __LINE__,
FUNCTION_ANY,
IPXDBG_LEVEL_INFO,
"VwDllEntryPoint: %s\n",
Reason == DLL_PROCESS_ATTACH ? "DLL_PROCESS_ATTACH"
: Reason == DLL_PROCESS_DETACH ? "DLL_PROCESS_DETACH"
: Reason == DLL_THREAD_ATTACH ? "DLL_THREAD_ATTACH"
: Reason == DLL_THREAD_DETACH ? "DLL_THREAD_DETACH"
: "?"
));
if (Reason == DLL_PROCESS_ATTACH) {
int err;
//
// BUGBUG: get ICA values from new VDD service. Right now we grab
// line 4 on the slave (base = 0x70, modifier = 0x03)
//
Ica = ICA_SLAVE;
IcaLine = 3;
err = WSAStartup(MAKEWORD(1, 1), &WsaData);
if (err) {
IPXDBGPRINT((__FILE__, __LINE__,
FUNCTION_ANY,
IPXDBG_LEVEL_FATAL,
"VwDllEntryPoint: WSAStartup() returns %d\n",
err
));
return FALSE;
} else {
IPXDBGPRINT((__FILE__, __LINE__,
FUNCTION_ANY,
IPXDBG_LEVEL_INFO,
"VwDllEntryPoint: WsaData:\n"
"\twVersion : 0x%04x\n"
"\twHighVersion : 0x%04x\n"
"\tszDescription : \"%s\"\n"
"\tszSystemStatus : \"%s\"\n"
"\tiMaxSockets : %d\n"
"\tiMaxUdpDg : %d\n"
"\tlpVendorInfo : 0x%08x\n",
WsaData.wVersion,
WsaData.wHighVersion,
WsaData.szDescription,
WsaData.szSystemStatus,
WsaData.iMaxSockets,
WsaData.iMaxUdpDg,
WsaData.lpVendorInfo
));
}
//
// retrieve the internet address for this station. Used in
// IPXGetInternetworkAddress() and IPXSendPacket()
//
err = GetInternetAddress(&MyInternetAddress);
if (err) {
IPXDBGPRINT((__FILE__, __LINE__,
FUNCTION_ANY,
IPXDBG_LEVEL_FATAL,
"VwDllEntryPoint: GetInternetAddress() returns %d\n",
WSAGetLastError()
));
goto attach_error_exit;
} else {
IPXDBGPRINT((__FILE__, __LINE__,
FUNCTION_ANY,
IPXDBG_LEVEL_INFO,
"VwDllEntryPoint: MyInternetAddress:\n"
"\tNet : %02.2x-%02.2x-%02.2x-%02.2x\n"
"\tNode : %02.2x-%02.2x-%02.2x-%02.2x-%02.2x-%02.2x\n",
MyInternetAddress.sa_netnum[0] & 0xff,
MyInternetAddress.sa_netnum[1] & 0xff,
MyInternetAddress.sa_netnum[2] & 0xff,
MyInternetAddress.sa_netnum[3] & 0xff,
MyInternetAddress.sa_nodenum[0] & 0xff,
MyInternetAddress.sa_nodenum[1] & 0xff,
MyInternetAddress.sa_nodenum[2] & 0xff,
MyInternetAddress.sa_nodenum[3] & 0xff,
MyInternetAddress.sa_nodenum[4] & 0xff,
MyInternetAddress.sa_nodenum[5] & 0xff
));
}
//
// get the maximum packet size supported by IPX. Used in
// IPXGetMaxPacketSize()
//
err = GetMaxPacketSize(&MyMaxPacketSize);
if (err) {
IPXDBGPRINT((__FILE__, __LINE__,
FUNCTION_ANY,
IPXDBG_LEVEL_FATAL,
"VwDllEntryPoint: GetMaxPacketSize() returns %d\n",
WSAGetLastError()
));
goto attach_error_exit;
} else {
IPXDBGPRINT((__FILE__, __LINE__,
FUNCTION_ANY,
IPXDBG_LEVEL_INFO,
"VwDllEntryPoint: GetMaxPacketSize: %04x (%d)\n",
MyMaxPacketSize,
MyMaxPacketSize
));
}
hAesThread = CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE)VwAesThread,
NULL,
0,
&aesThreadId
);
if (hAesThread == NULL) {
IPXDBGPRINT((__FILE__, __LINE__,
FUNCTION_ANY,
IPXDBG_LEVEL_FATAL,
"VwDllEntryPoint: CreateThread() returns %d\n",
GetLastError()
));
goto attach_error_exit;
}
//
// finally initialize any critical sections
//
InitializeCriticalSection(&SerializationCritSec);
InitializeCriticalSection(&AsyncCritSec);
CriticalSectionsAreInitialized = TRUE;
} else if (Reason == DLL_PROCESS_DETACH) {
if (hAesThread != NULL) {
WaitForSingleObject(hAesThread, ONE_TICK * 2);
CloseHandle(hAesThread);
}
WSACleanup();
if (CriticalSectionsAreInitialized) {
DeleteCriticalSection(&SerializationCritSec);
DeleteCriticalSection(&AsyncCritSec);
}
IPXDBGEND();
}
return TRUE;
attach_error_exit:
//
// here if any fatal errors on process attach after successfully performing
// WSAStartup
//
WSACleanup();
return FALSE;
}
BYTE
VWinInitialize(
VOID
)
/*++
Routine Description:
Called by interface when nwipxspx.dll is loaded. We
return the IRQ value.
Arguments:
None.
Return Value:
The IRQ value.
--*/
{
return 0x73;
}
VOID
VwInitialize(
VOID
)
/*++
Routine Description:
Called by VDD interface when DLL loaded via call to RegisterModule. We
get the IRQ value and return it as an interrupt vector in BX
Arguments:
None.
Return Value:
None.
--*/
{
IPXDBGPRINT((__FILE__, __LINE__,
FUNCTION_ANY,
IPXDBG_LEVEL_INFO,
"VwInitialize\n"
));
//
// only lines on slave PIC are available. Currently, lines 3, 4 and 7 are
// not used. We'll grab line 3 here, but in the future we expect a function
// to return the available IRQ line
//
setBX( VWinInitialize() );
}
VOID
VwDispatcher(
VOID
)
/*++
Routine Description:
Branches to relevant IPX/SPX handler for DOS calls, based on contents of
VDM BX register.
Control transfered here from 16-bit entry point, either as result of call
to far address returned from INT 2Fh/AH=7A or INT 7Ah
Special: we use BX = 0xFFFF to indicate that the app is terminating. The
TSR hooks INT 0x2F/AX=0x1122 (IFSResetEnvironment)
Arguments:
None.
Return Value:
None.
--*/
{
DWORD dispatchIndex;
dispatchIndex = (DWORD)getBX() & 0x7fff;
if (dispatchIndex <= MAX_IPXSPX_FUNCTION) {
VwDispatchTable[dispatchIndex]();
} else if (dispatchIndex == 0x7FFE) {
EsrCallback();
} else if (dispatchIndex == 0x7FFF) {
VwTerminateProgram();
} else {
IPXDBGPRINT((__FILE__, __LINE__,
FUNCTION_ANY,
IPXDBG_LEVEL_ERROR,
"ERROR: VwDispatcher: dispatchIndex = %x\n",
dispatchIndex
));
//
// BUGBUG - what's the correct error code to return in this situation?
// (will it ever arise?)
//
setAX(ERROR_INVALID_FUNCTION);
setCF(1);
}
}
PRIVATE
VOID
VwInvalidFunction(
VOID
)
/*++
Routine Description:
Just alerts us to the fact that an invalid function request was made.
Useful if any app makes a bad call, or we miss out a required function
during design/implementation
Arguments:
None.
Return Value:
None.
--*/
{
IPXDBGPRINT((__FILE__, __LINE__,
FUNCTION_ANY,
IPXDBG_LEVEL_INFO,
"VwInvalidFunction: BX=%04x\n",
getBX()
));
}
|