1 use winapi::shared::ntdef::{PVOID, UCHAR, ULONG, USHORT};
2 pub const GDI_MAX_HANDLE_COUNT: usize = 0x4000;
3 pub const GDI_HANDLE_INDEX_SHIFT: ULONG = 0;
4 pub const GDI_HANDLE_INDEX_BITS: ULONG = 16;
5 pub const GDI_HANDLE_INDEX_MASK: ULONG = 0xffff;
6 pub const GDI_HANDLE_TYPE_SHIFT: ULONG = 16;
7 pub const GDI_HANDLE_TYPE_BITS: ULONG = 5;
8 pub const GDI_HANDLE_TYPE_MASK: ULONG = 0x1f;
9 pub const GDI_HANDLE_ALTTYPE_SHIFT: ULONG = 21;
10 pub const GDI_HANDLE_ALTTYPE_BITS: ULONG = 2;
11 pub const GDI_HANDLE_ALTTYPE_MASK: ULONG = 0x3;
12 pub const GDI_HANDLE_STOCK_SHIFT: ULONG = 23;
13 pub const GDI_HANDLE_STOCK_BITS: ULONG = 1;
14 pub const GDI_HANDLE_STOCK_MASK: ULONG = 0x1;
15 pub const GDI_HANDLE_UNIQUE_SHIFT: ULONG = 24;
16 pub const GDI_HANDLE_UNIQUE_BITS: ULONG = 8;
17 pub const GDI_HANDLE_UNIQUE_MASK: ULONG = 0xff;
18 #[inline]
GDI_HANDLE_INDEX(Handle: ULONG) -> ULONG19 pub const fn GDI_HANDLE_INDEX(Handle: ULONG) -> ULONG {
20 Handle & GDI_HANDLE_INDEX_MASK
21 }
22 #[inline]
GDI_HANDLE_TYPE(Handle: ULONG) -> ULONG23 pub const fn GDI_HANDLE_TYPE(Handle: ULONG) -> ULONG {
24 Handle >> GDI_HANDLE_TYPE_SHIFT & GDI_HANDLE_TYPE_MASK
25 }
26 #[inline]
GDI_HANDLE_ALTTYPE(Handle: ULONG) -> ULONG27 pub const fn GDI_HANDLE_ALTTYPE(Handle: ULONG) -> ULONG {
28 Handle >> GDI_HANDLE_ALTTYPE_SHIFT & GDI_HANDLE_ALTTYPE_MASK
29 }
30 #[inline]
GDI_HANDLE_STOCK(Handle: ULONG) -> ULONG31 pub const fn GDI_HANDLE_STOCK(Handle: ULONG) -> ULONG {
32 Handle >> GDI_HANDLE_STOCK_SHIFT & GDI_HANDLE_STOCK_MASK
33 }
34 #[inline]
GDI_MAKE_HANDLE(Index: ULONG, Unique: ULONG) -> ULONG35 pub const fn GDI_MAKE_HANDLE(Index: ULONG, Unique: ULONG) -> ULONG {
36 Unique << GDI_HANDLE_INDEX_BITS | Index
37 }
38 pub const GDI_DEF_TYPE: ULONG = 0;
39 pub const GDI_DC_TYPE: ULONG = 1;
40 pub const GDI_DD_DIRECTDRAW_TYPE: ULONG = 2;
41 pub const GDI_DD_SURFACE_TYPE: ULONG = 3;
42 pub const GDI_RGN_TYPE: ULONG = 4;
43 pub const GDI_SURF_TYPE: ULONG = 5;
44 pub const GDI_CLIENTOBJ_TYPE: ULONG = 6;
45 pub const GDI_PATH_TYPE: ULONG = 7;
46 pub const GDI_PAL_TYPE: ULONG = 8;
47 pub const GDI_ICMLCS_TYPE: ULONG = 9;
48 pub const GDI_LFONT_TYPE: ULONG = 10;
49 pub const GDI_RFONT_TYPE: ULONG = 11;
50 pub const GDI_PFE_TYPE: ULONG = 12;
51 pub const GDI_PFT_TYPE: ULONG = 13;
52 pub const GDI_ICMCXF_TYPE: ULONG = 14;
53 pub const GDI_ICMDLL_TYPE: ULONG = 15;
54 pub const GDI_BRUSH_TYPE: ULONG = 16;
55 pub const GDI_PFF_TYPE: ULONG = 17;
56 pub const GDI_CACHE_TYPE: ULONG = 18;
57 pub const GDI_SPACE_TYPE: ULONG = 19;
58 pub const GDI_DBRUSH_TYPE: ULONG = 20;
59 pub const GDI_META_TYPE: ULONG = 21;
60 pub const GDI_EFSTATE_TYPE: ULONG = 22;
61 pub const GDI_BMFD_TYPE: ULONG = 23;
62 pub const GDI_VTFD_TYPE: ULONG = 24;
63 pub const GDI_TTFD_TYPE: ULONG = 25;
64 pub const GDI_RC_TYPE: ULONG = 26;
65 pub const GDI_TEMP_TYPE: ULONG = 27;
66 pub const GDI_DRVOBJ_TYPE: ULONG = 28;
67 pub const GDI_DCIOBJ_TYPE: ULONG = 29;
68 pub const GDI_SPOOL_TYPE: ULONG = 30;
69 #[inline]
GDI_CLIENT_TYPE_FROM_HANDLE(Handle: ULONG) -> ULONG70 pub const fn GDI_CLIENT_TYPE_FROM_HANDLE(Handle: ULONG) -> ULONG {
71 Handle & (GDI_HANDLE_ALTTYPE_MASK << GDI_HANDLE_ALTTYPE_SHIFT | GDI_HANDLE_TYPE_MASK
72 << GDI_HANDLE_TYPE_SHIFT)
73 }
74 #[inline]
GDI_CLIENT_TYPE_FROM_UNIQUE(Unique: ULONG) -> ULONG75 pub const fn GDI_CLIENT_TYPE_FROM_UNIQUE(Unique: ULONG) -> ULONG {
76 GDI_CLIENT_TYPE_FROM_HANDLE(Unique << 16)
77 }
78 pub const GDI_ALTTYPE_1: ULONG = 1 << GDI_HANDLE_ALTTYPE_SHIFT;
79 pub const GDI_ALTTYPE_2: ULONG = 2 << GDI_HANDLE_ALTTYPE_SHIFT;
80 pub const GDI_ALTTYPE_3: ULONG = 3 << GDI_HANDLE_ALTTYPE_SHIFT;
81 pub const GDI_CLIENT_BITMAP_TYPE: ULONG = GDI_SURF_TYPE << GDI_HANDLE_TYPE_SHIFT;
82 pub const GDI_CLIENT_BRUSH_TYPE: ULONG = GDI_BRUSH_TYPE << GDI_HANDLE_TYPE_SHIFT;
83 pub const GDI_CLIENT_CLIENTOBJ_TYPE: ULONG = GDI_CLIENTOBJ_TYPE << GDI_HANDLE_TYPE_SHIFT;
84 pub const GDI_CLIENT_DC_TYPE: ULONG = GDI_DC_TYPE << GDI_HANDLE_TYPE_SHIFT;
85 pub const GDI_CLIENT_FONT_TYPE: ULONG = GDI_LFONT_TYPE << GDI_HANDLE_TYPE_SHIFT;
86 pub const GDI_CLIENT_PALETTE_TYPE: ULONG = GDI_PAL_TYPE << GDI_HANDLE_TYPE_SHIFT;
87 pub const GDI_CLIENT_REGION_TYPE: ULONG = GDI_RGN_TYPE << GDI_HANDLE_TYPE_SHIFT;
88 pub const GDI_CLIENT_ALTDC_TYPE: ULONG = GDI_CLIENT_DC_TYPE | GDI_ALTTYPE_1;
89 pub const GDI_CLIENT_DIBSECTION_TYPE: ULONG = GDI_CLIENT_BITMAP_TYPE | GDI_ALTTYPE_1;
90 pub const GDI_CLIENT_EXTPEN_TYPE: ULONG = GDI_CLIENT_BRUSH_TYPE | GDI_ALTTYPE_2;
91 pub const GDI_CLIENT_METADC16_TYPE: ULONG = GDI_CLIENT_CLIENTOBJ_TYPE | GDI_ALTTYPE_3;
92 pub const GDI_CLIENT_METAFILE_TYPE: ULONG = GDI_CLIENT_CLIENTOBJ_TYPE | GDI_ALTTYPE_2;
93 pub const GDI_CLIENT_METAFILE16_TYPE: ULONG = GDI_CLIENT_CLIENTOBJ_TYPE | GDI_ALTTYPE_1;
94 pub const GDI_CLIENT_PEN_TYPE: ULONG = GDI_CLIENT_BRUSH_TYPE | GDI_ALTTYPE_1;
95 UNION!{union GDI_HANDLE_ENTRY_u {
96 Object: PVOID,
97 NextFree: PVOID,
98 }}
99 STRUCT!{struct GDI_HANDLE_ENTRY_Owner_s {
100 ProcessId: USHORT,
101 Bitfields: USHORT,
102 }}
103 BITFIELD!{GDI_HANDLE_ENTRY_Owner_s Bitfields: USHORT [
104 Lock set_Lock[0..1],
105 Count set_Count[1..16],
106 ]}
107 UNION!{union GDI_HANDLE_ENTRY_Owner {
108 s: GDI_HANDLE_ENTRY_Owner_s,
109 Value: ULONG,
110 }}
111 STRUCT!{struct GDI_HANDLE_ENTRY {
112 u: GDI_HANDLE_ENTRY_u,
113 Owner: GDI_HANDLE_ENTRY_Owner,
114 Unique: USHORT,
115 Type: UCHAR,
116 Flags: UCHAR,
117 UserPointer: PVOID,
118 }}
119 pub type PGDI_HANDLE_ENTRY = *mut GDI_HANDLE_ENTRY;
120 STRUCT!{struct GDI_SHARED_MEMORY {
121 Handles: [GDI_HANDLE_ENTRY; GDI_MAX_HANDLE_COUNT],
122 }}
123 pub type PGDI_SHARED_MEMORY = *mut GDI_SHARED_MEMORY;
124