File: protocol.def

package info (click to toggle)
wine 10.0~repack-12
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 326,476 kB
  • sloc: ansic: 4,155,993; perl: 23,800; yacc: 22,031; javascript: 15,872; makefile: 12,346; pascal: 9,519; objc: 6,923; lex: 5,273; xml: 3,219; python: 2,688; cpp: 1,741; sh: 871; java: 750; asm: 299; cs: 62
file content (4081 lines) | stat: -rw-r--r-- 140,037 bytes parent folder | download | duplicates (3)
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
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
/* -*- C -*-
 *
 * Wine server protocol definition
 *
 * Copyright (C) 2001 Alexandre Julliard
 *
 * This file is used by tools/make_requests to build the
 * protocol structures in include/wine/server_protocol.h
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

@HEADER  /* start of C declarations */

#include <stdarg.h>
#include <stdlib.h>
#include <time.h>

#include <windef.h>
#include <winbase.h>
#include <ntuser.h>

typedef unsigned int obj_handle_t;
typedef unsigned int user_handle_t;
typedef unsigned int atom_t;
typedef unsigned int process_id_t;
typedef unsigned int thread_id_t;
typedef unsigned int data_size_t;
typedef unsigned int ioctl_code_t;
typedef unsigned __int64 lparam_t;
typedef unsigned __int64 apc_param_t;
typedef unsigned __int64 mem_size_t;
typedef unsigned __int64 file_pos_t;
typedef unsigned __int64 client_ptr_t;
typedef unsigned __int64 affinity_t;
typedef unsigned __int64 object_id_t;
typedef client_ptr_t mod_handle_t;

struct request_header
{
    int          req;          /* request code */
    data_size_t  request_size; /* request variable part size */
    data_size_t  reply_size;   /* reply variable part maximum size */
};

struct reply_header
{
    unsigned int error;        /* error result */
    data_size_t  reply_size;   /* reply variable part size */
};

/* placeholder structure for the maximum allowed request size */
/* this is used to construct the generic_request union */
struct request_max_size
{
    int pad[16]; /* the max request size is 16 ints */
};

#define FIRST_USER_HANDLE 0x0020  /* first possible value for low word of user handle */
#define LAST_USER_HANDLE  0xffef  /* last possible value for low word of user handle */


/* debug event data */
union debug_event_data
{
    int code;   /* event code */
    struct
    {
        int              code;       /* DbgExceptionStateChange */
        int              first;      /* first chance exception? */
        unsigned int     exc_code;   /* exception code */
        unsigned int     flags;      /* exception flags */
        client_ptr_t     record;     /* exception record */
        client_ptr_t     address;    /* exception address */
        int              nb_params;  /* number of parameters */
        int              __pad;
        client_ptr_t     params[15]; /* parameters */
    } exception;
    struct
    {
        int          code;       /* DbgCreateThreadStateChange */
        obj_handle_t handle;     /* handle to the new thread */
        client_ptr_t start;      /* thread startup routine */
    } create_thread;
    struct
    {
        int          code;       /* DbgCreateProcessStateChange */
        obj_handle_t file;       /* handle to the process exe file */
        obj_handle_t process;    /* handle to the new process */
        obj_handle_t thread;     /* handle to the new thread */
        mod_handle_t base;       /* base of executable image */
        int          dbg_offset; /* offset of debug info in file */
        int          dbg_size;   /* size of debug info */
        client_ptr_t start;      /* thread startup routine */
    } create_process;
    struct
    {
        int          code;       /* DbgExitThreadStateChange/DbgExitProcessStateChange */
        int          exit_code;  /* thread or process exit code */
    } exit;
    struct
    {
        int          code;       /* DbgLoadDllStateChange */
        obj_handle_t handle;     /* file handle for the dll */
        mod_handle_t base;       /* base address of the dll */
        int          dbg_offset; /* offset of debug info in file */
        int          dbg_size;   /* size of debug info */
        client_ptr_t name;       /* image name (optional) */
    } load_dll;
    struct
    {
        int          code;       /* DbgUnloadDllStateChange */
        int          __pad;
        mod_handle_t base;       /* base address of the dll */
    } unload_dll;
};


enum context_exec_space
{
    EXEC_SPACE_USERMODE,
    EXEC_SPACE_SYSCALL,
    EXEC_SPACE_EXCEPTION,
};

/* context data */
struct context_data
{
    unsigned int     machine;    /* machine type */
    unsigned int     flags;      /* SERVER_CTX_* flags */
    union
    {
        struct { unsigned int eip, ebp, esp, eflags, cs, ss; } i386_regs;
        struct { unsigned __int64 rip, rbp, rsp;
                 unsigned int cs, ss, flags, __pad; } x86_64_regs;
        struct { unsigned int sp, lr, pc, cpsr; } arm_regs;
        struct { unsigned __int64 sp, pc, pstate; } arm64_regs;
    } ctl;  /* selected by SERVER_CTX_CONTROL */
    union
    {
        struct { unsigned int eax, ebx, ecx, edx, esi, edi; } i386_regs;
        struct { unsigned __int64 rax,rbx, rcx, rdx, rsi, rdi,
                                  r8, r9, r10, r11, r12, r13, r14, r15; } x86_64_regs;
        struct { unsigned int r[13]; } arm_regs;
        struct { unsigned __int64 x[31]; } arm64_regs;
    } integer;  /* selected by SERVER_CTX_INTEGER */
    union
    {
        struct { unsigned int ds, es, fs, gs; } i386_regs;
        struct { unsigned int ds, es, fs, gs; } x86_64_regs;
    } seg;  /* selected by SERVER_CTX_SEGMENTS */
    union
    {
        struct { unsigned int ctrl, status, tag, err_off, err_sel, data_off, data_sel, cr0npx;
                 unsigned char regs[80]; } i386_regs;
        struct { struct { unsigned __int64 low, high; } fpregs[32]; } x86_64_regs;
        struct { unsigned __int64 d[32]; unsigned int fpscr; } arm_regs;
        struct { struct { unsigned __int64 low, high; } q[32]; unsigned int fpcr, fpsr; } arm64_regs;
    } fp;  /* selected by SERVER_CTX_FLOATING_POINT */
    union
    {
        struct { unsigned int dr0, dr1, dr2, dr3, dr6, dr7; } i386_regs;
        struct { unsigned __int64 dr0, dr1, dr2, dr3, dr6, dr7; } x86_64_regs;
        struct { unsigned int bvr[8], bcr[8], wvr[1], wcr[1]; } arm_regs;
        struct { unsigned __int64 bvr[8], wvr[2]; unsigned int bcr[8], wcr[2]; } arm64_regs;
    } debug;  /* selected by SERVER_CTX_DEBUG_REGISTERS */
    union
    {
        unsigned char i386_regs[512];
    } ext;                       /* selected by SERVER_CTX_EXTENDED_REGISTERS */
    union
    {
        struct { enum context_exec_space space; int __pad; } space;
    } exec_space;                /* selected by SERVER_CTX_EXEC_SPACE */
    union
    {
        struct { struct { unsigned __int64 low, high; } ymm_high[16]; } regs;
    } ymm;                       /* selected by SERVER_CTX_YMM_REGISTERS */
};

#define SERVER_CTX_CONTROL            0x01
#define SERVER_CTX_INTEGER            0x02
#define SERVER_CTX_SEGMENTS           0x04
#define SERVER_CTX_FLOATING_POINT     0x08
#define SERVER_CTX_DEBUG_REGISTERS    0x10
#define SERVER_CTX_EXTENDED_REGISTERS 0x20
#define SERVER_CTX_YMM_REGISTERS      0x40
#define SERVER_CTX_EXEC_SPACE         0x80

/* structure used in sending an fd from client to server */
struct send_fd
{
    thread_id_t tid;  /* thread id */
    int         fd;   /* file descriptor on client-side */
};

/* structure sent by the server on the wait fifo */
struct wake_up_reply
{
    client_ptr_t cookie;    /* magic cookie that was passed in select_request */
    int          signaled;  /* wait result */
    int          __pad;
};

/* NT-style timeout, in 100ns units, negative means relative timeout */
typedef __int64 timeout_t;
#define TIMEOUT_INFINITE (((timeout_t)0x7fffffff) << 32 | 0xffffffff)

/* absolute timeout, negative means that monotonic clock is used */
typedef __int64 abstime_t;

/* structure for process startup info */
struct startup_info_data
{
    unsigned int debug_flags;
    unsigned int console_flags;
    obj_handle_t console;
    obj_handle_t hstdin;
    obj_handle_t hstdout;
    obj_handle_t hstderr;
    unsigned int x;
    unsigned int y;
    unsigned int xsize;
    unsigned int ysize;
    unsigned int xchars;
    unsigned int ychars;
    unsigned int attribute;
    unsigned int flags;
    unsigned int show;
    process_id_t process_group_id;
    data_size_t  curdir_len;
    data_size_t  dllpath_len;
    data_size_t  imagepath_len;
    data_size_t  cmdline_len;
    data_size_t  title_len;
    data_size_t  desktop_len;
    data_size_t  shellinfo_len;
    data_size_t  runtime_len;
    /* VARARG(curdir,unicode_str,curdir_len); */
    /* VARARG(dllpath,unicode_str,dllpath_len); */
    /* VARARG(imagepath,unicode_str,imagepath_len); */
    /* VARARG(cmdline,unicode_str,cmdline_len); */
    /* VARARG(title,unicode_str,title_len); */
    /* VARARG(desktop,unicode_str,desktop_len); */
    /* VARARG(shellinfo,unicode_str,shellinfo_len); */
    /* VARARG(runtime,unicode_str,runtime_len); */
};

/* structure returned in the list of window properties */
struct property_data
{
    atom_t         atom;     /* property atom */
    int            string;   /* was atom a string originally? */
    lparam_t       data;     /* data stored in property */
};

/* structure to specify window rectangles */
struct rectangle
{
    int  left;
    int  top;
    int  right;
    int  bottom;
};

/* structure for parameters of async I/O calls */
struct async_data
{
    obj_handle_t    handle;        /* object to perform I/O on */
    obj_handle_t    event;         /* event to signal when done */
    client_ptr_t    iosb;          /* I/O status block in client addr space */
    client_ptr_t    user;          /* opaque user data containing callback pointer and async-specific data */
    client_ptr_t    apc;           /* user APC to call */
    apc_param_t     apc_context;   /* user APC context or completion value */
};

/* structures for extra message data */

struct hw_msg_source
{
    unsigned int    device;        /* source device (IMDT_* values) */
    unsigned int    origin;        /* source origin (IMO_* values) */
};

struct rawinput
{
    int                  type;      /* rawinput data type (RIM_* values) */
    unsigned int         device;    /* rawinput device pseudo-handle */
    unsigned int         wparam;    /* wparam of the WM_INPUT* message */
    unsigned int         usage;     /* HID device usage */
};

struct hardware_msg_data
{
    lparam_t             info;      /* extra info */
    data_size_t          size;      /* size of hardware message data */
    int                  __pad;
    unsigned int         hw_id;     /* unique id */
    unsigned int         flags;     /* hook flags */
    struct hw_msg_source source;    /* message source */
    struct rawinput      rawinput;  /* rawinput message data */
};

struct callback_msg_data
{
    client_ptr_t    callback;   /* callback function */
    lparam_t        data;       /* user data for callback */
    lparam_t        result;     /* message result */
};

struct winevent_msg_data
{
    user_handle_t   hook;       /* hook handle */
    thread_id_t     tid;        /* thread id */
    client_ptr_t    hook_proc;  /* hook proc address */
    /* followed by module name if any */
};

union hw_input
{
    int type;
    struct
    {
        int            type;    /* INPUT_KEYBOARD */
        unsigned short vkey;    /* virtual key code */
        unsigned short scan;    /* scan code */
        unsigned int   flags;   /* event flags */
        unsigned int   time;    /* event time */
        lparam_t       info;    /* extra info */
    } kbd;
    struct
    {
        int            type;    /* INPUT_MOUSE */
        int            x;       /* coordinates */
        int            y;
        unsigned int   data;    /* mouse data */
        unsigned int   flags;   /* event flags */
        unsigned int   time;    /* event time */
        lparam_t       info;    /* extra info */
    } mouse;
    struct
    {
        int            type;    /* INPUT_HARDWARE */
        unsigned int   msg;     /* message code */
        lparam_t       wparam;  /* parameters */
        lparam_t       lparam;  /* parameters */
        struct hid_input hid;   /* defined in ntuser.h */
    } hw;
};

union message_data
{
    unsigned char            bytes[1];   /* raw data for sent messages */
    struct hardware_msg_data hardware;
    struct callback_msg_data callback;
    struct winevent_msg_data winevent;
};

/* structure returned in filesystem events */
struct filesystem_event
{
    int         action;
    data_size_t len;
    char        name[1];
};

struct luid
{
    unsigned int low_part;
    int          high_part;
};

struct luid_attr
{
    struct luid  luid;
    unsigned int attrs;
};

struct acl
{
    unsigned char  revision;
    unsigned char  pad1;
    unsigned short size;
    unsigned short count;
    unsigned short pad2;
};

struct sid
{
    unsigned char revision;
    unsigned char sub_count;
    unsigned char id_auth[6];
    unsigned int  sub_auth[15];
};

struct generic_map
{
    unsigned int read;
    unsigned int write;
    unsigned int exec;
    unsigned int all;
};

#define MAX_ACL_LEN 65535

struct security_descriptor
{
    unsigned int control;       /* SE_ flags */
    data_size_t  owner_len;
    data_size_t  group_len;
    data_size_t  sacl_len;
    data_size_t  dacl_len;
    /* VARARG(owner,sid); */
    /* VARARG(group,sid); */
    /* VARARG(sacl,acl); */
    /* VARARG(dacl,acl); */
};

struct object_attributes
{
    obj_handle_t rootdir;       /* root directory */
    unsigned int attributes;    /* object attributes */
    data_size_t  sd_len;        /* length of security_descriptor data. may be 0 */
    data_size_t  name_len;      /* length of the name string. may be 0 */
    /* VARARG(sd,security_descriptor); */
    /* VARARG(name,unicode_str); */
};

struct object_type_info
{
    data_size_t   name_len;      /* length of the name string */
    unsigned int  index;         /* type index in global table */
    unsigned int  obj_count;     /* count of objects of this type */
    unsigned int  handle_count;  /* count of handles of this type */
    unsigned int  obj_max;       /* max count of objects of this type */
    unsigned int  handle_max;    /* max count of handles of this type */
    unsigned int  valid_access;  /* mask for valid access bits */
    struct generic_map mapping;  /* generic access mappings */
    /* VARARG(name,unicode_str); */
};

enum select_opcode
{
    SELECT_NONE,
    SELECT_WAIT,
    SELECT_WAIT_ALL,
    SELECT_SIGNAL_AND_WAIT,
    SELECT_KEYED_EVENT_WAIT,
    SELECT_KEYED_EVENT_RELEASE
};

union select_op
{
    enum select_opcode op;
    struct
    {
        enum select_opcode op;   /* SELECT_WAIT or SELECT_WAIT_ALL */
        obj_handle_t    handles[MAXIMUM_WAIT_OBJECTS];
        int             __pad;
    } wait;
    struct
    {
        enum select_opcode op;   /* SELECT_SIGNAL_AND_WAIT */
        obj_handle_t    wait;
        obj_handle_t    signal;  /* must be last in the structure so we can remove it on retries */
    } signal_and_wait;
    struct
    {
        enum select_opcode op;   /* SELECT_KEYED_EVENT_WAIT or SELECT_KEYED_EVENT_RELEASE */
        obj_handle_t    handle;
        client_ptr_t    key;
    } keyed_event;
};

enum apc_type
{
    APC_NONE,
    APC_USER,
    APC_ASYNC_IO,
    APC_VIRTUAL_ALLOC,
    APC_VIRTUAL_ALLOC_EX,
    APC_VIRTUAL_FREE,
    APC_VIRTUAL_QUERY,
    APC_VIRTUAL_PROTECT,
    APC_VIRTUAL_FLUSH,
    APC_VIRTUAL_LOCK,
    APC_VIRTUAL_UNLOCK,
    APC_MAP_VIEW,
    APC_MAP_VIEW_EX,
    APC_UNMAP_VIEW,
    APC_CREATE_THREAD,
    APC_DUP_HANDLE
};

