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
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
|
PAGE ,132
TITLE DXNETBIO.ASM -- Dos Extender NetBIOS API Mapper
; Copyright (c) Microsoft Corporation 1989-1991. All Rights Reserved.
;***********************************************************************
;
; DXNETBIO.ASM - DOS Extender NetBIOS API Mapper
;
;-----------------------------------------------------------------------
;
; This module provides the 286 DOS Extender's API mapping of Int 2Ah and
; 5Ch NetBIOS requests. It allows a protected mode application to
; issue NetBIOS requests without worrying about segment to selector
; translations and mapping of buffers between extended and conventional
; memory.
;
;-----------------------------------------------------------------------
;
; 11/29/90 amitc Modified code to have the POST routine in GlobalMemory
; and queue the POST when DOSX is not around.
; 11/29/90 amitc Call to InitLowHeap moved to this file from DXOEM.ASM
; 02/01/90 jimmat Update Api mapping table for Ungerman-Bass extensions
; as per new data from UB.
; 06/15/89 w-glenns Finished TermNetMapper, added Delay/ResumeNetPosting
; 04/18/89 jimmat Original version.
; 18-Dec-1992 sudeepb Changed cli/sti to faster FCLI/FSTI
;
;***********************************************************************
.286p
; -------------------------------------------------------
; INCLUDE FILE DEFINITIONS
; -------------------------------------------------------
.xlist
.sall
include segdefs.inc
include gendefs.inc
include pmdefs.inc
include interupt.inc
include netbios.inc
IFDEF ROM
include dxrom.inc
ENDIF
include intmac.inc
include stackchk.inc
include bop.inc
include rdrsvc.inc
.list
; -------------------------------------------------------
; FLAG FOR PM NCB HANDLING
; -------------------------------------------------------
PM_NCB_HANDLING equ 1 ; set to 0 for NCB handling in VM
; -------------------------------------------------------
; GENERAL SYMBOL DEFINITIONS
; -------------------------------------------------------
; The following equates define the codes that map between a NCB Command code
; and the mapping flags used to process it. To be compatible with Windows/386,
; these values are all increments of 4 (they use 32 bit offsets). These
; values should always correspond to the values used by the Windows/386
; NetBIOS mapping!
ApiMapUnknown EQU 00h
ApiMapNone EQU 04h
ApiMapIn EQU 08h
ApiMapOut EQU 0Ch
ApiMapInOut EQU 10h
ApiChainSend EQU 14h
ApiCancel EQU 18h
ApiBufferIn EQU 1Ch
ApiBufferOut EQU 20h
ApiBufferInOut EQU 24h
; The following equates define the bit flags which identify the actions
; to take on entry and exit of a NetBIOS request.
BUFF_IN EQU 01h ;Buffer data to the int handler
BUFF_OUT EQU 02h ;Buffer data from the int handler
BUFF_CHAIN EQU 04h ;Special chain send buffering
BUFF_CANCEL EQU 08h ;Special cancel buffering
REPLACE_MAP_TABLE EQU 1607h ;Int2fh replace net map table service
VNETBIOS_DEV_ID EQU 14h ;VNETBIOS device ID
; -------------------------------------------------------
; EXTERNAL SYMBOL DEFINITIONS
; -------------------------------------------------------
extrn EnterIntHandler:NEAR
extrn LeaveIntHandler:NEAR
extrn EnterRealMode:NEAR
extrn EnterProtectedMode:NEAR
extrn AllocateLowBlock:NEAR
extrn FreeLowBlock:NEAR
extrn GetSegmentAddress:NEAR
externFP NSetSegmentDscr
extrn AllocateLDTSelector:NEAR
extrn Lma2SegOff:NEAR
extrn InitLowHeap:NEAR
; -------------------------------------------------------
; DATA SEGMENT DEFINITIONS
; -------------------------------------------------------
DXDATA segment
extrn pbReflStack:WORD
extrn bReflStack:WORD
extrn rglpfnRmISR:DWORD
extrn regUserSS:WORD
extrn regUserSP:WORD
extrn rgbXfrBuf1:BYTE
extrn segDXCode:WORD
extrn NetHeapSize:WORD
ifdef WOW_x86
extrn FastBop:fword
endif
OldInt76 dd 0
public HCB_List
Cancel_NCB EQU rgbXfrBuf1 ;Easier for commenting/readability
HCB_List dw 0 ;linked list of low HCB/NCB/Buffers
selNetScr dw 0 ;scratch selector
lpfnOldInt2A dd ? ;old int vector 2Ah & 5Ch routines
lpfnOldInt5C dd ?
lpfnRmNetIsr dd ? ;Real Mode vector to Network Int Rtn
SelNetStubCode dw 0 ;sel for stub code
SegNetStubCode dw 0 ;segment for stub code
AddrfStubDelayNetPosting dw ? ;address of fStubDelayNetPosting in StubSeg
AddrfStubTermNetRequest dw ? ;address of fStubTermNetRequest in StubSeg
NBPSp dw 0
; The ApiMapTbl converts an NCB Command code (0-7F) into a code that
; identifies the particular mapping routine to execute.
ApiMapTbl label byte
db ApiMapUnknown ; 00h -
db ApiMapUnknown ; 01h -
db ApiMapUnknown ; 02h -
db ApiMapUnknown ; 03h -
db ApiMapUnknown ; 04h -
db ApiMapUnknown ; 05h -
db ApiMapUnknown ; 06h -
db ApiMapUnknown ; 07h -
db ApiMapUnknown ; 08h -
db ApiMapUnknown ; 09h -
db ApiMapUnknown ; 0Ah -
db ApiMapUnknown ; 0Bh -
db ApiMapUnknown ; 0Ch -
db ApiMapUnknown ; 0Dh -
db ApiMapUnknown ; 0Eh -
db ApiMapUnknown ; 0Fh -
db ApiMapNone ; 10h - Call
db ApiMapNone ; 11h - Listen
db ApiMapNone ; 12h - Hang up
db ApiMapUnknown ; 13h -
db ApiBufferIn ; 14h - Send
db ApiBufferOut ; 15h - Receive
db ApiBufferOut ; 16h - Receive any
db ApiChainSend ; 17h - Chain send
db ApiMapUnknown ; 18h -
db ApiMapUnknown ; 19h -
db ApiMapUnknown ; 1Ah -
db ApiMapUnknown ; 1Bh -
db ApiMapUnknown ; 1Ch -
db ApiMapUnknown ; 1Dh -
db ApiMapUnknown ; 1Eh -
db ApiMapUnknown ; 1Fh -
db ApiBufferIn ; 20h - Send datagram
db ApiBufferOut ; 21h - Receive datagram
db ApiBufferIn ; 22h - Send broadcast datagram
db ApiBufferOut ; 23h - Receive broadcast dgram
db ApiMapUnknown ; 24h -
db ApiMapUnknown ; 25h -
db ApiMapUnknown ; 26h -
db ApiMapUnknown ; 27h -
db ApiMapUnknown ; 28h -
db ApiMapUnknown ; 29h -
db ApiMapUnknown ; 2Ah -
db ApiMapUnknown ; 2Bh -
db ApiMapUnknown ; 2Ch -
db ApiMapUnknown ; 2Dh -
db ApiMapUnknown ; 2Eh -
db ApiMapUnknown ; 2Fh -
db ApiMapNone ; 30h - Add name
db ApiMapNone ; 31h - Delete name
db ApiMapNone ; 32h - Reset
db ApiMapOut ; 33h - Adapter status
db ApiMapOut ; 34h - Session status
db ApiCancel ; 35h - Cancel
db ApiMapNone ; 36h - Add group name
db ApiMapUnknown ; 37h -
db ApiMapUnknown ; 38h -
db ApiMapUnknown ; 39h -
db ApiMapUnknown ; 3Ah -
db ApiMapUnknown ; 3Bh -
db ApiMapUnknown ; 3Ch -
db ApiMapUnknown ; 3Dh -
db ApiMapUnknown ; 3Eh -
db ApiMapUnknown ; 3Fh -
db ApiMapUnknown ; 40h -
db ApiMapUnknown ; 41h -
db ApiMapUnknown ; 42h -
db ApiMapUnknown ; 43h -
db ApiMapUnknown ; 44h -
db ApiMapUnknown ; 45h -
db ApiMapUnknown ; 46h -
db ApiMapUnknown ; 47h -
db ApiMapUnknown ; 48h -
db ApiMapUnknown ; 49h -
db ApiMapUnknown ; 4Ah -
db ApiMapUnknown ; 4Bh -
db ApiMapUnknown ; 4Ch -
db ApiMapUnknown ; 4Dh -
db ApiMapUnknown ; 4Eh -
db ApiMapUnknown ; 4Fh -
db ApiMapUnknown ; 50h -
db ApiMapUnknown ; 51h -
db ApiMapUnknown ; 52h -
db ApiMapUnknown ; 53h -
db ApiMapUnknown ; 54h -
db ApiMapUnknown ; 55h -
db ApiMapUnknown ; 56h -
db ApiMapUnknown ; 57h -
db ApiMapUnknown ; 58h -
db ApiMapUnknown ; 59h -
db ApiMapUnknown ; 5Ah -
db ApiMapUnknown ; 5Bh -
db ApiMapUnknown ; 5Ch -
db ApiMapUnknown ; 5Dh -
db ApiMapUnknown ; 5Eh -
db ApiMapUnknown ; 5Fh -
db ApiMapUnknown ; 60h -
db ApiMapUnknown ; 61h -
db ApiMapUnknown ; 62h -
db ApiMapUnknown ; 63h -
db ApiMapUnknown ; 64h -
db ApiMapUnknown ; 65h -
db ApiMapUnknown ; 66h -
db ApiMapUnknown ; 67h -
db ApiMapUnknown ; 68h -
db ApiMapUnknown ; 69h -
db ApiMapUnknown ; 6Ah -
db ApiMapUnknown ; 6Bh -
db ApiMapUnknown ; 6Ch -
db ApiMapUnknown ; 6Dh -
db ApiMapUnknown ; 6Eh -
db ApiMapUnknown ; 6Fh -
db ApiMapNone ; 70h - Unlink
db ApiMapUnknown ; 71h -
db ApiMapNone ; 72h - Ungerman Bass Register
db ApiBufferIn ; 73h - Ungerman Bass SendNmc
db ApiMapNone ; 74h - Ungerman Bass Callniu
db ApiMapNone ; 75h - Ungerman Bass Calladdr
db ApiMapNone ; 76h - Ungerman Bass Listenaddr
db ApiBufferIn ; 77h - Ungerman Bass SendPkt
db ApiBufferOut ; 78h - Ungerman Bass RcvPkt
db ApiBufferIn ; 79h - Ungerman Bass SendAttn
db ApiBufferOut ; 7Ah - Ungerman Bass RcvAttn
db ApiBufferOut ; 7Bh - Ungerman Bass Listenniu
db ApiBufferOut ; 7Ch - Ungerman Bass RcvRaw
db ApiBufferIn ; 7Dh - Ungerman Bass SendNmc2
db ApiMapUnknown ; 7Eh -
db ApiMapNone ; 7Fh - Install check
; The next table maps the (Windows/386 compatible) code from ApiMapTbl
; to the bit flags which control our entry/exit mapping.
EntryExitFlags label byte
db BUFF_IN+BUFF_OUT ;ApiMapUnknown
db 0 ;ApiMapNone
db BUFF_IN ;ApiMapIn
db BUFF_OUT ;ApiMapOut
db BUFF_IN+BUFF_OUT ;ApiMapInOut
db BUFF_CHAIN ;ApiChainSend
db BUFF_CANCEL ;ApiCancel
db BUFF_IN ;ApiBufferIn
db BUFF_OUT ;ApiBufferOut
db BUFF_IN+BUFF_OUT ;ApiBufferInOut
DXDATA ends
; -------------------------------------------------------
; CODE SEGMENT VARIABLES
; -------------------------------------------------------
DXCODE segment
IFNDEF ROM
extrn selDgroup:WORD
ENDIF
DXCODE ends
DXPMCODE segment
extrn selDgroupPM:WORD
DXPMCODE ends
page
; ----------------------------------------------------------------------
;
; The following routines handle INT 2Ah and 5Ch interrupts that
; request NetBIOS services. Typically, these interrupts require
; that a NCB and/or buffer be copied between conventional and
; extended memory, and register values be modified due to real-
; mode/protected-mode addressing differences.
;
; (Note: this comment copied almost unchanged from DXINTR.ASM)
;
; The following conventions are used:
;
; A stack is allocated from the interrupt reflector stack for these
; routines to use. This allows nested servicing of interrupts.
; A stack frame is built in the allocated stack which contains the
; following information:
;
; original caller's stack address
; caller's original flags and general registers (in pusha form)
; caller's original segment registers (DS & ES)
; flags and general registers to be passed to interrupt routine
; (initially the same as caller's original values)
; segment registers (DS & ES) to be passed to interrupt routine
; (initially set to the Dos Extender data segment address)
;
; This stack frame is built by the routine EnterIntHandler, and its
; format is defined by the structure INTRSTACK. The stack frame is
; destroyed and the processor registers set up for return to the user
; by the function LeaveIntHandler.
;
; There are two sets of general registers and two sets of segment
; registers (DS & ES) on the stack frame. One set of register values
; has member names of the form intUserXX. The values in these stack
; frame members will be passed to the interrupt service routine when
; it is called, and will be loaded with the register values returned
; by the interrupt service routine. The other set of registers values
; has member names of the form pmUserXX. These stack frame members
; contain the original values in the registers on entry from the
; user program that called the interrupt.
;
; When we return to the original caller, we want to pass back the
; general registers as returned by the interrupt routine (and possibly
; modified by the exit handler), and the same segment registers as
; on entry, unless the interrupt routine returns a value in a segment
; register. (in this case, there must be some code in the exit routine
; to handle this). This means that when we return to the caller, we
; return the general register values from the intUserXX set of stack
; frame members, but we return the segment registers from the pmUserXX
; set of frame members. By doing it this way, we don't have to do
; any work for the case where the interrupt subfuntion doesn't require
; any parameter manipulation. NOTE however, this means that when
; manipulating register values to be returned to the user, the segment
; registers are treated opposite to the way the general registers are
; treated. For general registers, to return a value to the user,
; store it in a intUserXX stack frame member. To return a segment
; value to the user, store it in a pmUserXX stack frame member.
;
; -------------------------------------------------------
subttl NetBIOS API Mapper Initialization Routine
page
; -------------------------------------------------------
; NetBIOS API MAPPER INITIALIZATION ROUTINE
; -------------------------------------------------------
DXPMCODE segment
assume cs:DXPMCODE
;--------------------------------------------------------
; InitNetMapper -- This routine initializates the NetBIOS API mapper.
;
; Input: none
; Output: none
; Errors: none
; Uses: all registers preserved
;
; Note: This routine expects to be called late enough in the DOS
; extender initialization cycle that it can use other interrupt
; mapping functions (like INT 21h). It must be called in
; PROTECTED MODE!
; And, assumes interrupts are to be enabled.
assume ds:DGROUP,es:NOTHING,ss:NOTHING
public InitNetMapper
InitNetMapper proc near
pusha
push es
; Do an installation check before doing anything else
SwitchToRealMode
assume ds:DGROUP,es:DGROUP
FSTI
mov ax,355Ch ;make sure the Int 5Ch vector
int 21h ; really points somewhere
assume es:NOTHING
mov ax,es ;can't be installed if 0 vector
or ax,bx
jz inm20
push ds
pop es
assume es:DGROUP
mov cx,(size NCB_Struc)/2 ;build a dummy NCB with an invalid
mov di,offset rgbXfrBuf1 ; 7Fh (Install) command code
mov bx,di
xor ax,ax
cld
rep stosw
mov [bx].NCB_Command,Install ;issue invalid request
int 5Ch
xor bx,bx ;assume not installed
cmp al,RC_Invalid_Cmd ;if it says invalid command, then
jnz inm20 ; it must be installed
dec bx ;bx !=0 means NetBIOS is installed
inm20:
SwitchToProtectedMode
FSTI
or bx,bx ;skip install if no NetBIOS
jnz inm20A ;net bios is there
jmp inm80 ;no NetBios
inm20A:
; we are going to have our net mapping layer installed. For this we need
; global memory for the post stub code. Allocate and initialize global
; memory now.
mov ax,NetHeapSize ;get size of low heap
call InitLowHeap ;init the low net heap
jnc inm20B ;low memory successfully initialized
jmp inm80 ;return with failure
inm20B:
; we need to allocate a block of memory in the low heap and copy some code
; down there which would handle the POST calls from the NetWork. It is
; necessary to have a piece in global memory do the POST handling because
; DOSX might have been swapped out by the Switcher when a POST request
; comes in.
mov cx, SIZE_OF_GLOBAL_NET_STUB_CODE
xor dx,dx ;DX:CX has the size
call AllocateLowBlock ;allocate a block in low memory
jnc inm20C ;allocation succeeded
jmp inm80 ;fail the initialization
inm20C:
; AX has a selector pointing to the start of the block. Copy the stub routine
; down into the block.
push es ;save
mov [SelNetStubCode],ax ;save the selector value
push ds ;save
mov es,ax ;destination sel of the xfer
push cs
pop ds
xor di,di ;destination offset
lea si,NetBiosStubCode ;source offset of xfer
mov cx,SIZE_OF_GLOBAL_NET_STUB_CODE ;size of the block
cld
rep movsb ;copy the block down
pop ds ;restore our DS
; now get the real mode segment value for the selector value in AX
mov bx,ax ;get selector value in BX
mov ax,6 ;get base DPMI call
int 31h ;CX:DX has the base address
shr dx,4 ;discard last 4 bits
and cx,0fh ;discarded bits were 0
shl cl,4 ;get it in MS nibble
or dh,cl ;DX has the RM segment
mov [SegNetStubCode],dx ;save it
; now copy the FAR address of the RMPostRtn into the stub code segment
lea di,FarAddrOfRMPostRtn ;variable where address to be saved
lea ax,NetBiosStubCode ;offset of the routine
sub di,ax ;DI has the offset in the stub
mov ax,segDXCode ;segment of real mode DosX
mov es:[di][2],ax ;save the segment
lea ax,RMPostRtn ;offset of the POST routine
mov es:[di][0],ax ;save the offset
; patch the address 'NBS_Patch_CalFarAddr' with the address in DI
mov si,NBS_Patch_CallFarAddr ;address to patch
mov es:[si],di ;patch it.
; calculate the offset to the other flag bytes in the stub code area that
; we will have to access.
lea di,fStubDelayNetPosting ;address when assembled
lea ax, NetBiosStubCode ;address of start of routine
sub di,ax ;address after move
mov [AddrfStubDelayNetPosting],di ;save it
; patch the address 'NBS_Patch_fsDelayNetPosting' with the value in DI
mov si,NBS_Patch_fsDelayNetPosting ;address to patch
mov es:[si],di ;patch it.
lea di,fStubTermNetRequests ;address when assembled
sub di,ax ;address after move
mov [AddrfStubTermNetRequest],di ;save it
; patch the address 'NBS_Patch_fsTermNetRequests' with the value in DI
mov si,NBS_Patch_fsTermNetRequests ;address to patch
mov es:[si],di ;patch it.
pop es
; The stub routine in global memory has now been put in place to handle POST
; calls. We now need to hook the INT 2AH and 5CH PM vectors to trap the network
; calls.
; The network seems to be installed, hook the INT 2Ah & 5Ch PM vectors
mov ax,352Ah ;get/store old Int 2Ah vector
int 21h
assume es:NOTHING
mov word ptr lpfnOldInt2A,bx
mov word ptr [lpfnOldInt2A+2],es
mov ax,355Ch ;get/store old Int 5Ch vector
int 21h
mov word ptr lpfnOldInt5C,bx
mov word ptr [lpfnOldInt5C+2],es
push ds
pop es
push cs
pop ds
assume ds:NOTHING,es:DGROUP
mov ax,252Ah ;set new Int 2Ah handler
mov dx,offset DXPMCODE:PMIntr2A
int 21h
mov ax,255Ch ;set new Int 5Ch handler
mov dx,offset DXPMCODE:PMIntr5C
int 21h
push es
pop ds
assume ds:DGROUP
; Allocate a selector to use for scratch purposes later
call AllocateLDTSelector
mov selNetScr,ax
; See if anybody wants to provide a different NetBIOS mapping table
SwitchToRealMode
assume ds:DGROUP,es:DGROUP
FSTI ;don't need 'em disabled
xor cx,cx ;subf'n zero
mov es,cx ;preset address to copy to NULL
mov di,cx
mov ax,REPLACE_MAP_TABLE
; DOSX net extender API call to substitute alternate NETBIOS
; mapping table
mov bx,VNETBIOS_DEV_ID ;VNETBIOS device ID
int 2Fh
; ES:DI contains address of alternate mapping table or NULL
mov cx,es ;Q: valid table pointer ?
jcxz inm70 ;N: NULL...keep current table
;Y: copy table pointed to by es:di to table area (simple replace)
mov ax,ds ; string move source (int 2F provided) table
mov es,ax ; in ds:si, and destination ApiMapTbl in the
mov ds,cx ; data segment now in es:di
mov si,di
mov di,offset ApiMapTbl ;ptr to table
mov cx,64 ;copy over 128 byte table
cld
rep movsw
mov ds,ax ;recall data segment
inm70:
SwitchToProtectedMode
assume ds:DGROUP,es:DGROUP,ss:NOTHING
FSTI
clc
jmp short inm90
inm80:
stc ;tell caller we didn't install
inm90:
pop es
popa
ret
InitNetMapper endp
;-----------------------------------------------------------------------------
; NetBiosStubCode
;
; DESCRIPTION This routine is actually relocated to a block of Global Memory
; obtained from the Switcher. It handles the POST calls from the
; NETBIOS layer. If DosX has been swapped out, fStubDelayPosting
; would be true and this routine would set a flag in the HCB
; to imply that the POSTing must be done. If DosX is active, this
; routine will call off to the RMPostRtn in DosX via a far call
; pointer.
;
; ENTRY:
; ES:BX - HCB
;
; EXIT:
; All registers preserved but for flags.
;
; USES:
; Flags
;
; NOTE:
; This routine will actually be copied to a global memory stub segment
; and will execute from there. However, since the routine would be moved
; while we are in protected mode, the routine is being assembled in the
; protected mode code segment.
;-----------------------------------------------------------------------------
NetBiosStubCode proc far
assume ds:NOTHING,es:NOTHING,ss:NOTHING
FCLI ;just to be sure
; Don't post anything if in the process of terminating
;-----------------------------------------------------------------------------
; The following instruction will have to be patched after the move:
;
; cmp cs:[fStubTermNetRequests],1
;
; we will mark the place that has to be patched.
;-----------------------------------------------------------------------------
db 2eh, 80h, 3eh ;CS: CMP BYTE PTR
NBS_Patch_fsTermNetRequests equ $ - NetBiosStubCode
dw ? ;address to compare
db 1 ;value to comapare
;-----------------------------------------------------------------------------
je NBSC_post_done
; Check if posting should be delayed
;-----------------------------------------------------------------------------
; The following instruction will have to be patched after the move:
;
; cmp cs:[fStubDelayNetPosting],0;Q: delay postings ?
;
; we will mark the place that has to be patched.
;-----------------------------------------------------------------------------
db 2eh, 80h, 3eh ;CS: CMP BYTE PTR
NBS_Patch_fsDelayNetPosting equ $ - NetBiosStubCode
dw ? ;address to compare
db 0 ;value to comapare
;-----------------------------------------------------------------------------
je NBSC_post_no_delay ;N: don't delay this posting
; we can do no posting. DosX has been swapped out. Set a flag in the HCB to
; imply that POSTing must be done later.
or byte ptr es:[bx.HCB_Flags],HCB_DELAY ;Y: mark as delayed
jmp short NBSC_post_done
NBSC_post_no_delay:
;-----------------------------------------------------------------------------
; call off to RMPostRtn in DosX. We will have to patch the following
; instruction after the move.
;
; call cs:[FarAddrOfRMPostRtn] ;call routine in DosX proper
;
; we will mark the place to match
;-----------------------------------------------------------------------------
db 2eh,0ffh,1eh ;CALL CS: DWORD PTR
NBS_Patch_CallFarAddr equ $ - NetBiosStubCode
dw ? ;call far address
;------------------------------------------------------------------------------
NBSC_post_done:
riret
NetBiosStubCode endp
;----------------------------------------------------------------------------;
; allocate space for some of the variables that the Stub Code uses. These ;
; will be filled in by PMODE code in the DosX. ;
;----------------------------------------------------------------------------;
fStubTermNetRequests db 0 ;DosX is terminating
fStubDelayNetPosting db 0 ;delay posting, DosX swapped
FarAddrOfRMPostRtn dd ? ;address of the actual POST rtn
SIZE_OF_GLOBAL_NET_STUB_CODE equ $ - NetBiosStubCode
;-----------------------------------------------------------------------------;
DXPMCODE ends
; -------------------------------------------------------
subttl NetBIOS API Mapper Termination Routine
page
; -------------------------------------------------------
; NetBIOS API MAPPER TERMINATION ROUTINE
; -------------------------------------------------------
DXCODE segment
assume cs:DXCODE
; TermNetMapper -- This routine is called when the 286 DOS extender
; is winding down so that any pending network requests from the
; protected mode application can be canceled.
;
; Input: none
; Output: none
; Errors: none
; Uses: ax,bx,cx,dx,si,di,es
;
; Note: This routine must be called in REAL MODE!
assume ds:DGROUP,es:NOTHING,ss:NOTHING
public TermNetMapper
TermNetMapper proc near
; set a flag in the stub code to imply that DosX is terminating and no more
; POSTs to be done.
mov di,[SelNetStubCode] ;selector for the stub area
or di,di ;is global heap in place ?
jnz @f ;yes.
ret
@@:
SwitchToProtectedMode
assume ds:DGROUP,es:DGROUP,ss:NOTHING
push es
mov es,di
assume es:nothing
; get the address of the flag byte fStubTermNetRequest after the block was
; relocated
mov di,[AddrfStubTermNetRequest]
; ES:DI has the flag byte address. Set the flag
mov byte ptr es:[di],1 ;set flag to delay posting
pop es
assume es:dgroup
; terminating the net driver interface...no more postings allowed
FSTI
mov cx,size NCB_Struc / 2
mov si,offset Cancel_NCB ;cancel control block buffer
mov di,si
xor ax,ax ;zero fill structure
cld
rep stosw
mov ds:[si.NCB_Command],Cancel ;Cancel command NCB
; We don't need to release the NCB/buffer(s) from the low heap because
; the entire low heap will soon be released.
; Search low heap list looking for copy of target NCB
mov cx,HCB_List
mov di,HCB_Header_Size ;offset of NCB in low heap block
term_next:
jcxz term_done
mov ax,cx
call GetSegmentAddress
add dx,di
adc bx,0 ;BX:DX = lma of low target NCB
call Lma2SegOff ;BX:DX = normalized SEG:OFF
dec bx ;return the same slightly unnormalized
add dx,10h ; SEG:OFF that was used initially
mov ds:[si.NCB_Buffer_Seg],bx ; point to NCB to cancel
mov ds:[si.NCB_Buffer_Off],dx
SwitchToRealMode ;also disables ints for us
assume ds:DGROUP,es:DGROUP
mov bx,si ;ES:BX points to cancelling NCB
pushf
call lpfnRmNetIsr ;do the cancel call
; return code in AL
SwitchToProtectedMode
assume ds:DGROUP,es:NOTHING,ss:NOTHING
FSTI
mov es,cx
mov cx,es:[di.HCB_Next]
jmp short term_next
term_done:
SwitchToRealMode
assume ds:DGROUP,es:DGROUP
FSTI
ret
TermNetMapper endp
; -------------------------------------------------------
DXCODE ends
; -------------------------------------------------------
subttl NetBIOS API Int 2Ah Mapper Interrupt Hook
page
; -------------------------------------------------------
; NetBIOS API INT 2Ah MAPPER INTERRUPT HOOK
; -------------------------------------------------------
DXPMCODE segment
assume cs:DXPMCODE
; -------------------------------------------------------
; PMIntr2A -- This routine traps Int 2Ah requests from a
; protected mode application. NetBIOS requests (ah =
; 1 or 4) are passed on to the Int 5Ch handler for
; further processing. Other requests are passed on
; to the next Int 2Ah handler in the interrupt chain.
;
; Input: User regs at time of interrupt
; Output: none
; Errors: none
; Uses: none
;
assume ds:NOTHING,es:NOTHING,ss:NOTHING
public PMIntr2A
PMIntr2A proc near
cld ;cya...
cmp ah,1 ;we only need to map the Int 2Ah
jz @f ; ah = 1 & 4 services--if it's
cmp ah,4 ; not one of those, just pass it
jz @f ; on down the chain...
sub sp,4 ; build a stack frame
push bp
mov bp,sp
push ax
push ds
mov ds,selDgroupPM
assume ds:DGROUP
mov ax,word ptr [lpfnOldInt2A+2] ; store previous INT 2A
mov word ptr [bp+4],ax ; handler
mov ax,word ptr [lpfnOldInt2A]
mov word ptr [bp+2],ax
pop ds
assume ds:NOTHING
pop ax
pop bp ; SS:SP -> previous handler
;let someone else deal with it
retf ; (most likely PMIntrReflector)
@@:
if PM_NCB_HANDLING
;
; if this is NT then we have decided we are making a NetBIOS call (es:bx points
; to an NCB in protect-mode memory). INT 0x2A, ah=1 or ah=4 just ends up calling
; the 0x5C entry point; ah is returned as 1 or 0, depending on whether an error
; is returned from 0x5C or not
;
push dx
mov dl,2ah
else
push bx ;save caller's bx
mov bx,4*2Ah ;indicate we came from int 2A handler
endif ; PM_NCB_HANDLING
jmp short DoNetRqst ;int 2Ah/5Ch common code
PMIntr2A endp
; -------------------------------------------------------
subttl NetBIOS API Int 5Ch Mapper Interrupt Hook
page
; -------------------------------------------------------
; NetBIOS API INT 5Ch MAPPER INTERRUPT HOOK
; -------------------------------------------------------
; PMIntr5C -- This routine maps Int 5Ch (and selected Int 2Ah)
; NetBIOS requests between a protected mode application, and
; the real mode interrupt handler.
;
; Input: User regs at time of interrupt
; Output: regs as returned by interrupt handler
; Errors:
; Uses: none
;
assume ds:NOTHING,es:NOTHING,ss:NOTHING
public PMIntr5C
PMIntr5C proc near
if PM_NCB_HANDLING
;
; we no longer want to make the call through the real-mode handler, since all
; it does is make the BOP
;
cld ; just in case
push dx
mov dl,5ch
DoNetRqst:
;
; Do a sync/async NETBIOS presence check. Don't BOP for this simple case.
; Also don't do the async call because Delrina WinFax Pro hasn't initialized
; The post address in the NCB.
;
cmp byte ptr es:[bx],7fh ; sync NETBIOS presence check
je skip_bop
cmp byte ptr es:[bx],0ffh ; async NETBIOS presence check
je skip_bop
ifdef WOW_x86
.386p
push ds
mov ds,selDgroupPM
assume ds:DGROUP
FBOP BOP_REDIR, SVC_NETBIOS5C, FastBop
pop ds
.286p
else
SVC SVC_NETBIOS5C
endif ; WOW_x86
cmp dl,2ah
jne @f
;
; this was a 0x2A call. Return ah = 0 if NetBIOS returned al = 0, else return
; ah = 1
;
sub ah,ah
or al,al
jz @f
inc ah
@@: pop dx
riret
skip_bop:
mov al,3 ; INVALID COMMAND error
mov es:[bx].ncb_retcode,al ; returned in NCB_RETCODE && al
mov es:[bx].ncb_cmd_cplt,al ; and NCB_CMD_CPLT
pop dx
riret
else
cld ;cya...
push bx ;save caller's bx
mov bx,4*5Ch ;indicate we came from int 5C
DoNetRqst label near ;start of int 2Ah/5Ch common code
push ax ;move the address of the
push ds ; proper real mode interrupt
mov ds,selDgroupPM ; handler (2A or 5C) to global var
assume ds:DGROUP
push es
mov ax,SEL_RMIVT OR STD_RING
mov es,ax
mov ax,word ptr es:[bx]
mov word ptr lpfnRmNetIsr,ax
mov ax,word ptr es:[bx+2]
mov word ptr [lpfnRmNetIsr+2],ax
pop es
pop ds ;restore caller's environment
assume ds:NOTHING
pop ax
pop bx
call EnterIntHandler ;build an interrupt stack frame
assume ds:DGROUP,es:NOTHING
FSTI ;-----------------------------------------------
; Allocate space in the low heap for the HCB/NCB and maybe a buffer
xor dx,dx
mov cx,HCB_SIZE ;DX:CX = # bytes low heap required
call GetEntryExitFlags ;AX=Entry flags / ES:BX -> PM NCB
test al,BUFF_IN+BUFF_OUT+BUFF_CHAIN ;need to allocate a low buffer?
jz i5c_alloc
;
; RLF 06/09/93
;
; from the command type, we think we have a buffer address and size. If either
; of these is 0, then we actually don't have a buffer; skip it
;
mov ah,al ; set default no buffer
and al,not (BUFF_IN or BUFF_OUT)
mov dx,es:[bx.NCB_Buffer_Off]
or dx,es:[bx.NCB_Buffer_Seg]
jz i5c_alloc
mov dx,es:[bx.NCB_Length]
or dx,dx
jz i5c_alloc
xor dx,dx ; restore dx to 0
mov al,ah ; restore buffer flags
add cx,es:[bx.NCB_Length] ;if so, add in it's length
adc dx,0
add cx,1fh ;allow space to align buffer
adc dx,0 ; on a paragraph boundry
and cx,not 0fh
test al,BUFF_CHAIN ;a 2nd weird-o buffer?
jz i5c_alloc
add cx,word ptr es:[bx.NCB_CallName] ;yes, add in it's len also
adc dx,0
add cx,1fh ;allow space to align buffer
adc dx,0 ; on a paragraph boundry
and cx,not 0fh
i5c_alloc:
push ax ;save entry/exit flags
FCLI ;treat allocate as critical section ------------
call AllocateLowBlock ;allocate conventional memory for
jnc @f ; HCB/NCB and maybe buffer
Debug_Out "Low heap allocation failed!"
pop ax ;clear stack
mov byte ptr [bp].intUserAX,RC_Resources
mov es:[bx.NCB_RetCode],RC_Resources
mov es:[bx.NCB_Cmd_Cplt],RC_Resources
jmp i5c_done
@@:
; Copy the PM NCB to the low heap and add our extra HCB fields
mov es,ax
xor di,di ;es:di -> low heap block
cld
stosw ;HCB_Handle
mov ax,bx
stosw ;HCB_PM_NCB_Off
mov ax,[bp].pmUserES
stosw ;HCB_PM_NCB_Seg
mov ax,HCB_List
stosw ;HCB_Next
xor ax,ax
stosw ;HCB_Flags = 0
mov HCB_List,es ;link HCB to head of list
FSTI ;-----------------------------------------------
push ds
mov ds,[bp].pmUserES
assume ds:NOTHING
errnz <size NCB_Struc and 1> ;if odd # bytes, can't just movsw
mov si,bx ;ES:DI->low NCB, DS:SI->PM NCB
mov cx,size NCB_Struc / 2
rep movsw
pop ds
assume ds:DGROUP
; Update the interrupt handler's registers to point to the low NCB
mov ax,es
call GetSegmentAddress
add dx,HCB_Header_Size
adc bx,0 ;BX:DX = lma of low NCB
pop ax ;refresh entry flags
push ax
push bx ;save lma of NCB
push dx
call Lma2SegOff ;BX:DX = normalized SEG:OFF of low NCB
dec bx ;we want to do a negative offset on the
add dx,10h ; NCB segment, so un-normalize it some
mov [bp].intUserES,bx ;point int handler's ES:BX to low NCB
mov [bp].intUserBX,dx
; If this is a cancel request, find the target NCB in the low heap
test al,BUFF_CANCEL ;cancel request?
jz i5c_not_cancel
mov di,HCB_Header_Size ;ES:DI -> low heap Cancel NCB
FCLI ;don't want list changing while looking --------
call FindTargetNCB ;BX:DX = SEG:OFF of target NCB
FSTI ;-----------------------------------------------
if DEBUG ;------------------------------------------------------------
jnc @f
Debug_Out "FindTargetNCB didn't!"
@@:
endif ;DEBUG --------------------------------------------------------
jc @f
mov es:[di.NCB_Buffer_Off],dx ;point cancel NCB to low
mov es:[di.NCB_Buffer_Seg],bx ; heap target NCB
@@:
i5c_not_cancel:
pop dx ;restore lma of NCB
pop bx
; If necessary, update NCB buffer pointer(s) and copy buffer(s) to low heap
pop ax ;recover entry flags
test al,BUFF_IN+BUFF_OUT+BUFF_CHAIN ;a buffer to point to?
jnz @f
jmp i5c_no_buf_in
@@:
add dx,size NCB_Struc + 0fh ;get lma of buffer, rounded up
adc bx,0 ; to the next higher paragraph
and dx,not 0fh
push ds
mov ds,[bp].pmUserES
mov si,[bp].pmUserBX ;DS:SI -> PM NCB
assume ds:NOTHING
push bx
push dx
call Lma2SegOff ;BX:DX = SEG:OFF of low buffer
mov di,HCB_Header_Size ;ES:DI -> low NCB
mov es:[di.NCB_Buffer_Off],dx
mov es:[di.NCB_Buffer_Seg],bx
pop dx
pop bx
test al,BUFF_IN+BUFF_CHAIN ;actually need to copy buffer?
jz i5c_buf_in_done
mov cx,ds:[si.NCB_Length] ;CX = buffer len
lds si,dword ptr ds:[si.NCB_Buffer_Off] ;DS:SI -> buffer
push ax
xor ax,ax
call CopyBuffer ;copies DS:SI to lma BX:DX len CX
pop ax
test al,BUFF_CHAIN
jz i5c_buf_in_done
add dx,es:[di.NCB_Length] ;BX:DX = lma of 2nd low heap buffer
adc bx,0
add dx,0fh
adc bx,0
and dx,not 0fh
push bx ;update low heap NCB with SEG:OFF
push dx ; of 2nd buffer
call Lma2SegOff
mov word ptr es:[di.NCB_CallName+2],dx ;2nd buffer loc stored
mov word ptr es:[di.NCB_CallName+4],bx ; at callname + 2
pop dx
pop bx
mov ds,[bp].pmUserES
mov si,[bp].pmUserBX ;DS:SI -> PM NCB
mov cx,word ptr ds:[si.NCB_CallName] ;CX = buffer len
lds si,dword ptr ds:[si.NCB_CallName+2] ;DS:SI -> buffer
xor ax,ax
call CopyBuffer ;copies DS:SI to lma BX:DX len CX
i5c_buf_in_done:
pop ds
assume ds:DGROUP
i5c_no_buf_in:
; Switch to real mode, and load the mapped real mode registers.
SwitchToRealMode ;also disables ints
assume ss:DGROUP
; --------------- START OF REAL MODE CODE ------------------------------
pop es
pop ds
assume ds:NOTHING,es:NOTHING
popa ;restore all the other registers
; If this is a NoWait command, hook the mapped NCB to point to our post
; routine. At this time ES:BX -> mapped NCB
test byte ptr es:[bx.NCB_Command],NoWait
jz @f
push ax ;save
;
; RLF 06/09/93
;
; although this is an async command, there may be no post address (app just
; polls return code until it goes non-0xff). In this case, don't set up our
; asynchronous notification routine
;
mov ax,es:[bx.NCB_Post_Off]
or ax,es:[bx.NCB_Post_Seg]
jz no_post_routine
assume ss:DGROUP ;ss has DOSX's data seg
mov ax,[SegNetStubCode] ;get segment of stub code
; the address of the stub code that will handle the POST is AX:0. Save this
; in the HCB.
mov word ptr es:[bx.NCB_Post_Off],0
mov word ptr es:[bx.NCB_Post_Seg],ax
no_post_routine:
pop ax ;restore
@@:
or byte ptr es:[bx.HCB_FLAGS],HCB_ISSUED
; Invoke the appropriate real mode interrupt handler (2Ah or 5Ch),
; reestablish our stack frame with the handler's returned registers,
; and then back to protected mode
call lpfnRmNetIsr ;exectue real mode interrupt handler
pushf
FCLI
pusha
push ds
push es
mov bp,sp ;restore stack frame pointer
mov ax,es:[bx.HCB_Handle] ;recover selector to current NCB/buff
push ax
SwitchToProtectedMode
assume ds:DGROUP,es:NOTHING,ss:NOTHING
; --------------- START OF PROTECTED MODE CODE -------------------------
; With some network drivers, and some NoWait commands, the operation may
; get 'posted' even before the driver IRETs from the issue call. If this
; has happened, the HCB_POSTED flag will be set. In this case, the caller's
; NCB and (possibly) buffer has already been updated, so we just discard
; the low heap block and exit. If the operation hasn't been posted already,
; we copy back the updated NCB info, and maybe a buffer. Note that interrupts
; are disabled, so we don't get 'posted' half way through this operation--
; that would be bad.
pop ax ;handle (selector) of low heap block
mov es,ax
mov di,HCB_Header_Size ;es:di -> low heap NCB
test byte ptr es:[di.HCB_Flags],HCB_POSTED ;already posted?
jnz i5c_release ; yes, just discard
and byte ptr es:[di.HCB_Flags],not HCB_ISSUED ;so post rtn knows
;we updated already
push ax ;save handle for later
call UpdateNCB ;update the caller's NCB
call GetEntryExitFlags ;AX=Exit Flags / ES:BX->PM NCB
test es:[bx.NCB_Command],NoWait ;don't copy buff now if NoWait
jnz i5c_no_buf_out
test al,BUFF_OUT
jz i5c_no_buf_out
;
; RLF 06/09/93
;
; although the flags for this command say we have an output buffer, we may
; not have one - address or length is 0; check it out
;
mov ax,es:[bx.NCB_Buffer_Off]
or ax,es:[bx.NCB_Buffer_Seg]
jz i5c_no_buf_out
mov ax,es:[bx.NCB_Length]
or ax,ax
jz i5c_no_buf_out
pop ax ;handle to low block back
push ax
call CopyBufferOut ;copy low heap buffer to pm app buffer
i5c_no_buf_out:
; If this was a Wait operation (or NoWait that failed), we are finished with
; the low heap block and can release it now.
pop ax ;recover handle to low heap block
test es:[bx.NCB_Command],NoWait ;if Wait, go release now
jz i5c_release
cmp es:[bx.NCB_RetCode],RC_Pending
jz i5c_done
; Most NetBIOS implementations seem to (correctly) set the RetCode to
; RC_Pending on NoWait requests. However, it seems that some Novell
; NetBIOS implementations can return RetCode == 00 but Cmd_Cplt ==
; RC_Pending (FFh). So, if it is a NoWait request, and RetCode isn't
; Pending, also check the Cmd_Cplt code.
cmp es:[bx.NCB_Cmd_Cplt],RC_Pending
jz i5c_done
Debug_Out "NoWait cmd with non Pending retcode!"
i5c_release:
push ds ;make sure es != low heap block sel
pop es ; (else FreeLowBlock will GP fault)
call DeLink ;DeLink HCB/NCB/Buffers from lnk list
call FreeLowBlock ;free the low heap block
; Finished! (at least for now) Restore caller's regs/stack and return
i5c_done:
mov ax,[bp].pmUserBX ;restore possibly modified BX to
mov [bp].intUserBX,ax ; PM NCB offset
call LeaveIntHandler
riret
endif ; if PM_NCB_HANDLING
PMIntr5C endp
; -------------------------------------------------------
DXPMCODE ends
; -------------------------------------------------------
subttl NetBIOS API Mapper Post Routine
page
; -------------------------------------------------------
; NetBIOS API MAPPER POST ROUTINE
; -------------------------------------------------------
;*******************************************************************************
;*
;* The code from here on down is only used if we are switching between real
;* and protect mode when making NetBIOS requests. It is ifdef'd out for WOW
;* because we now BOP the NetBIOS requests without switching modes
;*
;******************************************************************************/
;ife PM_NCB_HANDLING
DXCODE segment
assume cs:DXCODE
; -------------------------------------------------------
; RMPostRtn -- This REAL MODE routine is invoked by the network
; software when a NoWait NetBIOS command completes. This
; routine must update the applications copy of the NCB,
; possibly copy a buffer of data to the application, and
; possibly invoke the application's own post routine.
;
; Note, this will now be called when it is OK to POST the request
; back to the application. The Stub Code in global mrmory makes
; sure that this is OK to do.
;
; Input:
; Output:
; Errors:
; Uses:
assume ds:NOTHING,es:NOTHING,ss:NOTHING
public RMPostRtn
RMPostRtn proc far
FCLI ;just to be sure
cld ;cya...
push ax
push bx
push es
push ds ; NBP assumes ds saved, greaseballs
IFDEF ROM
SetRMDataSeg
ELSE
mov ds,selDgroup
ENDIF
assume ds:DGROUP
; Allocate a new stack frame, and then switch to the reflector stack
; frame.
mov regUserSP,sp
mov regUSerSS,ss
IFDEF ROM
push ds
pop ss
ELSE
mov ss,selDgroup
ENDIF
mov sp,pbReflStack
sub pbReflStack,CB_STKFRAME ;adjust pointer to next stack frame
FIX_STACK
push regUserSS ;save current stack loc on our stack
push regUserSP ; so we can restore it later
push es:[bx.HCB_Handle] ;selector to low heap block
; We are now running on our own stack, so we can switch into protected mode.
SwitchToProtectedMode ;destroys ax
; --------------- START OF PROTECTED MODE CODE -------------------------
pop ax ;ax = selector to low heap block
call NetBiosPostRoutine ;do the actual posting
pop regUserSP ;recover previous stack location
pop regUserSS
SwitchToRealMode ; Switch back to real mode.
; --------------- START OF REAL MODE CODE ------------------------------
; Switch back to the original stack, deallocate the interrupt stack frame,
; and return to the network software
CHECK_STACK
mov ss,regUserSS
mov sp,regUserSP
add pbReflStack,CB_STKFRAME
pop ds ; give ds back to NBP/XNS
pop es
pop bx
pop ax
ret
RMPostRtn endp
DXCODE ends
; -------------------------------------------------------
subttl NetBIOS API Mapper Utility Routines
page
; -------------------------------------------------------
; NetBIOS API MAPPER UTILITY ROUTINES
; -------------------------------------------------------
DXPMCODE segment
assume cs:DXPMCODE
; -------------------------------------------------------
; NetBiosPostRoutine -- local routine
; This PROTECT MODE routine is called when the network
; software completes a NoWait NetBIOS command. This
; routine must update the applications copy of the NCB,
; possibly copy a buffer of data to the application, and
; possibly invoke the application's own post routine.
;
; Input: ax --> selector to low heap block
; Output:
; Errors:
; Uses: ax,bx,es
assume ds:DGROUP,es:NOTHING,ss:NOTHING
public NetBiosPostRoutine
NetBiosPostRoutine proc near
IFNDEF WOW_x86
pusha
else
.386p
pushad
push fs
push gs
.286p
endif
; Update the protected mode copy of the NCB and copy buffer if required
push ax ;handle (selector) of low heap block
call UpdateNCB ;always update the caller's NCB
mov es,ax
mov bx,HCB_Header_Size ;ES:BX -> low heap NCB
les bx,dword ptr es:[bx.HCB_PM_NCB_Off] ;ES:BX -> PM NCB
call GetExitFlags2 ;AX=Exit Flags
test al,BUFF_OUT
jz postsub_no_buf
;
; RLF 06/09/93
;
; once more unto the breach dear friends: although we think this command has
; an output buffer, the app may think otherwise; let's check...
;
mov ax,es:[bx.NCB_Buffer_Off]
or ax,es:[bx.NCB_Buffer_Seg]
jz postsub_no_buf
mov ax,es:[bx.NCB_Length]
or ax,ax
jz postsub_no_buf
pop ax ;handle to low block back
push ax
call CopyBufferOut ;copy low heap buffer to pm app buffer
postsub_no_buf:
; Release the low heap space, unless the HCB_ISSUED flag is set (meaning
; that the net driver called us before returning from the initial Int 5Ch).
; In that case, the low heap block will be released by the Int 5Ch mapper.
pop ax ;recover handle to low heap block
push ax
push es
mov es,ax
mov di,HCB_Header_Size
or byte ptr es:[di.HCB_Flags],HCB_POSTED ;mark as posted
pop es
; Invoke the user's PM post routine, if there is one - AL=retcode, ES:BX->NCB
mov ax,es:[bx.NCB_Post_Off] ;did user specify a post routine?
or ax,es:[bx.NCB_Post_Seg]
jz postsub_done
mov [NBPSp],sp
rpushf ;build iret frame for user's
push cs ; routine to return to us
push offset postsub_ret
mov al,es:[bx.NCB_RetCode] ;pass ret code in al
push es:[bx.NCB_Post_Seg] ;invoke the user's post routine
push es:[bx.NCB_Post_Off]
retf
; PM app's post routine returns here when finished
postsub_ret:
mov ax,SEL_DXDATA OR STD_RING
mov ds,ax
mov sp,[NBPSp]
postsub_done:
pop ax
mov es,ax
test byte ptr es:[di.HCB_Flags],HCB_ISSUED ;still in Int 5C code?
jnz postsub_no_release ; yes, don't release
push ds ;make sure es != low heap block sel
pop es ; (else FreeLowBlock will GP fault)
call DeLink ;DeLink HCB/NCB/Buffers from lnk list
call FreeLowBlock ;free the low heap block
postsub_no_release:
IFNDEF WOW_x86
popa
ELSE
.386p
pop gs
pop fs
popad
.286p
ENDIF
ret
NetBiosPostRoutine endp
; -------------------------------------------------------
; DelayNetPostings -- This function is called when NetBIOS completions
; are to be delayed. We simply set a flag that causes the async
; post routine not to post to the application.
;
; Input: none
; Output: none
; Errors: none
; Uses: none
assume ds:DGROUP,es:NOTHING,ss:NOTHING
public DelayNetPosting
DelayNetPosting proc near
; Make sure posting is delayed. We need to set a flag in the StubCode area.
push es ;save
push di
mov di,[SelNetStubCode] ;selector for the stub area
or di,di ;did we copy to global memory ?
jz DelayNetPostingRet ;no, nothing to do.
mov es,di
; get the address of the flag byte fStubDelayNetPosting after the block was
; relocated
mov di,[AddrfStubDelayNetPosting]
; ES:DI has the flag byte address. Set the flag
mov byte ptr es:[di],1 ;set flag to delay posting
DelayNetPostingRet:
pop di
pop es ;restore
ret
DelayNetPosting endp
; -------------------------------------------------------
; ResumeNetPostings -- This function is called when completed NetBIOS
; postings can be resumed to the application. We traverse the
; list of NetBIOS requests, and 'post' the application on any that
; completed while posting were delayed.
;
; Input: none
; Output: none
; Errors: none
; Uses: none
assume ds:DGROUP,es:NOTHING,ss:NOTHING
public ResumeNetPosting
ResumeNetPosting proc near
push es
push di
push bx ; used by NetBiosPostRoutine
push ax
; set a flag in the StubCode area to imply that POSTing need not be delayed.
mov di,[SelNetStubCode] ;selector for the stub area
or di,di ;global heap in place ?
jnz dummy1
jmp ResumeNetPostingRet ;no.
dummy1:
mov es,di
; get the address of the flag byte fStubDelayNetPosting after the block was
; relocated
mov di,[AddrfStubDelayNetPosting]
; ES:DI has the flag byte address. ReSet the flag
mov byte ptr es:[di],0 ;reset the flag
FCLI ;protect access to linked list
mov cx,HCB_List
mov di,HCB_Header_Size ;offset of NCB in low heap block
resume_next:
jcxz resume_done
mov es,cx
mov cx,es:[di.HCB_Next]
test byte ptr es:[di.HCB_Flags],HCB_DELAY ;Has this one completed?
jz resume_next ; no, skip it
;Y: this packet was delayed...post it NOW !
mov ax,es:[di.HCB_Handle] ;selector to low heap block
FSTI
call NetBiosPostRoutine ;post the NCB finally
FCLI
; *** modification warning ***
; note: block has just been de-linked from list, so we MUST
; get the pointer to the next block before NetBiosPostRoutine
; is called (which calls DeLink)!
jmp short resume_next
resume_done:
FSTI
ResumeNetPostingRet:
pop ax
pop bx
pop di
pop es
ret
ResumeNetPosting endp
; ------------------------------------------------------
; CopyBufferOut -- This routine copies a buffer from the low heap
; block up to the PM app's buffer area.
;
; Input: AX = Selector to low heap block
; ES:BX -> PM NCB
; Output: none
; Errors: none
; Uses: none
assume ds:DGROUP,es:NOTHING
public CopyBufferOut
CopyBufferOut proc near
pusha
mov cx,es:[bx.NCB_Buffer_Seg]
or cx,es:[bx.NCB_Buffer_Off]
jz CBO_Buffer_Is_Null
push ds
mov di,bx ;ES:DI -> PM NCB
call GetSegmentAddress ;BX:DX = lma of low heap block
lds si,dword ptr es:[di.NCB_Buffer_Off] ;DS:SI -> PM buffer
assume ds:NOTHING
add dx,size NCB_Struc + HCB_Header_Size + 0fh
adc bx,0
and dx,not 0fh ;BX:DX = lma of low heap buffer
mov cx,es:[di.NCB_Length] ;CX = buffer length
mov al,1
call CopyBuffer ;copies from lma BX:DX to DS:SI, len CX
pop ds
assume ds:DGROUP
CBO_Buffer_Is_Null:
popa
ret
CopyBufferOut endp
; ------------------------------------------------------
; CopyBuffer -- This routine copies a buffer of length CX
; from DS:SI to the lma in BX:DX _or_ from the lma in
; BX:DX to DS:SI.
;
; Input: AX = direction flag, Z = from DS:SI -> lma,
; NZ = from lma -> DS:SI
; BX:DX = lma of source or dest
; CX = length in bytes
; DS:SI = pointer to source or dest
; Output: none
; Errors: none
; Uses: none
assume ds:NOTHING,es:NOTHING
public CopyBuffer
CopyBuffer proc near
pusha
push ds
push es
rpushf
FCLI
; Setup a selector/descriptor for the linear memory address
push ax ;save direction flag
push ds
mov ds,selDgroupPM ;temp dgroup addressability
assume ds:DGROUP
mov ax,selNetScr ;our scratch selector to use
dec cx ;length to limit
cCall NSetSegmentDscr,<ax,bx,dx,0,cx,STD_DATA>
pop ds
assume ds:NOTHING
inc cx ;back to length
; If necessary, adjust the length so we don't fault due by overrunning the
; DS segment
mov bx,ds ;get limit for DS segment
lsl bx,bx
sub bx,si ;less the DS offset
inc bx ; (limit is len - 1)
cmp bx,cx ;at least CX bytes left in segment?
jae @f
mov cx,bx ; no, only do # remaining
@@:
; Copy the buffer
xor di,di ;AX:DI is now SEL:OFF to lma
pop bx ;recover direction flag
or bx,bx
jnz @f
mov es,ax ;from DS:SI -> AX:DI, almost ready
jmp short cb_copy
@@:
xchg si,di ;from AX:DI -> DS:SI, adjust
push ds ; regs for movs instruction
pop es
mov ds,ax
cb_copy:
cld
shr cx,1 ;byte count to words, low bit to CY
rep movsw
jnc @f
movsb ;get any odd byte
@@:
npopf
pop es
pop ds
popa
ret
CopyBuffer endp
; ------------------------------------------------------
; DeLink -- This routine will unlink a HCB/NCB/Buffer low heap
; block from the HCB_List linked list.
;
; Input: AX = selector to block to unlink
; Output: block unlinked
; Uses: none
assume ds:DGROUP,es:NOTHING
public DeLink
DeLink proc near
push bx
push cx
push es
mov bx,HCB_Header_Size
cmp ax,HCB_List ;special case likely condition
jnz ul_search
mov es,ax ;ES:BX -> block to unlink
mov cx,es:[bx.HCB_Next] ;block is first in linked list
mov HCB_List,cx
jmp short ul_done
ul_search:
mov es,HCB_List ;ES:BX -> first block in list
ul_loop:
mov cx,es:[bx.HCB_Next] ;is this just before the block?
cmp ax,cx
jz ul_got_it
mov es,cx ; no, try the next one
jmp short ul_loop
ul_got_it:
push es ;okay, cut the selected block
mov es,cx ; out of the linked list
mov cx,es:[bx.HCB_Next]
pop es
mov es:[bx.HCB_Next],cx
ul_done:
pop es
pop cx
pop bx
ret
DeLink endp
; ------------------------------------------------------
; FindTargetNCB -- This routine searches the low memory heap
; to locate an NCB pointed to by another user PM NCB.
;
; Input: ES:DI -> Cancel NCB pointing to PM target NCB
; Output: BX:DX = RM SEG:OFF of target NCB in low heap
; Error: CY if target NCB can't be found
; Uses: none
assume ds:DGROUP,es:NOTHING
public FindTargetNCB
FindTargetNCB proc near
push ax
push cx
push di
push es
mov bx,es:[di.NCB_Buffer_Seg] ;get selector:offset of PM
mov dx,es:[di.NCB_Buffer_Off] ; target NCB to cancel
; Search low heap list looking for copy of target NCB
mov cx,HCB_List
mov di,HCB_Header_Size ;offset of NCB in low heap block
ft_next:
jcxz ft_err
mov es,cx ;ES:DI -> first/next HCB/NCB in list
cmp bx,es:[di.HCB_PM_NCB_Seg] ;is this the one?
jnz ft_not_it
cmp dx,es:[di.HCB_PM_NCB_Off]
jz ft_got_it
ft_not_it: ; no, get ptr to next one
mov cx,es:[di.HCB_Next]
jmp short ft_next
ft_got_it:
; ES:DI now points at the low heap copy of the target NCB, convert to SEG:OFF
mov ax,es
call GetSegmentAddress
add dx,di
adc bx,0 ;BX:DX = lma of low target NCB
call Lma2SegOff ;BX:DX = normalized SEG:OFF
dec bx ;return the same slightly unnormalized
add dx,10h ; SEG:OFF that was used initially
clc ;found it!
jmp short ft_done
ft_err: stc ;couldn't find the target ?!
ft_done:
pop es
pop di
pop cx
pop ax
ret
FindTargetNCB endp
;--------------------------------------------------------
; GetEntryExitFlags -- This routine looks up the entry/exit mapping
; flags for the current NetBIOS command.
;
; Input: user regs on stack frame
; Output: AX = flags
; ES:BX -> caller's PM NCB
; Errors: none
; Uses:
assume ds:DGROUP,es:NOTHING,ss:NOTHING
public GetEntryExitFlags
GetEntryExitFlags proc near
mov es,[bp].pmUserES ;point ES:BX to pm app's NCB
mov bx,[bp].pmUserBX ; and get command code
GetExitFlags2 label near
push di
mov al,es:[bx.NCB_Command]
and al,7Fh
cbw
mov di,ax ;map NCB command code to API
mov al,ApiMapTbl[di] ; mapping code via ApiMapTbl
shr ax,2 ;use map code to select entry/exit
mov di,ax ; flags via EntryExitCode
mov al,EntryExitFlags[di]
pop di
ret
GetEntryExitFlags endp
; ------------------------------------------------------
; UpdateNCB -- This routine updates the user's PM NCB copy from the
; low heap real mode copy.
;
; Input: AX = selector pointing to low heap HCB/NCB
; Output: User's PM NCB updated
; Errors: none
; Uses: none
assume ds:NOTHING,es:NOTHING,ss:NOTHING
public UpdateNCB
UpdateNCB proc near
push ax
push cx
push si
push di
push ds
push es
mov ds,ax
mov si,HCB_Header_Size ;DS:SI -> low heap NCB
les di,dword ptr [si.HCB_PM_NCB_Off] ;ES:DI -> protect mode NCB
mov al,[si.NCB_Command] ;want to check the command code later
and al,not NoWait
cld
movsw
movsw ;copy command, retcode, LSN, Num
add si,4 ;skip the buffer pointer
add di,4
movsw ;move the length
mov cx,34 / 2 ;len of callname, name, rto, sto (words)
cmp al,ChainSend ;funkey chain send command?
jnz @f
add si,16 ; yes, skip callname
add di,16
sub cx,16 / 2
@@:
rep movsw ;move name, rto, sto, maybe callname
add si,4 ;skip the post address
add di,4
mov cx,16 / 2 ;move the rest
rep movsw
pop es
pop ds
pop di
pop si
pop cx
pop ax
ret
UpdateNCB endp
; -------------------------------------------------------
DXPMCODE ends
;endif ; ife PM_NCB_HANDLING
DXDATA segment
my_sp dw ?
DXDATA ends
DXPMCODE segment
assume cs:DXPMCODE
;*******************************************************************************
;*
;* HandleNetbiosAnr
;*
;* Called when a simulated h/w interrupt for net callback functions occurs.
;* Checks if the call is a PM netbios ANR. If it is, we get the NCB
;* information and call the PM post routine
;*
;* ENTRY Nothing
;*
;* EXIT Nothing
;*
;* RETURNS Nothing
;*
;* ASSUMES Nothing
;*
;******************************************************************************/
public HandleNetbiosAnr
HandleNetbiosAnr proc
assume cs:DXPMCODE
assume ds:DGROUP
assume es:nothing
assume ss:nothing
;
; perform a BOP to discover if this is a protect mode netbios ANR. If it is then
; es and bx will point to the NCB
;
push ds
push SEL_DXDATA OR STD_RING
pop ds
ifdef WOW_x86
.386p
FBOP BOP_REDIR, SVC_NETBIOSCHECK, FastBop
.286p
else
SVC SVC_NETBIOSCHECK
endif ; WOW_x86
jnz @f
jmp chain_previous_int ; not PM Netbios ANR
@@:
;
; this is a PM Netbios ANR. Save state and call the post routine. There MUST be
; a post routine if we're here
;
IFNDEF WOW_x86
pusha
ELSE
.386p
pushad ; save all 32 bits
push fs
push gs
.286p
ENDIF
push es
ifdef WOW_x86
.386p
FBOP BOP_REDIR, SVC_NETBIOS5CINTERRUPT, FastBop
.286p
else
SVC SVC_NETBIOS5CINTERRUPT
endif ; WOW_x86
;
; save the stack pointer - apparently some apps will RETF, not IRET from the
; ANR. NB - this ISR cannot be re-entered since we only have the one previous
; stack pointer saved. This should be okay as long as the EOI is issued at the
; end of the ISR
;
mov my_sp,sp
;
; perform a fake interrupt to the PM post routine. ES:BX point at the NCB, AL is
; the return code. Post routine will IRET back (supposedly)
;
mov al,es:[bx.NCB_RetCode] ; pass ret code in al
pushf
call dword ptr es:[bx.NCB_Post_Off]
;
; restore our data segment and stack pointer, lest the app didn't IRET
;
mov ax,SEL_DXDATA OR STD_RING
mov ds,ax
mov sp,my_sp
;
; restore the interrupted state, then perform a BOP to reset the PIC and clean
; up any interrupt state
;
pop es
IFNDEF WOW_x86
popa
ELSE
.386p
pop gs
pop fs
popad
.286p
ENDIF
;
; this BOP will clear the emulated PICs (sends non-specific EOIs), and cause the
; next NET interrupt to be generated, if one is queued
;
ifdef WOW_x86
.386p
FBOP BOP_REDIR, SVC_RDRINTACK2, FastBop
.286p
else
SVC SVC_RDRINTACK2
endif ; WOW_x86
;
; restore the rest of the interrupted context and resume
;
pop ds
riret
chain_previous_int:
push word ptr OldInt76+2 ; selector of previous handler
push word ptr OldInt76 ; offset of previous handler
push bp
mov bp,sp
mov ds,[bp+6] ; retrieve interrupted ds
pop bp
retf 2 ; chain previous handler, removing space
; used for ds
HandleNetbiosAnr endp
public HookNetBiosHwInt
HookNetBiosHwInt proc near
;
; Save everything!!
;
pusha
push ds
push es
mov ax,3576h ; get old handler
int 21h
mov word ptr [OldInt76],bx
mov word ptr [OldInt76 + 2],es
mov dx,SEL_NBPMCODE OR STD_RING
mov ds,dx
mov dx,offset HandleNetbiosAnr
mov ah,25h
int 21h ; set new handler
pop es
pop ds
popa
ret
HookNetBiosHwInt endp
DXPMCODE ends
;****************************************************************
end
|