struct user_apc
{
    enum apc_type    type;     /* APC_USER */
    int              __pad;
    client_ptr_t     func;     /* void (__stdcall *func)(ULONG_PTR,ULONG_PTR,ULONG_PTR); */
    apc_param_t      args[3];  /* arguments for user function */
};

union apc_call
{
    enum apc_type type;
    struct user_apc user;
    struct
    {
        enum apc_type    type;     /* APC_ASYNC_IO */
        unsigned int     status;   /* I/O status */
        client_ptr_t     user;     /* user pointer */
        client_ptr_t     sb;       /* status block */
        data_size_t      result;   /* result size */
    } async_io;
    struct
    {
        enum apc_type    type;         /* APC_VIRTUAL_ALLOC */
        unsigned int     op_type;      /* type of operation */
        client_ptr_t     addr;         /* requested address */
        mem_size_t       size;         /* allocation size */
        mem_size_t       zero_bits;    /* number of zero high bits */
        unsigned int     prot;         /* memory protection flags */
    } virtual_alloc;
    struct
    {
        enum apc_type    type;         /* APC_VIRTUAL_ALLOC */
        unsigned int     op_type;      /* type of operation */
        client_ptr_t     addr;         /* requested address */
        mem_size_t       size;         /* allocation size */
        mem_size_t       limit_low;    /* allocation address limits */
        mem_size_t       limit_high;
        mem_size_t       align;        /* allocation alignment */
        unsigned int     prot;         /* memory protection flags */
        unsigned int     attributes;   /* memory extended attributes */
    } virtual_alloc_ex;
    struct
    {
        enum apc_type    type;      /* APC_VIRTUAL_FREE */
        unsigned int     op_type;   /* type of operation */
        client_ptr_t     addr;      /* requested address */
        mem_size_t       size;      /* allocation size */
    } virtual_free;
    struct
    {
        enum apc_type    type;      /* APC_VIRTUAL_QUERY */
        int              __pad;
        client_ptr_t     addr;      /* requested address */
    } virtual_query;
    struct
    {
        enum apc_type    type;      /* APC_VIRTUAL_PROTECT */
        unsigned int     prot;      /* new protection flags */
        client_ptr_t     addr;      /* requested address */
        mem_size_t       size;      /* requested size */
    } virtual_protect;
    struct
    {
        enum apc_type    type;      /* APC_VIRTUAL_FLUSH */
        int              __pad;
        client_ptr_t     addr;      /* requested address */
        mem_size_t       size;      /* requested size */
    } virtual_flush;
    struct
    {
        enum apc_type    type;      /* APC_VIRTUAL_LOCK */
        int              __pad;
        client_ptr_t     addr;      /* requested address */
        mem_size_t       size;      /* requested size */
    } virtual_lock;
    struct
    {
        enum apc_type    type;      /* APC_VIRTUAL_UNLOCK */
        int              __pad;
        client_ptr_t     addr;      /* requested address */
        mem_size_t       size;      /* requested size */
    } virtual_unlock;
    struct
    {
        enum apc_type    type;         /* APC_MAP_VIEW */
        obj_handle_t     handle;       /* mapping handle */
        client_ptr_t     addr;         /* requested address */
        mem_size_t       size;         /* allocation size */
        file_pos_t       offset;       /* file offset */
        mem_size_t       zero_bits;    /* number of zero high bits */
        unsigned int     alloc_type;   /* allocation type */
        unsigned int     prot;         /* memory protection flags */
    } map_view;
    struct
    {
        enum apc_type    type;         /* APC_MAP_VIEW_EX */
        obj_handle_t     handle;       /* mapping handle */
        client_ptr_t     addr;         /* requested address */
        mem_size_t       size;         /* allocation size */
        file_pos_t       offset;       /* file offset */
        mem_size_t       limit_low;    /* allocation address limits */
        mem_size_t       limit_high;
        unsigned int     alloc_type;   /* allocation type */
        unsigned int     prot;         /* memory protection flags */
        unsigned short   machine;      /* requested machine for image mappings */
        unsigned short   __pad[3];
    } map_view_ex;
    struct
    {
        enum apc_type    type;      /* APC_UNMAP_VIEW */
        unsigned int     flags;     /* unmap flags */
        client_ptr_t     addr;      /* view address */
    } unmap_view;
    struct
    {
        enum apc_type    type;      /* APC_CREATE_THREAD */
        unsigned int     flags;     /* creation flags */
        client_ptr_t     func;      /* void (__stdcall *func)(void*);  start function */
        client_ptr_t     arg;       /* argument for start function */
        mem_size_t       zero_bits; /* number of zero high bits for thread stack */
        mem_size_t       reserve;   /* reserve size for thread stack */
        mem_size_t       commit;    /* commit size for thread stack */
    } create_thread;
    struct
    {
        enum apc_type    type;         /* APC_DUP_HANDLE */
        obj_handle_t     src_handle;   /* src handle to duplicate */
        obj_handle_t     dst_process;  /* dst process handle */
        unsigned int     access;       /* wanted access rights */
        unsigned int     attributes;   /* object attributes */
        unsigned int     options;      /* duplicate options */
    } dup_handle;
};

union apc_result
{
    enum apc_type type;
    struct
    {
        enum apc_type    type;      /* APC_ASYNC_IO */
        unsigned int     status;    /* new status of async operation */
        unsigned int     total;     /* bytes transferred */
    } async_io;
    struct
    {
        enum apc_type    type;      /* APC_VIRTUAL_ALLOC */
        unsigned int     status;    /* status returned by call */
        client_ptr_t     addr;      /* resulting address */
        mem_size_t       size;      /* resulting size */
    } virtual_alloc;
    struct
    {
        enum apc_type    type;      /* APC_VIRTUAL_ALLOC_EX */
        unsigned int     status;    /* status returned by call */
        client_ptr_t     addr;      /* resulting address */
        mem_size_t       size;      /* resulting size */
    } virtual_alloc_ex;
    struct
    {
        enum apc_type    type;      /* APC_VIRTUAL_FREE */
        unsigned int     status;    /* status returned by call */
        client_ptr_t     addr;      /* resulting address */
        mem_size_t       size;      /* resulting size */
    } virtual_free;
    struct
    {
        enum apc_type    type;      /* APC_VIRTUAL_QUERY */
        unsigned int     status;    /* status returned by call */
        client_ptr_t     base;      /* resulting base address */
        client_ptr_t     alloc_base;/* resulting allocation base */
        mem_size_t       size;      /* resulting region size */
        unsigned short   state;     /* resulting region state */
        unsigned short   prot;      /* resulting region protection */
        unsigned short   alloc_prot;/* resulting allocation protection */
        unsigned short   alloc_type;/* resulting region allocation type */
    } virtual_query;
    struct
    {
        enum apc_type    type;      /* APC_VIRTUAL_PROTECT */
        unsigned int     status;    /* status returned by call */
        client_ptr_t     addr;      /* resulting address */
        mem_size_t       size;      /* resulting size */
        unsigned int     prot;      /* old protection flags */
    } virtual_protect;
    struct
    {
        enum apc_type    type;      /* APC_VIRTUAL_FLUSH */
        unsigned int     status;    /* status returned by call */
        client_ptr_t     addr;      /* resulting address */
        mem_size_t       size;      /* resulting size */
    } virtual_flush;
    struct
    {
        enum apc_type    type;      /* APC_VIRTUAL_LOCK */
        unsigned int     status;    /* status returned by call */
        client_ptr_t     addr;      /* resulting address */
        mem_size_t       size;      /* resulting size */
    } virtual_lock;
    struct
    {
        enum apc_type    type;      /* APC_VIRTUAL_UNLOCK */
        unsigned int     status;    /* status returned by call */
        client_ptr_t     addr;      /* resulting address */
        mem_size_t       size;      /* resulting size */
    } virtual_unlock;
    struct
    {
        enum apc_type    type;      /* APC_MAP_VIEW */
        unsigned int     status;    /* status returned by call */
        client_ptr_t     addr;      /* resulting address */
        mem_size_t       size;      /* resulting size */
    } map_view;
    struct
    {
        enum apc_type    type;      /* APC_MAP_VIEW_EX */
        unsigned int     status;    /* status returned by call */
        client_ptr_t     addr;      /* resulting address */
        mem_size_t       size;      /* resulting size */
    } map_view_ex;
    struct
    {
        enum apc_type    type;      /* APC_UNMAP_VIEW */
        unsigned int     status;    /* status returned by call */
    } unmap_view;
    struct
    {
        enum apc_type    type;      /* APC_CREATE_THREAD */
        unsigned int     status;    /* status returned by call */
        process_id_t     pid;       /* process id */
        thread_id_t      tid;       /* thread id */
        client_ptr_t     teb;       /* thread teb (in process address space) */
        obj_handle_t     handle;    /* handle to new thread */
    } create_thread;
    struct
    {
        enum apc_type    type;      /* APC_DUP_HANDLE */
        unsigned int     status;    /* status returned by call */
        obj_handle_t     handle;    /* duplicated handle in dst process */
    } dup_handle;
    struct
    {
        enum apc_type    type;      /* APC_BREAK_PROCESS */
        unsigned int     status;    /* status returned by call */
    } break_process;
};

enum irp_type
{
    IRP_CALL_NONE,
    IRP_CALL_CREATE,
    IRP_CALL_CLOSE,
    IRP_CALL_READ,
    IRP_CALL_WRITE,
    IRP_CALL_FLUSH,
    IRP_CALL_IOCTL,
    IRP_CALL_VOLUME,
    IRP_CALL_FREE,
    IRP_CALL_CANCEL
};

union irp_params
{
    enum irp_type        type;      /* irp call type */
    struct
    {
        enum irp_type    type;      /* IRP_CALL_CREATE */
        unsigned int     access;    /* access rights */
        unsigned int     sharing;   /* sharing flags */
        unsigned int     options;   /* file options */
        client_ptr_t     device;    /* opaque ptr for the device */
        obj_handle_t     file;      /* file handle */
    } create;
    struct
    {
        enum irp_type    type;      /* IRP_CALL_CLOSE */
        int              __pad;
        client_ptr_t     file;      /* opaque ptr for the file object */
    } close;
    struct
    {
        enum irp_type    type;      /* IRP_CALL_READ */
        unsigned int     key;       /* driver key */
        data_size_t      out_size;  /* needed output size */
        int              __pad;
        client_ptr_t     file;      /* opaque ptr for the file object */
        file_pos_t       pos;       /* file position */
    } read;
    struct
    {
        enum irp_type    type;      /* IRP_CALL_WRITE */
        unsigned int     key;       /* driver key */
        client_ptr_t     file;      /* opaque ptr for the file object */
        file_pos_t       pos;       /* file position */
    } write;
    struct
    {
        enum irp_type    type;      /* IRP_CALL_FLUSH */
        int              __pad;
        client_ptr_t     file;      /* opaque ptr for the file object */
    } flush;
    struct
    {
        enum irp_type    type;      /* IRP_CALL_IOCTL */
        ioctl_code_t     code;      /* ioctl code */
        data_size_t      out_size;  /* needed output size */
        int              __pad;
        client_ptr_t     file;      /* opaque ptr for the file object */
    } ioctl;
    struct
    {
        enum irp_type    type;      /* IRP_CALL_VOLUME */
        unsigned int     info_class;/* information class */
        data_size_t      out_size;  /* needed output size */
        int              __pad;
        client_ptr_t     file;      /* opaque ptr for the file object */
    } volume;
    struct
    {
        enum irp_type    type;      /* IRP_CALL_FREE */
        int              __pad;
        client_ptr_t     obj;       /* opaque ptr for the freed object */
    } free;
    struct
    {
        enum irp_type    type;      /* IRP_CALL_CANCEL */
        int              __pad;
        client_ptr_t     irp;       /* opaque ptr for canceled irp */
    } cancel;
};

/* information about a PE image mapping, roughly equivalent to SECTION_IMAGE_INFORMATION */
struct pe_image_info
{
    client_ptr_t   base;
    client_ptr_t   map_addr;
    mem_size_t     stack_size;
    mem_size_t     stack_commit;
    unsigned int   entry_point;
    unsigned int   map_size;
    unsigned int   zerobits;
    unsigned int   subsystem;
    unsigned short subsystem_minor;
    unsigned short subsystem_major;
    unsigned short osversion_major;
    unsigned short osversion_minor;
    unsigned short image_charact;
    unsigned short dll_charact;
    unsigned short machine;
    unsigned char  contains_code : 1;
    unsigned char  wine_builtin : 1;
    unsigned char  wine_fakedll : 1;
    unsigned char  is_hybrid : 1;
    unsigned char  padding : 4;
    unsigned char  image_flags;
    unsigned int   loader_flags;
    unsigned int   header_size;
    unsigned int   file_size;
    unsigned int   checksum;
    unsigned int   dbg_offset;
    unsigned int   dbg_size;
};
#define IMAGE_FLAGS_ComPlusNativeReady        0x01
#define IMAGE_FLAGS_ComPlusILOnly             0x02
#define IMAGE_FLAGS_ImageDynamicallyRelocated 0x04
#define IMAGE_FLAGS_ImageMappedFlat           0x08
#define IMAGE_FLAGS_BaseBelow4gb              0x10
#define IMAGE_FLAGS_ComPlusPrefer32bit        0x20

struct rawinput_device
{
    unsigned int   usage;
    unsigned int   flags;
    user_handle_t  target;
};

struct cursor_pos
{
    int x;
    int y;
    unsigned int time;
    int __pad;
    lparam_t info;
};

struct directory_entry
{
    data_size_t name_len;
    data_size_t type_len;
    /* VARARG(name,unicode_str,name_len); */
    /* VARARG(type,unicode_str,type_len); */
};

struct monitor_info
{
    struct rectangle raw;     /* host / physical position of the monitor rect */
    struct rectangle virt;    /* client / virtual position of the monitor rect */
    unsigned int     flags;  /* MONITOR_FLAG_* flags for the monitor */
    unsigned int     dpi;    /* physical DPI for the monitor */
};
#define MONITOR_FLAG_PRIMARY  0x01
#define MONITOR_FLAG_CLONE    0x02
#define MONITOR_FLAG_INACTIVE 0x04

union tcp_connection
{
    struct
    {
        unsigned int family;
        process_id_t owner;
        unsigned int state;
    } common;
    struct
    {
        unsigned int family;
        process_id_t owner;
        unsigned int state;
        unsigned int local_addr;
        unsigned int local_port;
        unsigned int remote_addr;
        unsigned int remote_port;
    } ipv4;
    struct
    {
        unsigned int family;
        process_id_t owner;
        unsigned int state;
        unsigned char local_addr[16];
        unsigned int local_scope_id;
        unsigned int local_port;
        unsigned char remote_addr[16];
        unsigned int remote_scope_id;
        unsigned int remote_port;
    } ipv6;
};

union udp_endpoint
{
    struct
    {
        unsigned int family;
        process_id_t owner;
    } common;
    struct
    {
        unsigned int family;
        process_id_t owner;
        unsigned int addr;
        unsigned int port;
    } ipv4;
    struct
    {
        unsigned int family;
        process_id_t owner;
        unsigned char addr[16];
        unsigned int scope_id;
        unsigned int port;
    } ipv6;
};

/****************************************************************/
/* shared session mapping structures */

struct shared_cursor
{
    int                  x;                /* cursor position */
    int                  y;
    unsigned int         last_change;      /* time of last position change */
    struct rectangle     clip;             /* cursor clip rectangle */
};

typedef volatile struct
{
    unsigned int         flags;            /* desktop flags */
    struct shared_cursor cursor;           /* global cursor information */
    unsigned char        keystate[256];    /* asynchronous key state */
    unsigned __int64     monitor_serial;   /* winstation monitor update counter */
} desktop_shm_t;

typedef volatile struct
{
    int                  hooks_count[WH_MAX - WH_MIN + 2]; /* active hooks count */
    unsigned int         wake_mask;        /* wakeup mask */
    unsigned int         wake_bits;        /* wakeup bits */
    unsigned int         changed_mask;     /* changed wakeup mask */
    unsigned int         changed_bits;     /* changed wakeup bits */
} queue_shm_t;

typedef volatile struct
{
    int                  foreground;       /* is desktop foreground thread input */
    user_handle_t        active;           /* handle to the active window */
    user_handle_t        focus;            /* handle to the focus window */
    user_handle_t        capture;          /* handle to the capture window */
    user_handle_t        menu_owner;       /* handle to the menu owner */
    user_handle_t        move_size;        /* handle to the moving/resizing window */
    user_handle_t        caret;            /* handle to the caret window */
    struct rectangle     caret_rect;       /* caret rectangle */
    user_handle_t        cursor;           /* handle to the cursor */
    int                  cursor_count;     /* cursor show count */
    unsigned char        keystate[256];    /* key state */
    int                  keystate_lock;    /* keystate is locked */
} input_shm_t;

typedef volatile union
{
    desktop_shm_t        desktop;
    queue_shm_t          queue;
    input_shm_t          input;
} object_shm_t;

typedef volatile struct
{
    LONG64               seq;              /* sequence number - server updating if (seq & 1) != 0 */
    object_id_t          id;               /* object unique id, object data is valid if != 0 */
    object_shm_t         shm;              /* object shared data */
} shared_object_t;

struct obj_locator
{
    object_id_t          id;               /* object unique id, object data is valid if != 0 */
    mem_size_t           offset;           /* offset of the object in session shared memory */
};

/****************************************************************/
/* Request declarations */

/* Create a new process from the context of the parent */
@REQ(new_process)
    obj_handle_t token;          /* process token */
    obj_handle_t debug;          /* process debug object */
    obj_handle_t parent_process; /* parent process */
    unsigned int flags;          /* process creation flags */
    int          socket_fd;      /* file descriptor for process socket */
    unsigned int access;         /* access rights for process object */
    unsigned short machine;      /* architecture that the new process will use */
    data_size_t  info_size;      /* size of startup info */
    data_size_t  handles_size;   /* length of explicit handles list */
    data_size_t  jobs_size;      /* length of jobs list */
    VARARG(objattr,object_attributes);   /* object attributes */
    VARARG(handles,uints,handles_size);  /* handles list */
    VARARG(jobs,uints,jobs_size);        /* jobs list */
    VARARG(info,startup_info,info_size); /* startup information */
    VARARG(env,unicode_str);     /* environment for new process */
@REPLY
    obj_handle_t info;           /* new process info handle */
    process_id_t pid;            /* process id */
    obj_handle_t handle;         /* process handle (in the current process) */
@END


/* Retrieve information about a newly started process */
@REQ(get_new_process_info)
    obj_handle_t info;           /* info handle returned from new_process_request */
@REPLY
    int          success;      /* did the process start successfully? */
    int          exit_code;    /* process exit code if failed */
@END


/* Create a new thread */
@REQ(new_thread)
    obj_handle_t process;      /* process in which to create thread */
    unsigned int access;       /* wanted access rights */
    unsigned int flags;        /* thread creation flags */
    int          request_fd;   /* fd for request pipe */
    VARARG(objattr,object_attributes); /* object attributes */
@REPLY
    thread_id_t  tid;          /* thread id */
    obj_handle_t handle;       /* thread handle (in the current process) */
@END


/* Retrieve the new process startup info */
@REQ(get_startup_info)
@REPLY
    data_size_t  info_size;    /* size of startup info */
    unsigned short machine;    /* architecture for the new process */
    VARARG(info,startup_info,info_size); /* startup information */
    VARARG(env,unicode_str);   /* environment */
@END


/* Signal the end of the process initialization */
@REQ(init_process_done)
    client_ptr_t teb;          /* TEB of new thread (in process address space) */
    client_ptr_t peb;          /* PEB of new process (in process address space) */
    client_ptr_t ldt_copy;     /* address of LDT copy (in process address space) */
@REPLY
    int          suspend;      /* is process suspended? */
@END


/* Initialize the first thread of a new process */
@REQ(init_first_thread)
    int          unix_pid;     /* Unix pid of new process */
    int          unix_tid;     /* Unix tid of new thread */
    int          debug_level;  /* new debug level */
    int          reply_fd;     /* fd for reply pipe */
    int          wait_fd;      /* fd for blocking calls pipe */
@REPLY
    process_id_t pid;          /* process id of the new thread's process */
    thread_id_t  tid;          /* thread id of the new thread */
    timeout_t    server_start; /* server start time */
    unsigned int session_id;   /* process session id */
    data_size_t  info_size;    /* total size of startup info */
    VARARG(machines,ushorts);  /* array of supported machines */
@END


/* Initialize a new thread; called from the child after pthread_create() */
@REQ(init_thread)
    int          unix_tid;     /* Unix tid of new thread */
    int          reply_fd;     /* fd for reply pipe */
    int          wait_fd;      /* fd for blocking calls pipe */
    client_ptr_t teb;          /* TEB of new thread (in thread address space) */
    client_ptr_t entry;        /* entry point (in thread address space) */
@REPLY
    int          suspend;      /* is thread suspended? */
@END


/* Terminate a process */
@REQ(terminate_process)
    obj_handle_t handle;       /* process handle to terminate */
    int          exit_code;    /* process exit code */
@REPLY
    int          self;         /* suicide? */
@END


/* Terminate a thread */
@REQ(terminate_thread)
    obj_handle_t handle;       /* thread handle to terminate */
    int          exit_code;    /* thread exit code */
@REPLY
    int          self;         /* suicide? */
@END


/* Retrieve information about a process */
@REQ(get_process_info)
    obj_handle_t handle;           /* process handle */
@REPLY
    process_id_t pid;              /* server process id */
    process_id_t ppid;             /* server process id of parent */
    affinity_t   affinity;         /* process affinity mask */
    client_ptr_t peb;              /* PEB address in process address space */
    timeout_t    start_time;       /* process start time */
    timeout_t    end_time;         /* process end time */
    unsigned int session_id;       /* process session id */
    int          exit_code;        /* process exit code */
    int          priority;         /* priority class */
    unsigned short machine;        /* process architecture */
    VARARG(image,pe_image_info);   /* image info for main exe */
@END


/* Retrieve debug information about a process */
@REQ(get_process_debug_info)
    obj_handle_t handle;           /* process handle */
@REPLY
    obj_handle_t debug;            /* handle to debug port */
    int          debug_children;   /* inherit debugger to child processes */
    VARARG(image,pe_image_info);   /* image info for main exe */
@END


/* Fetch the name of the process image */
@REQ(get_process_image_name)
    obj_handle_t handle;           /* process handle */
    process_id_t pid;              /* process id */
    int          win32;            /* return a win32 filename? */
@REPLY
    data_size_t  len;              /* len in bytes required to store filename */
    VARARG(name,unicode_str);      /* image name for main exe */
@END


/* Retrieve information about a process memory usage */
@REQ(get_process_vm_counters)
    obj_handle_t handle;                        /* process handle */
@REPLY
    mem_size_t peak_virtual_size;               /* peak virtual memory in bytes */
    mem_size_t virtual_size;                    /* virtual memory in bytes */
    mem_size_t peak_working_set_size;           /* peak real memory in bytes */
    mem_size_t working_set_size;                /* real memory in bytes */
    mem_size_t pagefile_usage;                  /* commit charge in bytes */
    mem_size_t peak_pagefile_usage;             /* peak commit charge in bytes */
@END


/* Set a process information */
@REQ(set_process_info)
    obj_handle_t handle;       /* process handle */
    int          mask;         /* setting mask (see below) */
    int          priority;     /* priority class */
    affinity_t   affinity;     /* affinity mask */
    obj_handle_t token;        /* primary token */
@END
#define SET_PROCESS_INFO_PRIORITY 0x01
#define SET_PROCESS_INFO_AFFINITY 0x02
#define SET_PROCESS_INFO_TOKEN    0x04


/* Retrieve information about a thread */
@REQ(get_thread_info)
    obj_handle_t handle;        /* thread handle */
    unsigned int access;        /* required access rights */
@REPLY
    process_id_t pid;           /* server process id */
    thread_id_t  tid;           /* server thread id */
    client_ptr_t teb;           /* thread teb pointer */
    client_ptr_t entry_point;   /* thread entry point */
    affinity_t   affinity;      /* thread affinity mask */
    int          exit_code;     /* thread exit code */
    int          priority;      /* thread priority level */
    int          last;          /* last thread in process */
    int          suspend_count; /* thread suspend count */
    unsigned int flags;         /* GET_THREAD_INFO_FLAG_ flags */
    data_size_t  desc_len;      /* description length in bytes */
    VARARG(desc,unicode_str);   /* description string */
@END
#define GET_THREAD_INFO_FLAG_DBG_HIDDEN 0x01
#define GET_THREAD_INFO_FLAG_TERMINATED 0x02


/* Retrieve information about thread times */
@REQ(get_thread_times)
    obj_handle_t handle;        /* thread handle */
@REPLY
    timeout_t    creation_time; /* thread creation time */
    timeout_t    exit_time;     /* thread exit time */
    int          unix_pid;      /* thread native pid */
    int          unix_tid;      /* thread native pid */
@END


/* Set a thread information */
@REQ(set_thread_info)
    obj_handle_t handle;       /* thread handle */
    int          mask;         /* setting mask (see below) */
    int          priority;     /* priority class */
    affinity_t   affinity;     /* affinity mask */
    client_ptr_t entry_point;  /* thread entry point */
    obj_handle_t token;        /* impersonation token */
    VARARG(desc,unicode_str);  /* description string */
@END
#define SET_THREAD_INFO_PRIORITY    0x01
#define SET_THREAD_INFO_AFFINITY    0x02
#define SET_THREAD_INFO_TOKEN       0x04
#define SET_THREAD_INFO_ENTRYPOINT  0x08
#define SET_THREAD_INFO_DESCRIPTION 0x10
#define SET_THREAD_INFO_DBG_HIDDEN  0x20


/* Suspend a thread */
@REQ(suspend_thread)
    obj_handle_t handle;       /* thread handle */
@REPLY
    int          count;        /* new suspend count */
@END


/* Resume a thread */
@REQ(resume_thread)
    obj_handle_t handle;       /* thread handle */
@REPLY
    int          count;        /* new suspend count */
@END


/* Queue an APC for a thread or process */
@REQ(queue_apc)
    obj_handle_t handle;       /* thread or process handle */
    VARARG(call,apc_call);     /* call arguments */
@REPLY
    obj_handle_t handle;       /* APC handle */
    int          self;         /* run APC in caller itself? */
@END


/* Get the result of an APC call */
@REQ(get_apc_result)
    obj_handle_t handle;       /* handle to the APC */
@REPLY
    union apc_result result;   /* result of the APC */
@END


/* Close a handle for the current process */
@REQ(close_handle)
    obj_handle_t handle;       /* handle to close */
@END


/* Set a handle information */
@REQ(set_handle_info)
    obj_handle_t handle;       /* handle we are interested in */
    int          flags;        /* new handle flags */
    int          mask;         /* mask for flags to set */
@REPLY
    int          old_flags;    /* old flag value */
@END


/* Duplicate a handle */
@REQ(dup_handle)
    obj_handle_t src_process;  /* src process handle */
    obj_handle_t src_handle;   /* src handle to duplicate */
    obj_handle_t dst_process;  /* dst process handle */
    unsigned int access;       /* wanted access rights */
    unsigned int attributes;   /* object attributes */
    unsigned int options;      /* duplicate options */
@REPLY
    obj_handle_t handle;       /* duplicated handle in dst process */
@END


/* Allocate a reserve object for pre-allocating memory for object types */
@REQ(allocate_reserve_object)
    int type;                   /* reserve object type. See MEMORY_RESERVE_OBJECT_TYPE */
    VARARG(objattr,object_attributes); /* object attributes */
@REPLY
    obj_handle_t handle;        /* reserve object handle */
@END


/* Test if two handles refer to the same object */
@REQ(compare_objects)
    obj_handle_t first;         /* first object handle */
    obj_handle_t second;        /* second object handle */
@END


/* Make an object permanent or temporary */
@REQ(set_object_permanence)
    obj_handle_t handle;       /* handle to the object */
    int          permanent;    /* 1 to make permanent, 0 to make temporary */
@END


/* Open a handle to a process */
@REQ(open_process)
    process_id_t pid;          /* process id to open */
    unsigned int access;       /* wanted access rights */
    unsigned int attributes;   /* object attributes */
@REPLY
    obj_handle_t handle;       /* handle to the process */
@END


/* Open a handle to a thread */
@REQ(open_thread)
    thread_id_t  tid;          /* thread id to open */
    unsigned int access;       /* wanted access rights */
    unsigned int attributes;   /* object attributes */
@REPLY
    obj_handle_t handle;       /* handle to the thread */
@END


/* Wait for handles */
@REQ(select)
    int          flags;        /* wait flags (see below) */
    client_ptr_t cookie;       /* magic cookie to return to client */
    abstime_t    timeout;      /* timeout */
    data_size_t  size;         /* size of select_op */
    obj_handle_t prev_apc;     /* handle to previous APC */
    VARARG(result,apc_result); /* result of previous APC */
    VARARG(data,select_op,size); /* operation-specific data */
    VARARG(contexts,contexts);   /* suspend context(s) */
@REPLY
    obj_handle_t apc_handle;   /* handle to next APC */
    int          signaled;     /* were the handles immediately signaled? */
    VARARG(call,apc_call);     /* APC call arguments */
    VARARG(contexts,contexts); /* suspend context(s) */
@END
#define SELECT_ALERTABLE     1
#define SELECT_INTERRUPTIBLE 2


/* Create an event */
@REQ(create_event)
    unsigned int access;        /* wanted access rights */
    int          manual_reset;  /* manual reset event */
    int          initial_state; /* initial state of the event */
    VARARG(objattr,object_attributes); /* object attributes */
@REPLY
    obj_handle_t handle;        /* handle to the event */
@END

/* Event operation */
@REQ(event_op)
    obj_handle_t  handle;       /* handle to event */
    int           op;           /* event operation (see below) */
@REPLY
    int           state;        /* previous state */
@END
enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };

@REQ(query_event)
    obj_handle_t  handle;       /* handle to event */
@REPLY
    int          manual_reset;  /* manual reset event */
    int          state;         /* current state of the event */
@END

/* Open an event */
@REQ(open_event)
    unsigned int access;        /* wanted access rights */
    unsigned int attributes;    /* object attributes */
    obj_handle_t rootdir;       /* root directory */
    VARARG(name,unicode_str);   /* object name */
@REPLY
    obj_handle_t handle;        /* handle to the event */
@END


/* Create a keyed event */
@REQ(create_keyed_event)
    unsigned int access;        /* wanted access rights */
    VARARG(objattr,object_attributes); /* object attributes */
@REPLY
    obj_handle_t handle;        /* handle to the event */
@END

/* Open a keyed event */
@REQ(open_keyed_event)
    unsigned int access;        /* wanted access rights */
    unsigned int attributes;    /* object attributes */
    obj_handle_t rootdir;       /* root directory */
    VARARG(name,unicode_str);   /* object name */
@REPLY
    obj_handle_t handle;        /* handle to the event */
@END


/* Create a mutex */
@REQ(create_mutex)
    unsigned int access;        /* wanted access rights */
    int          owned;         /* initially owned? */
    VARARG(objattr,object_attributes); /* object attributes */
@REPLY
    obj_handle_t handle;        /* handle to the mutex */
@END


/* Release a mutex */
@REQ(release_mutex)
    obj_handle_t handle;        /* handle to the mutex */
@REPLY
    unsigned int prev_count;    /* value of internal counter, before release */
@END


/* Open a mutex */
@REQ(open_mutex)
    unsigned int access;        /* wanted access rights */
    unsigned int attributes;    /* object attributes */
    obj_handle_t rootdir;       /* root directory */
    VARARG(name,unicode_str);   /* object name */
@REPLY
    obj_handle_t handle;        /* handle to the mutex */
@END


/* Query a mutex */
@REQ(query_mutex)
    obj_handle_t  handle;       /* handle to mutex */
@REPLY
    unsigned int count;         /* current count of mutex */
    int          owned;         /* true if owned by current thread */
    int          abandoned;     /* true if abandoned */
@END


/* Create a semaphore */
@REQ(create_semaphore)
    unsigned int access;        /* wanted access rights */
    unsigned int initial;       /* initial count */
    unsigned int max;           /* maximum count */
    VARARG(objattr,object_attributes); /* object attributes */
@REPLY
    obj_handle_t handle;        /* handle to the semaphore */
@END


/* Release a semaphore */
@REQ(release_semaphore)
    obj_handle_t handle;        /* handle to the semaphore */
    unsigned int count;         /* count to add to semaphore */
@REPLY
    unsigned int prev_count;    /* previous semaphore count */
@END

@REQ(query_semaphore)
    obj_handle_t handle;       /* handle to the semaphore */
@REPLY
    unsigned int current;      /* current count */
    unsigned int max;          /* maximum count */
@END

/* Open a semaphore */
@REQ(open_semaphore)
    unsigned int access;        /* wanted access rights */
    unsigned int attributes;    /* object attributes */
    obj_handle_t rootdir;       /* root directory */
    VARARG(name,unicode_str);   /* object name */
@REPLY
    obj_handle_t handle;        /* handle to the semaphore */
@END


/* Create a file */
@REQ(create_file)
    unsigned int access;        /* wanted access rights */
    unsigned int sharing;       /* sharing flags */
    int          create;        /* file create action */
    unsigned int options;       /* file options */
    unsigned int attrs;         /* file attributes for creation */
    VARARG(objattr,object_attributes); /* object attributes */
    VARARG(filename,string);    /* file name */
@REPLY
    obj_handle_t handle;        /* handle to the file */
@END


/* Open a file object */
@REQ(open_file_object)
    unsigned int access;        /* wanted access rights */
    unsigned int attributes;    /* open attributes */
    obj_handle_t rootdir;       /* root directory */
    unsigned int sharing;       /* sharing flags */
    unsigned int options;       /* file options */
    VARARG(filename,unicode_str); /* file name */
@REPLY
    obj_handle_t handle;        /* handle to the file */
@END


/* Allocate a file handle for a Unix fd */
@REQ(alloc_file_handle)
    unsigned int access;        /* wanted access rights */
    unsigned int attributes;    /* object attributes */
    int          fd;            /* file descriptor on the client side */
@REPLY
    obj_handle_t handle;        /* handle to the file */
@END


/* Get the Unix name from a file handle */
@REQ(get_handle_unix_name)
    obj_handle_t   handle;      /* file handle */
@REPLY
    data_size_t    name_len;    /* unix name length */
    VARARG(name,string);        /* unix name */
@END


/* Get a Unix fd to access a file */
@REQ(get_handle_fd)
    obj_handle_t handle;        /* handle to the file */
@REPLY
    int          type;          /* file type (see below) */
    int          cacheable;     /* can fd be cached in the client? */
    unsigned int access;        /* file access rights */
    unsigned int options;       /* file open options */
@END
enum server_fd_type
{
    FD_TYPE_INVALID,  /* invalid file (no associated fd) */
    FD_TYPE_FILE,     /* regular file */
    FD_TYPE_DIR,      /* directory */
    FD_TYPE_SOCKET,   /* socket */
    FD_TYPE_SERIAL,   /* serial port */
    FD_TYPE_CHAR,     /* unspecified char device */
    FD_TYPE_DEVICE,   /* Windows device file */
    FD_TYPE_NB_TYPES
};


/* Retrieve (or allocate) the client-side directory cache entry */
@REQ(get_directory_cache_entry)
    obj_handle_t handle;        /* handle to the directory */
@REPLY
    int          entry;         /* cache entry on the client side */
    VARARG(free,ints);          /* entries that can be freed */
@END


/* Flush a file buffers */
@REQ(flush)
    struct async_data async;    /* async I/O parameters */
@REPLY
    obj_handle_t event;         /* event set when finished */
@END

/* Query file information */
@REQ(get_file_info)
    obj_handle_t handle;        /* handle to the file */
    unsigned int info_class;    /* queried information class */
@REPLY
    VARARG(data,bytes);         /* file info data */
@END

/* Query volume information */
@REQ(get_volume_info)
    obj_handle_t handle;        /* handle to the file */
    struct async_data async;    /* async I/O parameters */
    unsigned int info_class;    /* queried information class */
@REPLY
    obj_handle_t wait;          /* handle to wait on for blocking read */
    VARARG(data,bytes);         /* volume info data */
@END

/* Lock a region of a file */
@REQ(lock_file)
    obj_handle_t handle;        /* handle to the file */
    file_pos_t   offset;        /* offset of start of lock */
    file_pos_t   count;         /* count of bytes to lock */
    int          shared;        /* shared or exclusive lock? */
    int          wait;          /* do we want to wait? */
@REPLY
    obj_handle_t handle;        /* handle to wait on */
    int          overlapped;    /* is it an overlapped I/O handle? */
@END


/* Unlock a region of a file */
@REQ(unlock_file)
    obj_handle_t handle;        /* handle to the file */
    file_pos_t   offset;        /* offset of start of unlock */
    file_pos_t   count;         /* count of bytes to unlock */
@END


/* Perform a recv on a socket */
@REQ(recv_socket)
    int          oob;           /* are we receiving OOB data? */
    struct async_data async;    /* async I/O parameters */
    int          force_async;   /* Force asynchronous mode? */
@REPLY
    obj_handle_t wait;          /* handle to wait on for blocking recv */
    unsigned int options;       /* device open options */
    int          nonblocking;   /* is socket non-blocking? */
@END


/* Perform a send on a socket */
@REQ(send_socket)
    unsigned int flags;         /* SERVER_SOCKET_IO_* flags */
    struct async_data async;    /* async I/O parameters */
@REPLY
    obj_handle_t wait;          /* handle to wait on for blocking send */
    unsigned int options;       /* device open options */
    int          nonblocking;   /* is socket non-blocking? */
@END

#define SERVER_SOCKET_IO_FORCE_ASYNC 0x01
#define SERVER_SOCKET_IO_SYSTEM      0x02

/* Get socket event flags */
@REQ(socket_get_events)
    obj_handle_t handle;        /* socket handle */
    obj_handle_t event;         /* event to reset */
@REPLY
    unsigned int flags;         /* event mask */
    VARARG(status,uints);       /* array of status codes */
@END


/* Store ICMP id for ICMP over datagram fixup */
@REQ(socket_send_icmp_id)
    obj_handle_t   handle;        /* socket handle */
    unsigned short icmp_id;       /* ICMP packet id */
    unsigned short icmp_seq;      /* ICMP packed sequence */
@REPLY
@END


/* Get ICMP id for ICMP over datagram fixup */
@REQ(socket_get_icmp_id)
    obj_handle_t   handle;        /* socket handle */
    unsigned short icmp_seq;      /* ICMP packed sequence */
@REPLY
    unsigned short icmp_id;       /* ICMP packet id */
@END


/* Retrieve the next pending console ioctl request */
@REQ(get_next_console_request)
    obj_handle_t handle;        /* console server handle */
    int          signal;        /* server signal state */
    int          read;          /* 1 if reporting result of blocked read ioctl */
    unsigned int status;        /* status of previous ioctl */
    VARARG(out_data,bytes);     /* out_data of previous ioctl */
@REPLY
    unsigned int code;          /* ioctl code */
    unsigned int output;        /* output id or 0 for input */
    data_size_t  out_size;      /* ioctl output size */
    VARARG(in_data,bytes);      /* ioctl in_data */
@END


/* enable directory change notifications */
@REQ(read_directory_changes)
    unsigned int filter;        /* notification filter */
    int          subtree;       /* watch the subtree? */
    int          want_data;     /* flag indicating whether change data should be collected */
    struct async_data async;    /* async I/O parameters */
@END


@REQ(read_change)
    obj_handle_t handle;
@REPLY
    VARARG(events,filesystem_event);  /* collected filesystem events */
@END


/* Create a file mapping */
@REQ(create_mapping)
    unsigned int access;        /* wanted access rights */
    unsigned int flags;         /* SEC_* flags */
    unsigned int file_access;   /* file access rights */
    mem_size_t   size;          /* mapping size */
    obj_handle_t file_handle;   /* file handle */
    VARARG(objattr,object_attributes); /* object attributes */
@REPLY
    obj_handle_t handle;        /* handle to the mapping */
@END


/* Open a mapping */
@REQ(open_mapping)
    unsigned int access;        /* wanted access rights */
    unsigned int attributes;    /* object attributes */
    obj_handle_t rootdir;       /* root directory */
    VARARG(name,unicode_str);   /* object name */
@REPLY
    obj_handle_t handle;        /* handle to the mapping */
@END


/* Get information about a file mapping */
@REQ(get_mapping_info)
    obj_handle_t handle;        /* handle to the mapping */
    unsigned int access;        /* wanted access rights */
@REPLY
    mem_size_t   size;          /* mapping size */
    unsigned int flags;         /* SEC_* flags */
    obj_handle_t shared_file;   /* shared mapping file handle */
    data_size_t  total;         /* total required buffer size in bytes */
    VARARG(image,pe_image_info);/* image info for SEC_IMAGE mappings */
    VARARG(name,unicode_str);   /* filename for SEC_IMAGE mappings */
@END


/* Get the address to use to map an image mapping */
@REQ(get_image_map_address)
    obj_handle_t handle;        /* handle to the mapping */
@REPLY
    client_ptr_t addr;          /* map address */
@END


/* Add a memory view in the current process */
@REQ(map_view)
    obj_handle_t mapping;       /* file mapping handle */
    unsigned int access;        /* wanted access rights */
    client_ptr_t base;          /* view base address (page-aligned) */
    mem_size_t   size;          /* view size */
    file_pos_t   start;         /* start offset in mapping */
@END


/* Add a memory view for an image mapping in the current process */
@REQ(map_image_view)
    obj_handle_t mapping;       /* file mapping handle */
    client_ptr_t base;          /* view base address (page-aligned) */
    mem_size_t   size;          /* view size */
    unsigned int entry;         /* entry point in mapped view */
    unsigned short machine;     /* machine in the mapped view */
@END


/* Add a memory view for a builtin dll in the current process */
@REQ(map_builtin_view)
    VARARG(image,pe_image_info);/* image info */
    VARARG(name,unicode_str);   /* image filename */
@END


/* Get information about a mapped image view */
@REQ(get_image_view_info)
    obj_handle_t process;       /* process handle */
    client_ptr_t addr;          /* address inside mapped view (in process address space) */
@REPLY
    client_ptr_t base;          /* view base address */
    mem_size_t   size;          /* view size */
@END


/* Unmap a memory view from the current process */
@REQ(unmap_view)
    client_ptr_t base;          /* view base address */
@END


/* Get a range of committed pages in a file mapping */
@REQ(get_mapping_committed_range)
    client_ptr_t base;          /* view base address */
    file_pos_t   offset;        /* starting offset (page-aligned, in bytes) */
@REPLY
    mem_size_t   size;          /* size of range starting at offset (page-aligned, in bytes) */
    int          committed;     /* whether it is a committed range */
@END


/* Add a range to the committed pages in a file mapping */
@REQ(add_mapping_committed_range)
    client_ptr_t base;          /* view base address */
    file_pos_t   offset;        /* starting offset (page-aligned, in bytes) */
    mem_size_t   size;          /* size to set (page-aligned, in bytes) or 0 if only retrieving */
@END


/* Check if two memory maps are for the same file */
@REQ(is_same_mapping)
    client_ptr_t base1;         /* first view base address */
    client_ptr_t base2;         /* second view base address */
@END


/* Get the filename of a mapping */
@REQ(get_mapping_filename)
    obj_handle_t process;       /* process handle */
    client_ptr_t addr;          /* address inside mapped view (in process address space) */
@REPLY
    data_size_t  len;           /* total filename length in bytes */
    VARARG(filename,unicode_str); /* filename in NT format */
@END


struct thread_info
{
    timeout_t       start_time;
    thread_id_t     tid;
    int             base_priority;
    int             current_priority;
    int             unix_tid;
    client_ptr_t    teb;
    client_ptr_t    entry_point;
};

struct process_info
{
    timeout_t       start_time;
    data_size_t     name_len;
    int             thread_count;
    int             priority;
    process_id_t    pid;
    process_id_t    parent_pid;
    unsigned int    session_id;
    int             handle_count;
    int             unix_pid;
    /* VARARG(name,unicode_str,name_len); */
    /* VARARG(threads,struct thread_info,thread_count); */
};

/* Get a list of processes and threads currently running */
@REQ(list_processes)
@REPLY
    data_size_t     info_size;
    int             process_count;
    int             total_thread_count;
    data_size_t     total_name_len;
    VARARG(data,process_info,info_size);
@END


/* Create a debug object */
@REQ(create_debug_obj)
    unsigned int access;       /* wanted access rights */
    unsigned int flags;        /* object flags */
    VARARG(objattr,object_attributes); /* object attributes */
@REPLY
    obj_handle_t handle;       /* handle to the debug object */
@END


/* Wait for a debug event */
@REQ(wait_debug_event)
    obj_handle_t debug;        /* debug object */
@REPLY
    process_id_t  pid;         /* process id */
    thread_id_t   tid;         /* thread id */
    VARARG(event,debug_event); /* debug event data */
@END


/* Queue an exception event */
@REQ(queue_exception_event)
    int           first;       /* first chance exception? */
    unsigned int  code;        /* exception code */
    unsigned int  flags;       /* exception flags */
    client_ptr_t  record;      /* exception record */
    client_ptr_t  address;     /* exception address */
    data_size_t   len;         /* size of parameters */
    VARARG(params,uints64,len);/* exception parameters */
@REPLY
    obj_handle_t     handle;   /* handle to the queued event */
@END


/* Retrieve the status of an exception event */
@REQ(get_exception_status)
    obj_handle_t     handle;   /* handle to the queued event */
@END


/* Continue a debug event */
@REQ(continue_debug_event)
    obj_handle_t debug;        /* debug object */
    process_id_t pid;          /* process id to continue */
    thread_id_t  tid;          /* thread id to continue */
    unsigned int status;       /* continuation status */
@END


/* Start or stop debugging an existing process */
@REQ(debug_process)
    obj_handle_t handle;       /* process handle */
    obj_handle_t debug;        /* debug object to attach to the process */
    int          attach;       /* 1=attaching / 0=detaching from the process */
@END


/* Set debug object information */
@REQ(set_debug_obj_info)
    obj_handle_t debug;        /* debug object */
    unsigned int flags;        /* object flags */
@END


/* Read data from a process address space */
@REQ(read_process_memory)
    obj_handle_t handle;       /* process handle */
    client_ptr_t addr;         /* addr to read from */
@REPLY
    VARARG(data,bytes);        /* result data */
@END


/* Write data to a process address space */
@REQ(write_process_memory)
    obj_handle_t handle;       /* process handle */
    client_ptr_t addr;         /* addr to write to */
    VARARG(data,bytes);        /* data to write */
@END


/* Create a registry key */
@REQ(create_key)
    unsigned int access;       /* desired access rights */
    unsigned int options;      /* creation options */
    VARARG(objattr,object_attributes); /* object attributes */
    VARARG(class,unicode_str);         /* class name */
@REPLY
    obj_handle_t hkey;         /* handle to the created key */
@END

/* Open a registry key */
@REQ(open_key)
    obj_handle_t parent;       /* handle to the parent key */
    unsigned int access;       /* desired access rights */
    unsigned int attributes;   /* object attributes */
    VARARG(name,unicode_str);  /* key name */
@REPLY
    obj_handle_t hkey;         /* handle to the open key */
@END


/* Delete a registry key */
@REQ(delete_key)
    obj_handle_t hkey;         /* handle to the key */
@END


/* Flush a registry key */
@REQ(flush_key)
    obj_handle_t hkey;         /* handle to the key */
@END


/* Enumerate registry subkeys */
@REQ(enum_key)
    obj_handle_t hkey;         /* handle to registry key */
    int          index;        /* index of subkey (or -1 for current key) */
    int          info_class;   /* requested information class */
@REPLY
    int          subkeys;      /* number of subkeys */
    int          max_subkey;   /* longest subkey name */
    int          max_class;    /* longest class name */
    int          values;       /* number of values */
    int          max_value;    /* longest value name */
    int          max_data;     /* longest value data */
    timeout_t    modif;        /* last modification time */
    data_size_t  total;        /* total length needed for full name and class */
    data_size_t  namelen;      /* length of key name in bytes */
    VARARG(name,unicode_str,namelen);  /* key name */
    VARARG(class,unicode_str);         /* class name */
@END


/* Set a value of a registry key */
@REQ(set_key_value)
    obj_handle_t hkey;         /* handle to registry key */
    int          type;         /* value type */
    data_size_t  namelen;      /* length of value name in bytes */
    VARARG(name,unicode_str,namelen);  /* value name */
    VARARG(data,bytes);                /* value data */
@END


/* Retrieve the value of a registry key */
@REQ(get_key_value)
    obj_handle_t hkey;         /* handle to registry key */
    VARARG(name,unicode_str);  /* value name */
@REPLY
    int          type;         /* value type */
    data_size_t  total;        /* total length needed for data */
    VARARG(data,bytes);        /* value data */
@END


/* Enumerate a value of a registry key */
@REQ(enum_key_value)
    obj_handle_t hkey;         /* handle to registry key */
    int          index;        /* value index */
    int          info_class;   /* requested information class */
@REPLY
    int          type;         /* value type */
    data_size_t  total;        /* total length needed for full name and data */
    data_size_t  namelen;      /* length of value name in bytes */
    VARARG(name,unicode_str,namelen);  /* value name */
    VARARG(data,bytes);                /* value data */
@END


/* Delete a value of a registry key */
@REQ(delete_key_value)
    obj_handle_t hkey;         /* handle to registry key */
    VARARG(name,unicode_str);  /* value name */
@END


/* Load a registry branch from a file */
@REQ(load_registry)
    obj_handle_t file;         /* file to load from */
    VARARG(objattr,object_attributes); /* object attributes */
@END


/* UnLoad a registry branch from a file */
@REQ(unload_registry)
    obj_handle_t parent;       /* handle to the parent key */
    unsigned int attributes;   /* object attributes */
    VARARG(name,unicode_str);  /* key name */
@END


/* Save a registry branch to a file */
@REQ(save_registry)
    obj_handle_t hkey;         /* key to save */
    obj_handle_t file;         /* file to save to */
@END


/* Add a registry key change notification */
@REQ(set_registry_notification)
    obj_handle_t hkey;         /* key to watch for changes */
    obj_handle_t event;        /* event to set */
    int          subtree;      /* should we watch the whole subtree? */
    unsigned int filter;       /* things to watch */
@END


/* Rename a registry key */
@REQ(rename_key)
    obj_handle_t hkey;         /* handle to the key to be renamed */
    VARARG(name,unicode_str);  /* new name */
@END


/* Create a waitable timer */
@REQ(create_timer)
    unsigned int access;        /* wanted access rights */
    int          manual;        /* manual reset */
    VARARG(objattr,object_attributes); /* object attributes */
@REPLY
    obj_handle_t handle;        /* handle to the timer */
@END


/* Open a waitable timer */
@REQ(open_timer)
    unsigned int access;        /* wanted access rights */
    unsigned int attributes;    /* object attributes */
    obj_handle_t rootdir;       /* root directory */
    VARARG(name,unicode_str);   /* object name */
@REPLY
    obj_handle_t handle;        /* handle to the timer */
@END

/* Set a waitable timer */
@REQ(set_timer)
    obj_handle_t handle;        /* handle to the timer */
    timeout_t    expire;        /* next expiration absolute time */
    client_ptr_t callback;      /* callback function */
    client_ptr_t arg;           /* callback argument */
    int          period;        /* timer period in ms */
@REPLY
    int          signaled;      /* was the timer signaled before this call ? */
@END

/* Cancel a waitable timer */
@REQ(cancel_timer)
    obj_handle_t handle;        /* handle to the timer */
@REPLY
     int         signaled;      /* was the timer signaled before this calltime ? */
@END

/* Get information on a waitable timer */
@REQ(get_timer_info)
    obj_handle_t handle;        /* handle to the timer */
@REPLY
    timeout_t    when;          /* absolute time when the timer next expires */
    int          signaled;      /* is the timer signaled? */
@END


/* Retrieve the current context of a thread */
@REQ(get_thread_context)
    obj_handle_t handle;       /* thread handle */
    obj_handle_t context;      /* context handle */
    unsigned int flags;        /* context flags */
    unsigned int native_flags; /* flags for native context if WoW present */
    unsigned short machine;    /* context architecture */
@REPLY
    int          self;         /* was it a handle to the current thread? */
    obj_handle_t handle;       /* pending context handle */
    VARARG(contexts,contexts); /* thread context(s) */
@END


/* Set the current context of a thread */
@REQ(set_thread_context)
    obj_handle_t handle;       /* thread handle */
    unsigned int native_flags; /* flags for native context if WoW present */
    VARARG(contexts,contexts); /* thread context(s) */
@REPLY
    int          self;         /* was it a handle to the current thread? */
@END


/* Fetch a selector entry for a thread */
@REQ(get_selector_entry)
    obj_handle_t  handle;      /* thread handle */
    int           entry;       /* LDT entry */
@REPLY
    unsigned int  base;        /* selector base */
    unsigned int  limit;       /* selector limit */
    unsigned char flags;       /* selector flags */
@END


/* Add an atom */
@REQ(add_atom)
    VARARG(name,unicode_str);  /* atom name */
@REPLY
    atom_t        atom;        /* resulting atom */
@END


/* Delete an atom */
@REQ(delete_atom)
    atom_t        atom;        /* atom handle */
@END


/* Find an atom */
@REQ(find_atom)
    VARARG(name,unicode_str);  /* atom name */
@REPLY
    atom_t       atom;         /* atom handle */
@END


/* Get information about an atom */
@REQ(get_atom_information)
    atom_t       atom;         /* atom handle */
@REPLY
    int          count;        /* atom lock count */
    int          pinned;       /* whether the atom has been pinned */
    data_size_t  total;        /* actual length of atom name */
    VARARG(name,unicode_str);  /* atom name */
@END


/* Get a handle for the current thread message queue */
@REQ(get_msg_queue_handle)
@REPLY
    obj_handle_t handle;       /* handle to the queue */
@END


/* Get the message queue of the current thread */
@REQ(get_msg_queue)
@REPLY
    struct obj_locator locator;   /* locator for the shared session object */
@END


/* Set the file descriptor associated to the current thread queue */
@REQ(set_queue_fd)
    obj_handle_t handle;       /* handle to the file descriptor */
@END


/* Set the current message queue wakeup mask */
@REQ(set_queue_mask)
    unsigned int wake_mask;    /* wakeup bits mask */
    unsigned int changed_mask; /* changed bits mask */
    int          skip_wait;    /* will we skip waiting if signaled? */
@REPLY
    unsigned int wake_bits;    /* current wake bits */
    unsigned int changed_bits; /* current changed bits */
@END


/* Get the current message queue status */
@REQ(get_queue_status)
    unsigned int clear_bits;   /* should we clear the change bits? */
@REPLY
    unsigned int wake_bits;    /* wake bits */
    unsigned int changed_bits; /* changed bits since last time */
@END


/* Retrieve the process idle event */
@REQ(get_process_idle_event)
    obj_handle_t handle;       /* process handle */
@REPLY
    obj_handle_t event;        /* handle to idle event */
@END


/* Send a message to a thread queue */
@REQ(send_message)
    thread_id_t     id;        /* thread id */
    int             type;      /* message type (see below) */
    int             flags;     /* message flags (see below) */
    user_handle_t   win;       /* window handle */
    unsigned int    msg;       /* message code */
    lparam_t        wparam;    /* parameters */
    lparam_t        lparam;    /* parameters */
    timeout_t       timeout;   /* timeout for reply */
    VARARG(data,message_data); /* message data for sent messages */
@END

@REQ(post_quit_message)
    int             exit_code; /* exit code to return */
@END

enum message_type
{
    MSG_ASCII,          /* Ascii message (from SendMessageA) */
    MSG_UNICODE,        /* Unicode message (from SendMessageW) */
    MSG_NOTIFY,         /* notify message (from SendNotifyMessageW), always Unicode */
    MSG_CALLBACK,       /* callback message (from SendMessageCallbackW), always Unicode */
    MSG_CALLBACK_RESULT,/* result of a callback message */
    MSG_OTHER_PROCESS,  /* sent from other process, may include vararg data, always Unicode */
    MSG_POSTED,         /* posted message (from PostMessageW), always Unicode */
    MSG_HARDWARE,       /* hardware message */
    MSG_WINEVENT,       /* winevent message */
    MSG_HOOK_LL         /* low-level hardware hook */
};
#define SEND_MSG_ABORT_IF_HUNG  0x01


/* Send a hardware message to a thread queue */
@REQ(send_hardware_message)
    user_handle_t   win;       /* window handle */
    union hw_input  input;     /* input data */
    unsigned int    flags;     /* flags (see below) */
    VARARG(report,bytes);      /* HID report data */
@REPLY
    int             wait;      /* do we need to wait for a reply? */
    int             prev_x;    /* previous cursor position */
    int             prev_y;
    int             new_x;     /* new cursor position */
    int             new_y;
@END
#define SEND_HWMSG_INJECTED    0x01


/* Get a message from the current queue */
@REQ(get_message)
    unsigned int    flags;     /* PM_* flags */
    user_handle_t   get_win;   /* window handle to get */
    unsigned int    get_first; /* first message code to get */
    unsigned int    get_last;  /* last message code to get */
    unsigned int    hw_id;     /* id of the previous hardware message (or 0) */
    unsigned int    wake_mask; /* wakeup bits mask */
    unsigned int    changed_mask; /* changed bits mask */
    unsigned int    internal;  /* get internal messages only */
@REPLY
    user_handle_t   win;       /* window handle */
    unsigned int    msg;       /* message code */
    lparam_t        wparam;    /* parameters */
    lparam_t        lparam;    /* parameters */
    int             type;      /* message type */
    int             x;         /* message x position */
    int             y;         /* message y position */
    unsigned int    time;      /* message time */
    data_size_t     total;     /* total size of extra data */
    VARARG(data,message_data); /* message data for sent messages */
@END


/* Reply to a sent message */
@REQ(reply_message)
    int             remove;    /* should we remove the message? */
    lparam_t        result;    /* message result */
    VARARG(data,bytes);        /* message data for sent messages */
@END


/* Accept and remove the current hardware message */
@REQ(accept_hardware_message)
    unsigned int    hw_id;     /* id of the hardware message */
@END


/* Retrieve the reply for the last message sent */
@REQ(get_message_reply)
    int             cancel;    /* cancel message if not ready? */
@REPLY
    lparam_t        result;    /* message result */
    VARARG(data,bytes);        /* message data for sent messages */
@END


/* Set a window timer */
@REQ(set_win_timer)
    user_handle_t   win;       /* window handle */
    unsigned int    msg;       /* message to post */
    unsigned int    rate;      /* timer rate in ms */
    lparam_t        id;        /* timer id */
    lparam_t        lparam;    /* message lparam (callback proc) */
@REPLY
    lparam_t        id;        /* timer id */
@END


/* Kill a window timer */
@REQ(kill_win_timer)
    user_handle_t   win;       /* window handle */
    lparam_t        id;        /* timer id */
    unsigned int    msg;       /* message to post */
@END


/* check if the thread owning the window is hung */
@REQ(is_window_hung)
    user_handle_t   win;       /* window handle */
@REPLY
    int is_hung;
@END


/* Retrieve info about a serial port */
@REQ(get_serial_info)
    obj_handle_t handle;       /* handle to comm port */
    int          flags;
@REPLY
    unsigned int eventmask;
    unsigned int pending_write;
@END


/* Set info about a serial port */
@REQ(set_serial_info)
    obj_handle_t handle;       /* handle to comm port */
    int          flags;        /* bitmask to set values (see below) */
@END
#define SERIALINFO_PENDING_WRITE 0x04

/* Cancel all sync io on a thread */
@REQ(cancel_sync)
    obj_handle_t handle;        /* thread handle on which to cancel io */
    client_ptr_t iosb;          /* I/O status block (NULL=all) */
@END

/* Create an async I/O */
@REQ(register_async)
    int          type;          /* type of queue to look after */
    struct async_data async;    /* async I/O parameters */
    int          count;         /* count - usually # of bytes to be read/written */
@END
#define ASYNC_TYPE_READ  0x01
#define ASYNC_TYPE_WRITE 0x02
#define ASYNC_TYPE_WAIT  0x03


/* Cancel all async op on a fd */
@REQ(cancel_async)
    obj_handle_t handle;        /* handle to comm port, socket or file */
    client_ptr_t iosb;          /* I/O status block (NULL=all) */
    int          only_thread;   /* cancel matching this thread */
@END


/* Retrieve results of an async */
@REQ(get_async_result)
    client_ptr_t   user_arg;      /* user arg used to identify async */
@REPLY
    VARARG(out_data,bytes);       /* iosb output data */
@END


/* Notify direct completion of async and close the wait handle if not blocking */
@REQ(set_async_direct_result)
    obj_handle_t   handle;        /* wait handle */
    apc_param_t    information;   /* IO_STATUS_BLOCK Information */
    unsigned int   status;        /* completion status */
    int            mark_pending;  /* set async to pending before completion? */
@REPLY
    obj_handle_t   handle;        /* wait handle, or NULL if closed */
@END


/* Perform a read on a file object */
@REQ(read)
    struct async_data async;      /* async I/O parameters */
    file_pos_t     pos;           /* read position */
@REPLY
    obj_handle_t   wait;          /* handle to wait on for blocking read */
    unsigned int   options;       /* device open options */
    VARARG(data,bytes);           /* read data */
@END


/* Perform a write on a file object */
@REQ(write)
    struct async_data async;      /* async I/O parameters */
    file_pos_t     pos;           /* write position */
    VARARG(data,bytes);           /* write data */
@REPLY
    obj_handle_t   wait;          /* handle to wait on for blocking write */
    unsigned int   options;       /* device open options */
    data_size_t    size;          /* size written */
@END


/* Perform an ioctl on a file */
@REQ(ioctl)
    ioctl_code_t   code;          /* ioctl code */
    struct async_data async;      /* async I/O parameters */
    VARARG(in_data,bytes);        /* ioctl input data */
@REPLY
    obj_handle_t   wait;          /* handle to wait on for blocking ioctl */
    unsigned int   options;       /* device open options */
    VARARG(out_data,bytes);       /* ioctl output data */
@END


/* Store results of an async irp */
@REQ(set_irp_result)
    obj_handle_t handle;          /* handle to the irp */
    unsigned int status;          /* status of the irp */
    data_size_t  size;            /* result size (input or output depending on the operation) */
    VARARG(data,bytes);           /* output data of the irp */
@END


/* Create a named pipe */
@REQ(create_named_pipe)
    unsigned int   access;
    unsigned int   options;
    unsigned int   sharing;
    unsigned int   disposition;
    unsigned int   maxinstances;
    unsigned int   outsize;
    unsigned int   insize;
    timeout_t      timeout;
    unsigned int   flags;
    VARARG(objattr,object_attributes); /* object attributes */
@REPLY
    obj_handle_t   handle;       /* handle to the pipe */
    int            created;
@END

/* flags in create_named_pipe and get_named_pipe_info */
#define NAMED_PIPE_MESSAGE_STREAM_WRITE 0x0001
#define NAMED_PIPE_MESSAGE_STREAM_READ  0x0002
#define NAMED_PIPE_NONBLOCKING_MODE     0x0004
#define NAMED_PIPE_SERVER_END           0x8000

/* Set named pipe information by handle */
@REQ(set_named_pipe_info)
    obj_handle_t   handle;
    unsigned int   flags;
@END

/* Create a window */
@REQ(create_window)
    user_handle_t  parent;      /* parent window */
    user_handle_t  owner;       /* owner window */
    atom_t         atom;        /* class atom */
    mod_handle_t   instance;    /* module instance */
    unsigned int   dpi_context; /* thread DPI context */
    unsigned int   style;       /* window style */
    unsigned int   ex_style;    /* window extended style */
    VARARG(class,unicode_str);  /* class name */
@REPLY
    user_handle_t  handle;      /* created window */
    user_handle_t  parent;      /* full handle of parent */
    user_handle_t  owner;       /* full handle of owner */
    int            extra;       /* number of extra bytes */
    client_ptr_t   class_ptr;   /* pointer to class in client address space */
    unsigned int   dpi_context; /* window DPI context */
@END


/* Destroy a window */
@REQ(destroy_window)
    user_handle_t  handle;      /* handle to the window */
@END


/* Retrieve the desktop window for the current thread */
@REQ(get_desktop_window)
    int            force;       /* force creation if it doesn't exist */
@REPLY
    user_handle_t  top_window;  /* handle to the desktop window */
    user_handle_t  msg_window;  /* handle to the top-level HWND_MESSAGE parent */
@END


/* Set a window owner */
@REQ(set_window_owner)
    user_handle_t  handle;      /* handle to the window */
    user_handle_t  owner;       /* new owner */
@REPLY
    user_handle_t  full_owner;  /* full handle of new owner */
    user_handle_t  prev_owner;  /* full handle of previous owner */
@END


/* Get information from a window handle */
@REQ(get_window_info)
    user_handle_t  handle;      /* handle to the window */
@REPLY
    user_handle_t  full_handle; /* full 32-bit handle */
    user_handle_t  last_active; /* last active popup */
    process_id_t   pid;         /* process owning the window */
    thread_id_t    tid;         /* thread owning the window */
    atom_t         atom;        /* class atom */
    int            is_unicode;  /* ANSI or unicode */
    unsigned int   dpi_context; /* window DPI context */
@END


/* Set some information in a window */
@REQ(set_window_info)
    unsigned short flags;         /* flags for fields to set (see below) */
    short int      is_unicode;    /* ANSI or unicode */
    user_handle_t  handle;        /* handle to the window */
    unsigned int   style;         /* window style */
    unsigned int   ex_style;      /* window extended style */
    data_size_t    extra_size;    /* size to set in extra bytes */
    mod_handle_t   instance;      /* creator instance */
    lparam_t       user_data;     /* user-specific data */
    lparam_t       extra_value;   /* value to set in extra bytes or window id */
    int            extra_offset;  /* offset to set in extra bytes */
@REPLY
    unsigned int   old_style;     /* old window style */
    unsigned int   old_ex_style;  /* old window extended style */
    mod_handle_t   old_instance;  /* old creator instance */
    lparam_t       old_user_data; /* old user-specific data */
    lparam_t       old_extra_value; /* old value in extra bytes */
    lparam_t       old_id;        /* old window id */
@END
#define SET_WIN_STYLE     0x01
#define SET_WIN_EXSTYLE   0x02
#define SET_WIN_ID        0x04
#define SET_WIN_INSTANCE  0x08
#define SET_WIN_USERDATA  0x10
#define SET_WIN_EXTRA     0x20
#define SET_WIN_UNICODE   0x40


/* Set the parent of a window */
@REQ(set_parent)
    user_handle_t  handle;      /* handle to the window */
    user_handle_t  parent;      /* handle to the parent */
@REPLY
    user_handle_t  old_parent;  /* old parent window */
    user_handle_t  full_parent; /* full handle of new parent */
    unsigned int   dpi_context; /* new DPI context */
@END


/* Get a list of the window parents, up to the root of the tree */
@REQ(get_window_parents)
    user_handle_t  handle;        /* handle to the window */
@REPLY
    int            count;         /* total count of parents */
    VARARG(parents,user_handles); /* parent handles */
@END


/* Get a list of window siblings or children */
@REQ(get_window_list)
    obj_handle_t   desktop;       /* handle to desktop */
    user_handle_t  handle;        /* handle to window to start from */
    thread_id_t    tid;           /* thread owning the listed windows */
    int            children;      /* enumerate children? */
@REPLY
    int            count;         /* total count of windows */
    VARARG(windows,user_handles); /* window handles */
@END


/* Get a list of the window siblings of a specified class */
@REQ(get_class_windows)
    user_handle_t  parent;        /* parent window */
    user_handle_t  child;         /* first child window */
    atom_t         atom;          /* class atom for the listed siblings */
    VARARG(class,unicode_str);    /* class name */
@REPLY
    int            count;         /* total count of siblings */
    VARARG(children,user_handles); /* siblings handles */
@END


/* Get a list of the window children that contain a given point */
@REQ(get_window_children_from_point)
    user_handle_t  parent;        /* parent window */
    int            x;             /* point in parent coordinates */
    int            y;
    int            dpi;           /* dpi for the point coordinates */
@REPLY
    int            count;         /* total count of children */
    VARARG(children,user_handles); /* children handles */
@END


/* Get window tree information from a window handle */
@REQ(get_window_tree)
    user_handle_t  handle;        /* handle to the window */
@REPLY
    user_handle_t  parent;        /* parent window */
    user_handle_t  owner;         /* owner window */
    user_handle_t  next_sibling;  /* next sibling in Z-order */
    user_handle_t  prev_sibling;  /* prev sibling in Z-order */
    user_handle_t  first_sibling; /* first sibling in Z-order */
    user_handle_t  last_sibling;  /* last sibling in Z-order */
    user_handle_t  first_child;   /* first child */
    user_handle_t  last_child;    /* last child */
@END

/* Set the position and Z order of a window */
@REQ(set_window_pos)
    unsigned short swp_flags;     /* SWP_* flags */
    unsigned short paint_flags;   /* paint flags (see below) */
    unsigned int   monitor_dpi;   /* DPI of the window's monitor */
    user_handle_t  handle;        /* handle to the window */
    user_handle_t  previous;      /* previous window in Z order */
    struct rectangle window;      /* window rectangle (in parent coords) */
    struct rectangle client;      /* client rectangle (in parent coords) */
    VARARG(valid,rectangles);     /* valid rectangles from WM_NCCALCSIZE (in parent coords) */
@REPLY
    unsigned int   new_style;     /* new window style */
    unsigned int   new_ex_style;  /* new window extended style */
    user_handle_t  surface_win;   /* parent window that holds the surface */
@END
#define SET_WINPOS_PAINT_SURFACE    0x01  /* window has a paintable surface */
#define SET_WINPOS_PIXEL_FORMAT     0x02  /* window has a custom pixel format */
#define SET_WINPOS_LAYERED_WINDOW   0x04  /* window is drawn with UpdateLayeredWindow */

/* Get the window and client rectangles of a window */
@REQ(get_window_rectangles)
    user_handle_t  handle;        /* handle to the window */
    int            relative;      /* coords relative to (see below) */
    int            dpi;           /* DPI to map to, or zero for per-monitor DPI */
@REPLY
    struct rectangle window;      /* window rectangle */
    struct rectangle client;      /* client rectangle */
@END
enum coords_relative
{
    COORDS_CLIENT,   /* relative to client area */
    COORDS_WINDOW,   /* relative to whole window area */
    COORDS_PARENT,   /* relative to parent's client area */
    COORDS_SCREEN    /* relative to screen origin */
};


/* Get the window text */
@REQ(get_window_text)
    user_handle_t  handle;        /* handle to the window */
@REPLY
    data_size_t    length;        /* total length in WCHARs */
    VARARG(text,unicode_str);     /* window text */
@END


/* Set the window text */
@REQ(set_window_text)
    user_handle_t  handle;        /* handle to the window */
    VARARG(text,unicode_str);     /* window text */
@END


/* Get the coordinates offset between two windows */
@REQ(get_windows_offset)
    user_handle_t  from;          /* handle to the first window */
    user_handle_t  to;            /* handle to the second window */
    int            dpi;           /* DPI to map to, or zero for per-monitor DPI */
@REPLY
    int            x;             /* x coordinate offset */
    int            y;             /* y coordinate offset */
    int            mirror;        /* whether to mirror the x coordinate */
@END


/* Get the visible region of a window */
@REQ(get_visible_region)
    user_handle_t  window;        /* handle to the window */
    unsigned int   flags;         /* DCX flags */
@REPLY
    user_handle_t  top_win;       /* top window to clip against */
    struct rectangle top_rect;    /* top window visible rect with screen coords */
    struct rectangle win_rect;    /* window rect in screen coords */
    unsigned int   paint_flags;   /* paint flags (from SET_WINPOS_* flags) */
    data_size_t    total_size;    /* total size of the resulting region */
    VARARG(region,rectangles);    /* list of rectangles for the region (in screen coords) */
@END


/* Get the window region */
@REQ(get_window_region)
    user_handle_t  window;        /* handle to the window */
    int            surface;       /* get the visible surface region */
@REPLY
    struct rectangle visible_rect;/* window visible rect in screen coords */
    data_size_t    total_size;    /* total size of the resulting region */
    VARARG(region,rectangles);    /* list of rectangles for the region (in window coords) */
@END


/* Set the window region */
@REQ(set_window_region)
    user_handle_t  window;        /* handle to the window */
    int            redraw;        /* redraw the window? */
    VARARG(region,rectangles);    /* list of rectangles for the region (in window coords) */
@END


/* Get the window update region */
@REQ(get_update_region)
    user_handle_t  window;        /* handle to the window */
    user_handle_t  from_child;    /* child to start searching from */
    unsigned int   flags;         /* update flags (see below) */
@REPLY
    user_handle_t  child;         /* child to repaint (or window itself) */
    unsigned int   flags;         /* resulting update flags (see below) */
    data_size_t    total_size;    /* total size of the resulting region */
    VARARG(region,rectangles);    /* list of rectangles for the region (in screen coords) */
@END
#define UPDATE_NONCLIENT       0x001  /* get region for repainting non-client area */
#define UPDATE_ERASE           0x002  /* get region for erasing client area */
#define UPDATE_PAINT           0x004  /* get region for painting client area */
#define UPDATE_INTERNALPAINT   0x008  /* get region if internal paint is pending */
#define UPDATE_ALLCHILDREN     0x010  /* force repaint of all children */
#define UPDATE_NOCHILDREN      0x020  /* don't try to repaint any children */
#define UPDATE_NOREGION        0x040  /* don't return a region, only the flags */
#define UPDATE_DELAYED_ERASE   0x080  /* still needs erase after BeginPaint */
#define UPDATE_CLIPCHILDREN    0x100  /* remove clipped children from the update region */


/* Update the z order of a window so that a given rectangle is fully visible */
@REQ(update_window_zorder)
    user_handle_t  window;        /* handle to the window */
    struct rectangle rect;        /* rectangle that must be visible (in client coords) */
@END


/* Mark parts of a window as needing a redraw */
@REQ(redraw_window)
    user_handle_t  window;        /* handle to the window */
    unsigned int   flags;         /* RDW_* flags */
    VARARG(region,rectangles);    /* list of rectangles for the region (in window coords) */
@END


/* Set a window property */
@REQ(set_window_property)
    user_handle_t  window;        /* handle to the window */
    lparam_t       data;          /* data to store */
    atom_t         atom;          /* property atom (if no name specified) */
    VARARG(name,unicode_str);     /* property name */
@END


/* Remove a window property */
@REQ(remove_window_property)
    user_handle_t  window;        /* handle to the window */
    atom_t         atom;          /* property atom (if no name specified) */
    VARARG(name,unicode_str);     /* property name */
@REPLY
    lparam_t       data;          /* data stored in property */
@END


/* Get a window property */
@REQ(get_window_property)
    user_handle_t  window;        /* handle to the window */
    atom_t         atom;          /* property atom (if no name specified) */
    VARARG(name,unicode_str);     /* property name */
@REPLY
    lparam_t       data;          /* data stored in property */
@END


/* Get the list of properties of a window */
@REQ(get_window_properties)
    user_handle_t  window;        /* handle to the window */
@REPLY
    int            total;         /* total number of properties */
    VARARG(props,properties);     /* list of properties */
@END


/* Create a window station */
@REQ(create_winstation)
    unsigned int flags;           /* window station flags */
    unsigned int access;          /* wanted access rights */
    unsigned int attributes;      /* object attributes */
    obj_handle_t rootdir;         /* root directory */
    VARARG(name,unicode_str);     /* object name */
@REPLY
    obj_handle_t handle;          /* handle to the window station */
@END


/* Open a handle to a window station */
@REQ(open_winstation)
    unsigned int access;          /* wanted access rights */
    unsigned int attributes;      /* object attributes */
    obj_handle_t rootdir;         /* root directory */
    VARARG(name,unicode_str);     /* object name */
@REPLY
    obj_handle_t handle;          /* handle to the window station */
@END


/* Close a window station */
@REQ(close_winstation)
    obj_handle_t handle;          /* handle to the window station */
@END


/* Update the process current window station monitors */
@REQ(set_winstation_monitors)
    int              increment;   /* force increment the monitor update counter */
    VARARG(infos,monitor_infos);  /* window station monitors */
@REPLY
    unsigned __int64 serial;      /* winstation monitor update counter */
@END


/* Get the process current window station */
@REQ(get_process_winstation)
@REPLY
    obj_handle_t handle;          /* handle to the window station */
@END


/* Set the process current window station */
@REQ(set_process_winstation)
    obj_handle_t handle;          /* handle to the window station */
@END


/* Enumerate window stations and desktops */
@REQ(enum_winstation)
    obj_handle_t handle;          /* handle to the window station */
@REPLY
    data_size_t count;            /* number of names */
    data_size_t total;            /* total needed buffer size */
    VARARG(names,unicode_strings);/* window station names */
@END


/* Create a desktop */
@REQ(create_desktop)
    unsigned int flags;           /* desktop flags */
    unsigned int access;          /* wanted access rights */
    unsigned int attributes;      /* object attributes */
    VARARG(name,unicode_str);     /* object name */
@REPLY
    obj_handle_t handle;          /* handle to the desktop */
@END


/* Open a handle to a desktop */
@REQ(open_desktop)
    obj_handle_t winsta;          /* window station to open (null allowed) */
    unsigned int flags;           /* desktop flags */
    unsigned int access;          /* wanted access rights */
    unsigned int attributes;      /* object attributes */
    VARARG(name,unicode_str);     /* object name */
@REPLY
    obj_handle_t handle;          /* handle to the desktop */
@END


/* Open a handle to current input desktop */
@REQ(open_input_desktop)
    unsigned int flags;           /* desktop flags */
    unsigned int access;          /* wanted access rights */
    unsigned int attributes;      /* object attributes */
@REPLY
    obj_handle_t handle;          /* handle to the desktop */
@END


/* Changes the current input desktop */
@REQ(set_input_desktop)
    obj_handle_t handle;          /* handle to the desktop */
@END


/* Close a desktop */
@REQ(close_desktop)
    obj_handle_t handle;          /* handle to the desktop */
@END


/* Get the thread current desktop */
@REQ(get_thread_desktop)
    thread_id_t  tid;             /* thread id */
@REPLY
    struct obj_locator locator;   /* locator for the shared session object */
    obj_handle_t   handle;        /* handle to the desktop */
@END


/* Set the thread current desktop */
@REQ(set_thread_desktop)
    obj_handle_t handle;          /* handle to the desktop */
@REPLY
    struct obj_locator locator;   /* locator for the shared session object */
@END


/* Get/set information about a user object (window station or desktop) */
@REQ(set_user_object_info)
    obj_handle_t handle;          /* handle to the object */
    unsigned int flags;           /* information to set/get */
    unsigned int obj_flags;       /* new object flags */
@REPLY
    int          is_desktop;      /* is object a desktop? */
    unsigned int old_obj_flags;   /* old object flags */
    VARARG(name,unicode_str);     /* object name */
@END
#define SET_USER_OBJECT_SET_FLAGS       1
#define SET_USER_OBJECT_GET_FULL_NAME   2


/* Register a hotkey */
@REQ(register_hotkey)
    user_handle_t  window;        /* handle to the window */
    int            id;            /* hotkey identifier */
    unsigned int   flags;         /* modifier keys */
    unsigned int   vkey;          /* virtual key code */
@REPLY
    int            replaced;      /* did we replace an existing hotkey? */
    unsigned int   flags;         /* flags of replaced hotkey */
    unsigned int   vkey;          /* virtual key code of replaced hotkey */
@END


/* Unregister a hotkey */
@REQ(unregister_hotkey)
    user_handle_t  window;        /* handle to the window */
    int            id;            /* hotkey identifier */
@REPLY
    unsigned int   flags;         /* flags of removed hotkey */
    unsigned int   vkey;          /* virtual key code of removed hotkey */
@END


/* Attach (or detach) thread inputs */
@REQ(attach_thread_input)
    thread_id_t    tid_from;       /* thread to be attached */
    thread_id_t    tid_to;         /* thread to which tid_from should be attached */
    int            attach;         /* is it an attach? */
@END


/* Get the thread input of the given thread */
@REQ(get_thread_input)
    thread_id_t    tid;           /* id of thread */
@REPLY
    struct obj_locator locator;   /* locator for the shared session object */
@END


/* Get the time of the last input event */
@REQ(get_last_input_time)
@REPLY
    unsigned int time;
@END


/* Retrieve queue keyboard state for current thread or global async state */
@REQ(get_key_state)
    int            async;         /* whether to query the async state */
    int            key;           /* key code */
@REPLY
    unsigned char  state;         /* state of specified key */
@END

/* Set queue keyboard state for current thread */
@REQ(set_key_state)
    int            async;         /* whether to change the async state too */
    VARARG(keystate,bytes);       /* state array for all the keys */
@END

/* Set the system foreground window */
@REQ(set_foreground_window)
    user_handle_t  handle;        /* handle to the foreground window */
@REPLY
    user_handle_t  previous;      /* handle to the previous foreground window */
    int            send_msg_old;  /* whether we have to send a msg to the old window */
    int            send_msg_new;  /* whether we have to send a msg to the new window */
@END

/* Set the current thread focus window */
@REQ(set_focus_window)
    user_handle_t  handle;        /* handle to the focus window */
@REPLY
    user_handle_t  previous;      /* handle to the previous focus window */
@END

/* Set the current thread active window */
@REQ(set_active_window)
    user_handle_t  handle;        /* handle to the active window */
@REPLY
    user_handle_t  previous;      /* handle to the previous active window */
@END

/* Set the current thread capture window */
@REQ(set_capture_window)
    user_handle_t  handle;        /* handle to the capture window */
    unsigned int   flags;         /* capture flags (see below) */
@REPLY
    user_handle_t  previous;      /* handle to the previous capture window */
    user_handle_t  full_handle;   /* full 32-bit handle of new capture window */
@END
#define CAPTURE_MENU     0x01  /* capture is for a menu */
#define CAPTURE_MOVESIZE 0x02  /* capture is for moving/resizing */


/* Set the current thread caret window */
@REQ(set_caret_window)
    user_handle_t  handle;        /* handle to the caret window */
    int            width;         /* caret width */
    int            height;        /* caret height */
@REPLY
    user_handle_t  previous;      /* handle to the previous caret window */
    struct rectangle old_rect;    /* previous caret rectangle */
    int            old_hide;      /* previous hide count */
    int            old_state;     /* previous caret state (1=on, 0=off) */
@END


/* Set the current thread caret information */
@REQ(set_caret_info)
    unsigned int   flags;         /* caret flags (see below) */
    user_handle_t  handle;        /* handle to the caret window */
    int            x;             /* caret x position */
    int            y;             /* caret y position */
    int            hide;          /* increment for hide count (can be negative to show it) */
    int            state;         /* caret state (see below) */
@REPLY
    user_handle_t  full_handle;   /* handle to the current caret window */
    struct rectangle old_rect;    /* previous caret rectangle */
    int            old_hide;      /* previous hide count */
    int            old_state;     /* previous caret state (1=on, 0=off) */
@END
#define SET_CARET_POS        0x01  /* set the caret position from x,y */
#define SET_CARET_HIDE       0x02  /* increment the caret hide count */
#define SET_CARET_STATE      0x04  /* set the caret on/off state */
enum caret_state
{
    CARET_STATE_OFF,        /* off */
    CARET_STATE_ON,         /* on */
    CARET_STATE_TOGGLE,     /* toggle current state */
    CARET_STATE_ON_IF_MOVED /* on if the position differs, unchanged otherwise */
};


/* Set a window hook */
@REQ(set_hook)
    int            id;             /* id of the hook */
    process_id_t   pid;            /* id of process to set the hook into */
    thread_id_t    tid;            /* id of thread to set the hook into */
    int            event_min;
    int            event_max;
    client_ptr_t   proc;           /* hook procedure */
    int            flags;
    int            unicode;        /* is it a unicode hook? */
    VARARG(module,unicode_str);    /* module name */
@REPLY
    user_handle_t  handle;         /* handle to the hook */
@END


/* Remove a window hook */
@REQ(remove_hook)
    user_handle_t  handle;         /* handle to the hook */
    client_ptr_t   proc;           /* hook procedure if handle is 0 */
    int            id;             /* id of the hook if handle is 0 */
@REPLY
@END


/* Start calling a hook chain */
@REQ(start_hook_chain)
    int            id;             /* id of the hook */
    int            event;          /* signalled event */
    user_handle_t  window;         /* handle to the event window */
    int            object_id;      /* object id for out of context winevent */
    int            child_id;       /* child id for out of context winevent */
@REPLY
    user_handle_t  handle;         /* handle to the next hook */
    process_id_t   pid;            /* process id for low-level keyboard/mouse hooks */
    thread_id_t    tid;            /* thread id for low-level keyboard/mouse hooks */
    int            unicode;        /* is it a unicode hook? */
    client_ptr_t   proc;           /* hook procedure */
    VARARG(module,unicode_str);    /* module name */
@END


/* Finished calling a hook chain */
@REQ(finish_hook_chain)
    int            id;             /* id of the hook */
@END


/* Get the hook information */
@REQ(get_hook_info)
    user_handle_t  handle;         /* handle to the current hook */
    int            get_next;       /* do we want info about current or next hook? */
    int            event;          /* signalled event */
    user_handle_t  window;         /* handle to the event window */
    int            object_id;      /* object id for out of context winevent */
    int            child_id;       /* child id for out of context winevent */
@REPLY
    user_handle_t  handle;         /* handle to the hook */
    int            id;             /* id of the hook */
    process_id_t   pid;            /* process id for low-level keyboard/mouse hooks */
    thread_id_t    tid;            /* thread id for low-level keyboard/mouse hooks */
    client_ptr_t   proc;           /* hook procedure */
    int            unicode;        /* is it a unicode hook? */
    VARARG(module,unicode_str);    /* module name */
@END


/* Create a window class */
@REQ(create_class)
    int            local;          /* is it a local class? */
    atom_t         atom;           /* class atom */
    unsigned int   style;          /* class style */
    mod_handle_t   instance;       /* module instance */
    int            extra;          /* number of extra class bytes */
    int            win_extra;      /* number of window extra bytes */
    client_ptr_t   client_ptr;     /* pointer to class in client address space */
    data_size_t    name_offset;    /* base class name offset for specified atom */
    VARARG(name,unicode_str);      /* class name */
@REPLY
    atom_t         atom;           /* resulting class atom */
@END


/* Destroy a window class */
@REQ(destroy_class)
    atom_t         atom;           /* class atom */
    mod_handle_t   instance;       /* module instance */
    VARARG(name,unicode_str);      /* class name */
@REPLY
    client_ptr_t   client_ptr;     /* pointer to class in client address space */
@END


/* Set some information in a class */
@REQ(set_class_info)
    user_handle_t  window;         /* handle to the window */
    unsigned int   flags;          /* flags for info to set (see below) */
    atom_t         atom;           /* class atom */
    unsigned int   style;          /* class style */
    int            win_extra;      /* number of window extra bytes */
    mod_handle_t   instance;       /* module instance */
    int            extra_offset;   /* offset to set in extra bytes */
    data_size_t    extra_size;     /* size to set in extra bytes */
    lparam_t       extra_value;    /* value to set in extra bytes */
@REPLY
    atom_t         old_atom;       /* previous class atom */
    atom_t         base_atom;      /* base class atom */
    mod_handle_t   old_instance;   /* previous module instance */
    lparam_t       old_extra_value; /* old value in extra bytes */
    unsigned int   old_style;      /* previous class style */
    int            old_extra;      /* previous number of class extra bytes */
    int            old_win_extra;  /* previous number of window extra bytes */
@END
#define SET_CLASS_ATOM      0x0001
#define SET_CLASS_STYLE     0x0002
#define SET_CLASS_WINEXTRA  0x0004
#define SET_CLASS_INSTANCE  0x0008
#define SET_CLASS_EXTRA     0x0010


/* Open the clipboard */
@REQ(open_clipboard)
    user_handle_t  window;         /* clipboard window */
@REPLY
    user_handle_t  owner;          /* current clipboard owner */
@END


/* Close the clipboard */
@REQ(close_clipboard)
@REPLY
    user_handle_t  viewer;         /* first clipboard viewer */
    user_handle_t  owner;          /* current clipboard owner */
@END


/* Empty the clipboard and grab ownership */
@REQ(empty_clipboard)
@END


/* Add a data format to the clipboard */
@REQ(set_clipboard_data)
    unsigned int   format;         /* clipboard format of the data */
    unsigned int   lcid;           /* locale id to use for synthesizing text formats */
    VARARG(data,bytes);            /* data contents */
@REPLY
    unsigned int   seqno;          /* sequence number for the set data */
@END


/* Fetch a data format from the clipboard */
@REQ(get_clipboard_data)
    unsigned int   format;         /* clipboard format of the data */
    int            render;         /* will we try to render it if missing? */
    int            cached;         /* do we already have it in the client-side cache? */
    unsigned int   seqno;          /* sequence number for the data in the cache */
@REPLY
    unsigned int   from;           /* for synthesized data, format to generate it from */
    user_handle_t  owner;          /* clipboard owner for delayed-rendered formats */
    unsigned int   seqno;          /* sequence number for the originally set data */
    data_size_t    total;          /* total data size */
    VARARG(data,bytes);            /* data contents */
@END


/* Retrieve a list of available formats */
@REQ(get_clipboard_formats)
    unsigned int   format;         /* specific format to query, return all if 0 */
@REPLY
    unsigned int   count;          /* count of available formats */
    VARARG(formats,uints);         /* array of available formats */
@END


/* Retrieve the next available format */
@REQ(enum_clipboard_formats)
    unsigned int   previous;       /* previous format, or first if 0 */
@REPLY
    unsigned int   format;         /* next format */
@END


/* Release ownership of the clipboard */
@REQ(release_clipboard)
    user_handle_t  owner;          /* clipboard owner to release */
@REPLY
    user_handle_t  viewer;         /* first clipboard viewer */
    user_handle_t  owner;          /* current clipboard owner */
@END


/* Get clipboard information */
@REQ(get_clipboard_info)
@REPLY
    user_handle_t  window;         /* clipboard window */
    user_handle_t  owner;          /* clipboard owner */
    user_handle_t  viewer;         /* clipboard viewer */
    unsigned int   seqno;          /* current sequence number */
@END


/* Set the clipboard viewer window */
@REQ(set_clipboard_viewer)
    user_handle_t  viewer;         /* clipboard viewer */
    user_handle_t  previous;       /* if non-zero, check that this was the previous viewer */
@REPLY
    user_handle_t  old_viewer;     /* previous clipboard viewer */
    user_handle_t  owner;          /* clipboard owner */
@END


/* Add a clipboard listener window */
@REQ(add_clipboard_listener)
    user_handle_t  window;         /* clipboard listener window */
@END


/* Remove a clipboard listener window */
@REQ(remove_clipboard_listener)
    user_handle_t  window;         /* clipboard listener window */
@END


/* Create a security token */
@REQ(create_token)
    struct luid    token_id;
    unsigned int   access;         /* access rights to the new token */
    int            primary;        /* is the new token to be a primary one? */
    int            impersonation_level; /* impersonation level of the new token */
    abstime_t      expire;         /* expiration time */
    int            group_count;
    int            primary_group;
    int            priv_count;
    /* VARARG(objattr,object_attributes);  */
    /* VARARG(user,sid); */
    /* VARARG(groups,sid); */
    /* VARARG(privs,luid_attr); */
    /* VARARG(dacl,acl); */
@REPLY
    obj_handle_t   token;    /* handle to the token */
@END


/* Open a security token */
@REQ(open_token)
    obj_handle_t   handle;    /* handle to the thread or process */
    unsigned int   access;    /* access rights to the new token */
    unsigned int   attributes;/* object attributes */
    unsigned int   flags;     /* flags (see below) */
@REPLY
    obj_handle_t   token;    /* handle to the token */
@END
#define OPEN_TOKEN_THREAD   1
#define OPEN_TOKEN_AS_SELF  2


/* Set/get the desktop shell windows */
@REQ(set_desktop_shell_windows)
    unsigned int   flags;               /* flags for fields to set (see below) */
    user_handle_t  shell_window;        /* handle to the new shell window */
    user_handle_t  shell_listview;      /* handle to the new shell listview window */
    user_handle_t  progman_window;      /* handle to the new program manager window */
    user_handle_t  taskman_window;      /* handle to the new task manager window */
@REPLY
    user_handle_t  old_shell_window;    /* handle to the shell window */
    user_handle_t  old_shell_listview;  /* handle to the shell listview window */
    user_handle_t  old_progman_window;  /* handle to the new program manager window */
    user_handle_t  old_taskman_window;  /* handle to the new task manager window */
@END
#define SET_DESKTOP_SHELL_WINDOWS   0x01  /* set both main shell and listview windows */
#define SET_DESKTOP_PROGMAN_WINDOW  0x02
#define SET_DESKTOP_TASKMAN_WINDOW  0x04

/* Adjust the privileges held by a token */
@REQ(adjust_token_privileges)
    obj_handle_t  handle; /* handle to the token */
    int           disable_all; /* disable all privileges? */
    int           get_modified_state; /* get modified privileges? */
    VARARG(privileges,luid_attr); /* privileges to enable/disable/remove */
@REPLY
    unsigned int  len; /* total length in bytes required to store token privileges */
    VARARG(privileges,luid_attr); /* modified privileges */
@END

/* Retrieves the set of privileges held by or available to a token */
@REQ(get_token_privileges)
    obj_handle_t  handle; /* handle to the token */
@REPLY
    unsigned int  len; /* total length in bytes required to store token privileges */
    VARARG(privileges,luid_attr); /* privileges held by or available to a token */
@END

/* Check the token has the required privileges */
@REQ(check_token_privileges)
    obj_handle_t  handle; /* handle to the token */
    int           all_required; /* are all the privileges required for the check to succeed? */
    VARARG(privileges,luid_attr); /* privileges to check */
@REPLY
    int           has_privileges; /* does the token have the required privileges? */
    VARARG(privileges,luid_attr); /* privileges held by or available to a token */
@END

@REQ(duplicate_token)
    obj_handle_t  handle;        /* handle to the token to duplicate */
    unsigned int  access;        /* access rights to the new token */
    int           primary;       /* is the new token to be a primary one? */
    int           impersonation_level; /* impersonation level of the new token */
    VARARG(objattr,object_attributes); /* object attributes */
@REPLY
    obj_handle_t  new_handle; /* duplicated handle */
@END

@REQ(filter_token)
    obj_handle_t  handle;          /* handle to the token to duplicate */
    unsigned int  flags;           /* flags */
    data_size_t   privileges_size; /* size of privileges */
    VARARG(privileges,luid_attr,privileges_size); /* privileges to remove from new token */
    VARARG(disable_sids,sid);      /* array of groups to remove from new token */
@REPLY
    obj_handle_t  new_handle;      /* filtered handle */
@END

@REQ(access_check)
    obj_handle_t    handle; /* handle to the token */
    unsigned int    desired_access; /* desired access to the object */
    struct generic_map mapping;     /* mapping to specific rights */
    VARARG(sd,security_descriptor); /* security descriptor to check */
@REPLY
    unsigned int    access_granted; /* access rights actually granted */
    unsigned int    access_status; /* was access granted? */
    unsigned int    privileges_len; /* length needed to store privileges */
    VARARG(privileges,luid_attr); /* privileges used during access check */
@END

@REQ(get_token_sid)
    obj_handle_t    handle;       /* handle to the token */
    unsigned int    which_sid;    /* which SID to retrieve from the token */
@REPLY
    data_size_t     sid_len;      /* length needed to store sid */
    VARARG(sid,sid);              /* the sid specified by which_sid from the token */
@END

@REQ(get_token_groups)
    obj_handle_t    handle;       /* handle to the token */
    unsigned int    attr_mask;    /* mask for wanted attributes */
@REPLY
    data_size_t     attr_len;     /* length needed to store attrs */
    data_size_t     sid_len;      /* length needed to store sids */
    VARARG(attrs,uints,attr_len); /* group attributes */
    VARARG(sids,sids);            /* group sids */
@END

@REQ(get_token_default_dacl)
    obj_handle_t    handle;     /* handle to the token */
@REPLY
    data_size_t     acl_len;    /* length needed to store access control list */
    VARARG(acl,acl);            /* access control list */
@END

@REQ(set_token_default_dacl)
    obj_handle_t    handle;     /* handle to the token */
    VARARG(acl,acl);            /* default dacl to set */
@END

@REQ(set_security_object)
    obj_handle_t    handle;       /* handle to the object */
    unsigned int    security_info; /* which parts of security descriptor to set */
    VARARG(sd,security_descriptor); /* security descriptor to set */
@END

@REQ(get_security_object)
    obj_handle_t    handle;       /* handle to the object */
    unsigned int    security_info; /* which parts of security descriptor to get */
@REPLY
    unsigned int    sd_len;         /* buffer size needed for sd */
    VARARG(sd,security_descriptor); /* retrieved security descriptor */
@END


struct handle_info
{
    process_id_t owner;
    obj_handle_t handle;
    unsigned int access;
    unsigned int attributes;
    unsigned int type;
};

/* Return a list of all opened handles */
@REQ(get_system_handles)
@REPLY
    unsigned int    count;        /* number of handles */
    VARARG(data,handle_infos);    /* array of handle_infos */
@END


/* Retrieve a list of all processes' TCP connections. */
@REQ(get_tcp_connections)
    unsigned int    state_filter; /* MIB_TCP_STATE_* or 0 for no filter */
@REPLY
    unsigned int    count;
    VARARG(connections,tcp_connections);
@END


/* Retrieve a list of all processes' UDP endpoints. */
@REQ(get_udp_endpoints)
@REPLY
    unsigned int    count;
    VARARG(endpoints,udp_endpoints);
@END


/* Create a mailslot */
@REQ(create_mailslot)
    unsigned int   access;        /* wanted access rights */
    unsigned int   options;
    timeout_t      read_timeout;
    unsigned int   max_msgsize;
    VARARG(objattr,object_attributes); /* object attributes */
@REPLY
    obj_handle_t   handle;        /* handle to the mailslot */
@END


/* Set mailslot information */
@REQ(set_mailslot_info)
    obj_handle_t   handle;        /* handle to the mailslot */
    timeout_t      read_timeout;
    unsigned int   flags;
@REPLY
    timeout_t      read_timeout;
    unsigned int   max_msgsize;
@END
#define MAILSLOT_SET_READ_TIMEOUT  1


/* Create a directory object */
@REQ(create_directory)
    unsigned int   access;        /* access flags */
    VARARG(objattr,object_attributes); /* object attributes */
@REPLY
    obj_handle_t   handle;        /* handle to the directory */
@END


/* Open a directory object */
@REQ(open_directory)
    unsigned int   access;        /* access flags */
    unsigned int   attributes;    /* object attributes */
    obj_handle_t   rootdir;       /* root directory */
    VARARG(directory_name,unicode_str); /* Directory name */
@REPLY
    obj_handle_t   handle;        /* handle to the directory */
@END


/* Get directory entries */
@REQ(get_directory_entries)
    obj_handle_t   handle;             /* handle to the directory */
    unsigned int   index;              /* index of first entry */
    unsigned int   max_count;          /* maximum number of entries to return */
@REPLY
    data_size_t    total_len;          /* total length needed for strings */
    unsigned int   count;              /* number of entries returned */
    VARARG(entries,directory_entries);
@END


/* Create a symbolic link object */
@REQ(create_symlink)
    unsigned int   access;        /* access flags */
    VARARG(objattr,object_attributes); /* object attributes */
    VARARG(target_name,unicode_str);   /* target name */
@REPLY
    obj_handle_t   handle;        /* handle to the symlink */
@END


/* Open a symbolic link object */
@REQ(open_symlink)
    unsigned int   access;        /* access flags */
    unsigned int   attributes;    /* object attributes */
    obj_handle_t   rootdir;       /* root directory */
    VARARG(name,unicode_str);     /* symlink name */
@REPLY
    obj_handle_t   handle;        /* handle to the symlink */
@END


/* Query a symbolic link object */
@REQ(query_symlink)
    obj_handle_t   handle;        /* handle to the symlink */
@REPLY
    data_size_t    total;         /* total needed size for name */
    VARARG(target_name,unicode_str); /* target name */
@END


/* Query basic object information */
@REQ(get_object_info)
    obj_handle_t   handle;        /* handle to the object */
@REPLY
    unsigned int   access;        /* granted access mask */
    unsigned int   ref_count;     /* object ref count */
    unsigned int   handle_count;  /* object handle count */
@END


/* Query the full name of an object */
@REQ(get_object_name)
    obj_handle_t   handle;        /* handle to the object */
@REPLY
    data_size_t    total;         /* total needed size for name */
    VARARG(name,unicode_str);     /* object name */
@END


/* Query object type name information */
@REQ(get_object_type)
    obj_handle_t   handle;        /* handle to the object */
@REPLY
    VARARG(info,object_type_info); /* type information */
@END


/* Query type information for all types */
@REQ(get_object_types)
@REPLY
    int            count;          /* total count of object types */
    VARARG(info,object_types_info); /* type information */
@END


/* Allocate a locally-unique identifier */
@REQ(allocate_locally_unique_id)
@REPLY
    struct luid    luid;
@END


/* Create a device manager */
@REQ(create_device_manager)
    unsigned int access;          /* wanted access rights */
    unsigned int attributes;      /* object attributes */
@REPLY
    obj_handle_t handle;          /* handle to the device */
@END


/* Create a device */
@REQ(create_device)
    obj_handle_t rootdir;         /* root directory */
    client_ptr_t user_ptr;        /* opaque ptr for use by client */
    obj_handle_t manager;         /* device manager */
    VARARG(name,unicode_str);     /* object name */
@END


/* Delete a device */
@REQ(delete_device)
    obj_handle_t manager;         /* handle to the device manager */
    client_ptr_t device;          /* pointer to the device */
@END


/* Retrieve the next pending device irp request */
@REQ(get_next_device_request)
    obj_handle_t manager;         /* handle to the device manager */
    obj_handle_t prev;            /* handle to the previous irp */
    unsigned int status;          /* status of the previous irp */
    client_ptr_t user_ptr;        /* user pointer of the previous irp */
    int          pending;         /* was the previous irp marked pending? */
    unsigned int iosb_status;     /* IOSB status of the previous irp */
    data_size_t  result;          /* IOSB result of the previous irp */
    VARARG(data,bytes);           /* output data of the previous irp */
@REPLY
    union irp_params params;      /* irp parameters */
    obj_handle_t next;            /* handle to the next irp */
    thread_id_t  client_tid;      /* tid of thread calling irp */
    client_ptr_t client_thread;   /* pointer to thread object of calling irp */
    data_size_t  in_size;         /* total needed input size */
    VARARG(next_data,bytes);      /* input data of the next irp */
@END


/* Get kernel pointer from server object */
@REQ(get_kernel_object_ptr)
    obj_handle_t manager;         /* handle to the device manager */
    obj_handle_t handle;          /* object handle */
@REPLY
    client_ptr_t user_ptr;        /* kernel object pointer */
@END


/* Associate kernel pointer with server object */
@REQ(set_kernel_object_ptr)
    obj_handle_t manager;         /* handle to the device manager */
    obj_handle_t handle;          /* object handle */
    client_ptr_t user_ptr;        /* kernel object pointer */
@END


/* Grab server object reference from kernel object pointer */
@REQ(grab_kernel_object)
    obj_handle_t manager;         /* handle to the device manager */
    client_ptr_t user_ptr;        /* kernel object pointer */
@END


/* Release server object reference from kernel object pointer */
@REQ(release_kernel_object)
    obj_handle_t manager;         /* handle to the device manager */
    client_ptr_t user_ptr;        /* kernel object pointer */
@END


/* Get handle from kernel object pointer */
@REQ(get_kernel_object_handle)
    obj_handle_t manager;         /* handle to the device manager */
    client_ptr_t user_ptr;        /* kernel object pointer */
    unsigned int access;          /* wanted access rights */
@REPLY
    obj_handle_t handle;          /* kernel object handle */
@END


/* Make the current process a system process */
@REQ(make_process_system)
    obj_handle_t handle;          /* handle to the process */
@REPLY
    obj_handle_t event;           /* event signaled when all user processes have exited */
@END


/* Grant the given process an admin token with Default elevation */
@REQ(grant_process_admin_token)
    obj_handle_t handle;          /* handle to the process */
@END


/* Get detailed fixed-size information about a token */
@REQ(get_token_info)
    obj_handle_t   handle;        /* handle to the object */
@REPLY
    struct luid    token_id;      /* locally-unique identifier of the token */
    struct luid    modified_id;   /* locally-unique identifier of the modified version of the token */
    unsigned int   session_id;    /* token session id */
    int            primary;       /* is the token primary or impersonation? */
    int            impersonation_level; /* level of impersonation */
    int            elevation;     /* elevation type */
    int            group_count;   /* the number of groups the token is a member of */
    int            privilege_count; /* the number of privileges the token has */
@END


/* Create a token which is an elevation counterpart to this token */
@REQ(create_linked_token)
    obj_handle_t   handle;        /* handle to the token */
@REPLY
    obj_handle_t   linked;        /* handle to the linked token */
@END


/* Create I/O completion port */
@REQ(create_completion)
    unsigned int access;          /* desired access to a port */
    unsigned int concurrent;      /* max number of concurrent active threads */
    VARARG(objattr,object_attributes); /* object attributes */
@REPLY
    obj_handle_t handle;          /* port handle */
@END


/* Open I/O completion port */
@REQ(open_completion)
    unsigned int access;          /* desired access to a port */
    unsigned int attributes;      /* object attributes */
    obj_handle_t rootdir;         /* root directory */
    VARARG(filename,unicode_str); /* port name */
@REPLY
    obj_handle_t handle;          /* port handle */
@END


/* add completion to completion port */
@REQ(add_completion)
    obj_handle_t  handle;         /* port handle */
    apc_param_t   ckey;           /* completion key */
    apc_param_t   cvalue;         /* completion value */
    apc_param_t   information;    /* IO_STATUS_BLOCK Information */
    obj_handle_t  reserve_handle; /* completion reserve object handle */
    unsigned int  status;         /* completion result */
@END


/* get completion from completion port queue */
@REQ(remove_completion)
    obj_handle_t handle;          /* port handle */
    int          alertable;       /* completion wait is alertable */
@REPLY
    apc_param_t   ckey;           /* completion key */
    apc_param_t   cvalue;         /* completion value */
    apc_param_t   information;    /* IO_STATUS_BLOCK Information */
    unsigned int  status;         /* completion result */
    obj_handle_t  wait_handle;    /* handle to completion wait internal object */
@END


/* get completion after successful wait */
@REQ(get_thread_completion)
@REPLY
    apc_param_t   ckey;           /* completion key */
    apc_param_t   cvalue;         /* completion value */
    apc_param_t   information;    /* IO_STATUS_BLOCK Information */
    unsigned int  status;         /* completion result */
@END


/* get completion queue depth */
@REQ(query_completion)
    obj_handle_t  handle;         /* port handle */
@REPLY
    unsigned int  depth;          /* completion queue depth */
@END


/* associate object with completion port */
@REQ(set_completion_info)
    obj_handle_t  handle;         /* object handle */
    apc_param_t   ckey;           /* completion key */
    obj_handle_t  chandle;        /* port handle */
@END


/* check for associated completion and push msg */
@REQ(add_fd_completion)
    obj_handle_t   handle;        /* async' object */
    apc_param_t    cvalue;        /* completion value */
    apc_param_t    information;   /* IO_STATUS_BLOCK Information */
    unsigned int   status;        /* completion status */
    int            async;         /* completion is an async result */
@END


/* set fd completion information */
@REQ(set_fd_completion_mode)
    obj_handle_t handle;          /* handle to a file or directory */
    unsigned int flags;           /* completion notification flags */
@END


/* set fd disposition information */
@REQ(set_fd_disp_info)
    obj_handle_t handle;          /* handle to a file or directory */
    unsigned int flags;           /* what actions should be taken when deleting a file */
@END


/* set fd name information */
@REQ(set_fd_name_info)
    obj_handle_t handle;          /* handle to a file or directory */
    obj_handle_t rootdir;         /* root directory */
    data_size_t  namelen;         /* length of NT name in bytes */
    int          link;            /* link instead of renaming */
    unsigned int flags;           /* FILE_RENAME_* flags */
    VARARG(name,unicode_str,namelen); /* NT name */
    VARARG(filename,string);      /* new file name */
@END


/* set fd eof information */
@REQ(set_fd_eof_info)
    obj_handle_t handle;        /* handle to a file or directory */
    file_pos_t   eof;           /* offset of eof of file */
@END


/* Retrieve layered info for a window */
@REQ(get_window_layered_info)
    user_handle_t  handle;        /* handle to the window */
@REPLY
    unsigned int   color_key;     /* color key */
    unsigned int   alpha;         /* alpha (0..255) */
    unsigned int   flags;         /* LWA_* flags */
@END


/* Set layered info for a window */
@REQ(set_window_layered_info)
    user_handle_t  handle;        /* handle to the window */
    unsigned int   color_key;     /* color key */
    unsigned int   alpha;         /* alpha (0..255) */
    unsigned int   flags;         /* LWA_* flags */
@END


/* Allocate an arbitrary user handle */
@REQ(alloc_user_handle)
@REPLY
    user_handle_t  handle;        /* allocated handle */
@END


/* Free an arbitrary user handle */
@REQ(free_user_handle)
    user_handle_t  handle;        /* handle to free*/
@END


/* Set/get the current cursor */
@REQ(set_cursor)
    unsigned int   flags;         /* flags for fields to set (see below) */
    user_handle_t  handle;        /* handle to the cursor */
    int            show_count;    /* show count increment/decrement */
    int            x;             /* cursor position */
    int            y;
    struct rectangle clip;        /* cursor clip rectangle */
@REPLY
    user_handle_t  prev_handle;   /* previous handle */
    int            prev_count;    /* previous show count */
    int            prev_x;        /* previous position */
    int            prev_y;
    int            new_x;         /* new position */
    int            new_y;
    struct rectangle new_clip;    /* new clip rectangle */
    unsigned int   last_change;   /* time of last position change */
@END
#define SET_CURSOR_HANDLE 0x01
#define SET_CURSOR_COUNT  0x02
#define SET_CURSOR_POS    0x04
#define SET_CURSOR_CLIP   0x08
#define SET_CURSOR_NOCLIP 0x10
#define SET_CURSOR_FSCLIP 0x20

/* Get the history of the 64 last cursor positions */
@REQ(get_cursor_history)
@REPLY
    VARARG(history,cursor_positions);
@END


/* Batch read rawinput message data */
@REQ(get_rawinput_buffer)
    data_size_t header_size;   /* size of RAWINPUTHEADER structure */
    int         read_data;     /* read the rawinput buffer data */
@REPLY
    data_size_t next_size; /* minimum size to get next message data */
    unsigned int time;     /* time of the last removed message */
    unsigned int count;
    VARARG(data,bytes);
@END

/* Modify the list of registered rawinput devices */
@REQ(update_rawinput_devices)
    VARARG(devices,rawinput_devices);
@END

/* Create a new job object */
@REQ(create_job)
    unsigned int access;          /* wanted access rights */
    VARARG(objattr,object_attributes); /* object attributes */
@REPLY
    obj_handle_t handle;          /* handle to the job */
@END


/* Open a job object */
@REQ(open_job)
    unsigned int access;          /* wanted access rights */
    unsigned int attributes;      /* object attributes */
    obj_handle_t rootdir;         /* root directory */
    VARARG(name,unicode_str);     /* object name */
@REPLY
    obj_handle_t handle;          /* handle to the job */
@END


/* Assign a job object to a process */
@REQ(assign_job)
    obj_handle_t job;             /* handle to the job */
    obj_handle_t process;         /* handle to the process */
@END


/* Check if a process is associated with a job */
@REQ(process_in_job)
    obj_handle_t job;             /* handle to the job */
    obj_handle_t process;         /* handle to the process */
@END


/* Set limit flags on a job */
@REQ(set_job_limits)
    obj_handle_t handle;          /* handle to the job */
    unsigned int limit_flags;     /* new limit flags */
@END


/* Set new completion port for a job */
@REQ(set_job_completion_port)
    obj_handle_t job;             /* handle to the job */
    obj_handle_t port;            /* handle to the completion port */
    client_ptr_t key;             /* key to send with completion messages */
@END


/* Retrieve information about a job */
@REQ(get_job_info)
    obj_handle_t handle;          /* handle to the job */
@REPLY
    int total_processes;          /* total count of processes */
    int active_processes;         /* count of running processes */
    VARARG(pids,uints);           /* list of active pids */
@END


/* Terminate all processes associated with the job  */
@REQ(terminate_job)
    obj_handle_t handle;          /* handle to the job */
    int          status;          /* process exit code */
@END


/* Suspend a process */
@REQ(suspend_process)
    obj_handle_t handle;       /* process handle */
@END


/* Resume a process */
@REQ(resume_process)
    obj_handle_t handle;       /* process handle */
@END


/* Iterate thread list for process */
@REQ(get_next_thread)
    obj_handle_t process;      /* process handle */
    obj_handle_t last;         /* thread handle to start with */
    unsigned int access;       /* desired access for returned handle */
    unsigned int attributes;   /* returned handle attributes */
    unsigned int flags;        /* controls iteration direction */
@REPLY
    obj_handle_t handle;       /* next thread handle */
@END


/* Setup keyboard auto-repeat */
@REQ(set_keyboard_repeat)
    int enable;                /* whether to enable auto-repeat */
    int delay;                 /* auto-repeat delay in ms */
    int period;                /* auto-repeat period in ms */
@REPLY
    int enable;                /* previous state of auto-repeat enable */
@END