include: Add transact.idl to oledb.idl.
[wine.git] / dlls / win32u / win32u_private.h
bloba76bd6f0c16dc6f3454e358ea73f40d4696c690f
1 /*
2 * Unix call wrappers
4 * Copyright 2021 Jacek Caban for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __WINE_WIN32U_PRIVATE
22 #define __WINE_WIN32U_PRIVATE
24 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "ntgdi.h"
28 #include "ntuser.h"
29 #include "wine/gdi_driver.h"
30 #include "wine/unixlib.h"
31 #include "wine/debug.h"
33 struct user_callbacks
35 HWND (WINAPI *pGetDesktopWindow)(void);
36 UINT (WINAPI *pGetDpiForSystem)(void);
37 BOOL (WINAPI *pGetMonitorInfoW)( HMONITOR, LPMONITORINFO );
38 INT (WINAPI *pGetSystemMetrics)(INT);
39 BOOL (WINAPI *pGetWindowRect)( HWND hwnd, LPRECT rect );
40 BOOL (WINAPI *pEnumDisplayMonitors)( HDC, LPRECT, MONITORENUMPROC, LPARAM );
41 BOOL (WINAPI *pEnumDisplaySettingsW)(LPCWSTR, DWORD, LPDEVMODEW );
42 BOOL (WINAPI *pRedrawWindow)( HWND, const RECT*, HRGN, UINT );
43 DPI_AWARENESS_CONTEXT (WINAPI *pSetThreadDpiAwarenessContext)( DPI_AWARENESS_CONTEXT );
44 HWND (WINAPI *pWindowFromDC)( HDC );
47 struct unix_funcs
49 /* win32u functions */
50 INT (WINAPI *pNtGdiAbortDoc)( HDC hdc );
51 BOOL (WINAPI *pNtGdiAbortPath)( HDC hdc );
52 BOOL (WINAPI *pNtGdiAlphaBlend)( HDC hdc_dst, int x_dst, int y_dst, int width_dst, int height_dst,
53 HDC hdc_src, int x_src, int y_src, int width_src, int height_src,
54 BLENDFUNCTION blend_function, HANDLE xform );
55 BOOL (WINAPI *pNtGdiAngleArc)( HDC hdc, INT x, INT y, DWORD radius, FLOAT start_angle,
56 FLOAT sweep_angle );
57 BOOL (WINAPI *pNtGdiArcInternal)( UINT type, HDC hdc, INT left, INT top, INT right, INT bottom,
58 INT xstart, INT ystart, INT xend, INT yend );
59 BOOL (WINAPI *pNtGdiBeginPath)( HDC hdc );
60 BOOL (WINAPI *pNtGdiBitBlt)( HDC hdc_dst, INT x_dst, INT y_dst, INT width, INT height, HDC hdc_src,
61 INT x_src, INT y_src, DWORD rop, DWORD bk_color, FLONG fl );
62 BOOL (WINAPI *pNtGdiCloseFigure)( HDC hdc );
63 BOOL (WINAPI *pNtGdiComputeXformCoefficients)( HDC hdc );
64 HBITMAP (WINAPI *pNtGdiCreateCompatibleBitmap)( HDC hdc, INT width, INT height );
65 HDC (WINAPI *pNtGdiCreateCompatibleDC)( HDC hdc );
66 HBITMAP (WINAPI *pNtGdiCreateDIBitmapInternal)( HDC hdc, INT width, INT height, DWORD init,
67 const void *bits, const BITMAPINFO *data,
68 UINT coloruse, UINT max_info, UINT max_bits,
69 ULONG flags, HANDLE xform );
70 HDC (WINAPI *pNtGdiCreateMetafileDC)( HDC hdc );
71 NTSTATUS (WINAPI *pNtGdiDdDDICheckVidPnExclusiveOwnership)( const D3DKMT_CHECKVIDPNEXCLUSIVEOWNERSHIP *desc );
72 NTSTATUS (WINAPI *pNtGdiDdDDICreateDCFromMemory)( D3DKMT_CREATEDCFROMMEMORY *desc );
73 NTSTATUS (WINAPI *pNtGdiDdDDIDestroyDCFromMemory)( const D3DKMT_DESTROYDCFROMMEMORY *desc );
74 NTSTATUS (WINAPI *pNtGdiDdDDIDestroyDevice)( const D3DKMT_DESTROYDEVICE *desc );
75 NTSTATUS (WINAPI *pNtGdiDdDDIEscape)( const D3DKMT_ESCAPE *desc );
76 NTSTATUS (WINAPI *pNtGdiDdDDISetVidPnSourceOwner)( const D3DKMT_SETVIDPNSOURCEOWNER *desc );
77 BOOL (WINAPI *pNtGdiDeleteObjectApp)( HGDIOBJ obj );
78 LONG (WINAPI *pNtGdiDoPalette)( HGDIOBJ handle, WORD start, WORD count, void *entries,
79 DWORD func, BOOL inbound );
80 BOOL (WINAPI *pNtGdiEllipse)( HDC hdc, INT left, INT top, INT right, INT bottom );
81 INT (WINAPI *pNtGdiEndDoc)(HDC hdc);
82 BOOL (WINAPI *pNtGdiEndPath)( HDC hdc );
83 INT (WINAPI *pNtGdiEndPage)( HDC hdc );
84 BOOL (WINAPI *pNtGdiEnumFonts)( HDC hdc, ULONG type, ULONG win32_compat, ULONG face_name_len,
85 const WCHAR *face_name, ULONG charset, ULONG *count, void *buf );
86 INT (WINAPI *pNtGdiExcludeClipRect)( HDC hdc, INT left, INT top, INT right, INT bottom );
87 INT (WINAPI *pNtGdiExtEscape)( HDC hdc, WCHAR *driver, INT driver_id, INT escape, INT input_size,
88 const char *input, INT output_size, char *output );
89 BOOL (WINAPI *pNtGdiExtFloodFill)( HDC hdc, INT x, INT y, COLORREF color, UINT type );
90 BOOL (WINAPI *pNtGdiExtTextOutW)( HDC hdc, INT x, INT y, UINT flags, const RECT *rect,
91 const WCHAR *str, UINT count, const INT *dx, DWORD cp );
92 INT (WINAPI *pNtGdiExtSelectClipRgn)( HDC hdc, HRGN region, INT mode );
93 BOOL (WINAPI *pNtGdiFillPath)( HDC hdc );
94 BOOL (WINAPI *pNtGdiFillRgn)( HDC hdc, HRGN hrgn, HBRUSH hbrush );
95 BOOL (WINAPI *pNtGdiFontIsLinked)( HDC hdc );
96 BOOL (WINAPI *pNtGdiFrameRgn)( HDC hdc, HRGN hrgn, HBRUSH brush, INT width, INT height );
97 BOOL (WINAPI *pNtGdiGetAndSetDCDword)( HDC hdc, UINT method, DWORD value, DWORD *result );
98 INT (WINAPI *pNtGdiGetAppClipBox)( HDC hdc, RECT *rect );
99 UINT (WINAPI *pNtGdiGetBoundsRect)( HDC hdc, RECT *rect, UINT flags );
100 BOOL (WINAPI *pNtGdiGetCharABCWidthsW)( HDC hdc, UINT first, UINT last, WCHAR *chars,
101 ULONG flags, void *buffer );
102 BOOL (WINAPI *pNtGdiGetCharWidthW)( HDC hdc, UINT first_char, UINT last_char, WCHAR *chars,
103 ULONG flags, void *buffer );
104 BOOL (WINAPI *pNtGdiGetCharWidthInfo)( HDC hdc, struct char_width_info *info );
105 INT (WINAPI *pNtGdiGetDIBitsInternal)( HDC hdc, HBITMAP hbitmap, UINT startscan, UINT lines,
106 void *bits, BITMAPINFO *info, UINT coloruse,
107 UINT max_bits, UINT max_info );
108 INT (WINAPI *pNtGdiGetDeviceCaps)( HDC hdc, INT cap );
109 BOOL (WINAPI *pNtGdiGetDeviceGammaRamp)( HDC hdc, void *ptr );
110 DWORD (WINAPI *pNtGdiGetFontData)( HDC hdc, DWORD table, DWORD offset, void *buffer, DWORD length );
111 DWORD (WINAPI *pNtGdiGetFontUnicodeRanges)( HDC hdc, GLYPHSET *lpgs );
112 DWORD (WINAPI *pNtGdiGetGlyphIndicesW)( HDC hdc, const WCHAR *str, INT count,
113 WORD *indices, DWORD flags );
114 DWORD (WINAPI *pNtGdiGetGlyphOutline)( HDC hdc, UINT ch, UINT format, GLYPHMETRICS *metrics,
115 DWORD size, void *buffer, const MAT2 *mat2,
116 BOOL ignore_rotation );
117 DWORD (WINAPI *pNtGdiGetKerningPairs)( HDC hdc, DWORD count, KERNINGPAIR *kern_pair );
118 COLORREF (WINAPI *pNtGdiGetNearestColor)( HDC hdc, COLORREF color );
119 UINT (WINAPI *pNtGdiGetOutlineTextMetricsInternalW)( HDC hdc, UINT cbData,
120 OUTLINETEXTMETRICW *otm, ULONG opts );
121 COLORREF (WINAPI *pNtGdiGetPixel)( HDC hdc, INT x, INT y );
122 INT (WINAPI *pNtGdiGetRandomRgn)( HDC hdc, HRGN region, INT code );
123 BOOL (WINAPI *pNtGdiGetRasterizerCaps)( RASTERIZER_STATUS *status, UINT size );
124 BOOL (WINAPI *pNtGdiGetRealizationInfo)( HDC hdc, struct font_realization_info *info );
125 UINT (WINAPI *pNtGdiGetTextCharsetInfo)( HDC hdc, FONTSIGNATURE *fs, DWORD flags );
126 BOOL (WINAPI *pNtGdiGetTextExtentExW)( HDC hdc, const WCHAR *str, INT count, INT max_ext,
127 INT *nfit, INT *dxs, SIZE *size, UINT flags );
128 INT (WINAPI *pNtGdiGetTextFaceW)( HDC hdc, INT count, WCHAR *name, BOOL alias_name );
129 BOOL (WINAPI *pNtGdiGetTextMetricsW)( HDC hdc, TEXTMETRICW *metrics, ULONG flags );
130 BOOL (WINAPI *pNtGdiGradientFill)( HDC hdc, TRIVERTEX *vert_array, ULONG nvert,
131 void *grad_array, ULONG ngrad, ULONG mode );
132 INT (WINAPI *pNtGdiIntersectClipRect)( HDC hdc, INT left, INT top, INT right, INT bottom );
133 BOOL (WINAPI *pNtGdiInvertRgn)( HDC hdc, HRGN hrgn );
134 BOOL (WINAPI *pNtGdiLineTo)( HDC hdc, INT x, INT y );
135 BOOL (WINAPI *pNtGdiMaskBlt)( HDC hdc, INT x_dst, INT y_dst, INT width_dst, INT height_dst,
136 HDC hdc_src, INT x_src, INT y_src, HBITMAP mask,
137 INT x_mask, INT y_mask, DWORD rop, DWORD bk_color );
138 BOOL (WINAPI *pNtGdiModifyWorldTransform)( HDC hdc, const XFORM *xform, DWORD mode );
139 BOOL (WINAPI *pNtGdiMoveTo)( HDC hdc, INT x, INT y, POINT *pt );
140 INT (WINAPI *pNtGdiOffsetClipRgn)( HDC hdc, INT x, INT y );
141 HDC (WINAPI *pNtGdiOpenDCW)( UNICODE_STRING *device, const DEVMODEW *devmode,
142 UNICODE_STRING *output, ULONG type, BOOL is_display,
143 HANDLE hspool, DRIVER_INFO_2W *driver_info, void *pdev );
144 BOOL (WINAPI *pNtGdiPatBlt)( HDC hdc, INT left, INT top, INT width, INT height, DWORD rop );
145 BOOL (WINAPI *pNtGdiPlgBlt)( HDC hdc, const POINT *point, HDC hdc_src, INT x_src, INT y_src,
146 INT width, INT height, HBITMAP mask, INT x_mask, INT y_mask,
147 DWORD bk_color );
148 BOOL (WINAPI *pNtGdiPolyDraw)(HDC hdc, const POINT *points, const BYTE *types, DWORD count );
149 ULONG (WINAPI *pNtGdiPolyPolyDraw)( HDC hdc, const POINT *points, const UINT *counts,
150 DWORD count, UINT function );
151 BOOL (WINAPI *pNtGdiPtVisible)( HDC hdc, INT x, INT y );
152 BOOL (WINAPI *pNtGdiRectVisible)( HDC hdc, const RECT *rect );
153 BOOL (WINAPI *pNtGdiRectangle)( HDC hdc, INT left, INT top, INT right, INT bottom );
154 BOOL (WINAPI *pNtGdiResetDC)( HDC hdc, const DEVMODEW *devmode, BOOL *banding,
155 DRIVER_INFO_2W *driver_info, void *dev );
156 BOOL (WINAPI *pNtGdiResizePalette)( HPALETTE palette, UINT count );
157 BOOL (WINAPI *pNtGdiRestoreDC)( HDC hdc, INT level );
158 BOOL (WINAPI *pNtGdiRoundRect)( HDC hdc, INT left, INT top, INT right,
159 INT bottom, INT ell_width, INT ell_height );
160 BOOL (WINAPI *pNtGdiScaleViewportExtEx)( HDC hdc, INT x_num, INT x_denom,
161 INT y_num, INT y_denom, SIZE *size );
162 BOOL (WINAPI *pNtGdiScaleWindowExtEx)( HDC hdc, INT x_num, INT x_denom,
163 INT y_num, INT y_denom, SIZE *size );
164 HGDIOBJ (WINAPI *pNtGdiSelectBitmap)( HDC hdc, HGDIOBJ handle );
165 HGDIOBJ (WINAPI *pNtGdiSelectBrush)( HDC hdc, HGDIOBJ handle );
166 BOOL (WINAPI *pNtGdiSelectClipPath)( HDC hdc, INT mode );
167 HGDIOBJ (WINAPI *pNtGdiSelectFont)( HDC hdc, HGDIOBJ handle );
168 HGDIOBJ (WINAPI *pNtGdiSelectPen)( HDC hdc, HGDIOBJ handle );
169 UINT (WINAPI *pNtGdiSetBoundsRect)( HDC hdc, const RECT *rect, UINT flags );
170 INT (WINAPI *pNtGdiSetDIBitsToDeviceInternal)( HDC hdc, INT x_dst, INT y_dst, DWORD cx,
171 DWORD cy, INT x_src, INT y_src, UINT startscan,
172 UINT lines, const void *bits, const BITMAPINFO *bmi,
173 UINT coloruse, UINT max_bits, UINT max_info,
174 BOOL xform_coords, HANDLE xform );
175 BOOL (WINAPI *pNtGdiSetDeviceGammaRamp)( HDC hdc, void *ptr );
176 DWORD (WINAPI *pNtGdiSetLayout)( HDC hdc, LONG wox, DWORD layout );
177 COLORREF (WINAPI *pNtGdiSetPixel)( HDC hdc, INT x, INT y, COLORREF color );
178 UINT (WINAPI *pNtGdiSetSystemPaletteUse)( HDC hdc, UINT use );
179 INT (WINAPI *pNtGdiStartDoc)( HDC hdc, const DOCINFOW *doc, BOOL *banding, INT job );
180 INT (WINAPI *pNtGdiStartPage)( HDC hdc );
181 BOOL (WINAPI *pNtGdiStretchBlt)( HDC hdc, INT x_dst, INT y_dst, INT width_dst, INT height_dst,
182 HDC hdc_src, INT x_src, INT y_src, INT width_src, INT height_src,
183 DWORD rop, COLORREF bk_color );
184 INT (WINAPI *pNtGdiStretchDIBitsInternal)( HDC hdc, INT x_dst, INT y_dst, INT width_dst,
185 INT height_dst, INT x_src, INT y_src, INT width_src,
186 INT height_src, const void *bits, const BITMAPINFO *bmi,
187 UINT coloruse, DWORD rop, UINT max_info, UINT max_bits,
188 HANDLE xform );
189 BOOL (WINAPI *pNtGdiStrokeAndFillPath)( HDC hdc );
190 BOOL (WINAPI *pNtGdiStrokePath)( HDC hdc );
191 BOOL (WINAPI *pNtGdiTransparentBlt)( HDC hdc, int x_dst, int y_dst, int width_dst, int height_dst,
192 HDC hdc_src, int x_src, int y_src, int width_src, int height_src,
193 UINT color );
194 BOOL (WINAPI *pNtGdiUnrealizeObject)( HGDIOBJ obj );
195 BOOL (WINAPI *pNtGdiUpdateColors)( HDC hdc );
196 BOOL (WINAPI *pNtGdiWidenPath)( HDC hdc );
198 /* Wine-specific functions */
199 UINT (WINAPI *pGDIRealizePalette)( HDC hdc );
200 HPALETTE (WINAPI *pGDISelectPalette)( HDC hdc, HPALETTE hpal, WORD bkg );
201 DWORD_PTR (WINAPI *pGetDCHook)( HDC hdc, DCHOOKPROC *proc );
202 BOOL (WINAPI *pMirrorRgn)( HWND hwnd, HRGN hrgn );
203 BOOL (WINAPI *pSetDCHook)( HDC hdc, DCHOOKPROC proc, DWORD_PTR data );
204 INT (WINAPI *pSetDIBits)( HDC hdc, HBITMAP hbitmap, UINT startscan,
205 UINT lines, const void *bits, const BITMAPINFO *info,
206 UINT coloruse );
207 WORD (WINAPI *pSetHookFlags)( HDC hdc, WORD flags );
208 BOOL (CDECL *get_brush_bitmap_info)( HBRUSH handle, BITMAPINFO *info, void *bits, UINT *usage );
209 BOOL (CDECL *get_file_outline_text_metric)( const WCHAR *path, OUTLINETEXTMETRICW *otm );
210 BOOL (CDECL *get_icm_profile)( HDC hdc, BOOL allow_default, DWORD *size, WCHAR *filename );
211 const struct vulkan_funcs * (CDECL *get_vulkan_driver)( HDC hdc, UINT version );
212 struct opengl_funcs * (CDECL *get_wgl_driver)( HDC hdc, UINT version );
213 void (CDECL *make_gdi_object_system)( HGDIOBJ handle, BOOL set );
214 void (CDECL *set_display_driver)( void *proc );
215 void (CDECL *set_visible_region)( HDC hdc, HRGN hrgn, const RECT *vis_rect, const RECT *device_rect,
216 struct window_surface *surface );
219 UINT WINAPI GDIRealizePalette( HDC hdc );
220 HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg );
222 extern void wrappers_init( unixlib_handle_t handle ) DECLSPEC_HIDDEN;
223 extern NTSTATUS gdi_init(void) DECLSPEC_HIDDEN;
224 extern NTSTATUS callbacks_init( void *args ) DECLSPEC_HIDDEN;
225 extern void winstation_init(void) DECLSPEC_HIDDEN;
227 extern HKEY reg_open_hkcu_key( const char *name ) DECLSPEC_HIDDEN;
228 extern HKEY reg_open_key( HKEY root, const WCHAR *name, ULONG name_len ) DECLSPEC_HIDDEN;
229 extern ULONG query_reg_ascii_value( HKEY hkey, const char *name,
230 KEY_VALUE_PARTIAL_INFORMATION *info, ULONG size ) DECLSPEC_HIDDEN;
232 static inline WCHAR *win32u_wcsrchr( const WCHAR *str, WCHAR ch )
234 WCHAR *ret = NULL;
235 do { if (*str == ch) ret = (WCHAR *)(ULONG_PTR)str; } while (*str++);
236 return ret;
239 static inline WCHAR win32u_towupper( WCHAR ch )
241 return RtlUpcaseUnicodeChar( ch );
244 static inline WCHAR *win32u_wcschr( const WCHAR *str, WCHAR ch )
246 do { if (*str == ch) return (WCHAR *)(ULONG_PTR)str; } while (*str++);
247 return NULL;
250 static inline int win32u_wcsicmp( const WCHAR *str1, const WCHAR *str2 )
252 int ret;
253 for (;;)
255 if ((ret = win32u_towupper( *str1 ) - win32u_towupper( *str2 )) || !*str1) return ret;
256 str1++;
257 str2++;
261 static inline int win32u_wcscmp( const WCHAR *str1, const WCHAR *str2 )
263 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
264 return *str1 - *str2;
267 static inline LONG win32u_wcstol( LPCWSTR s, LPWSTR *end, INT base )
269 BOOL negative = FALSE, empty = TRUE;
270 LONG ret = 0;
272 if (base < 0 || base == 1 || base > 36) return 0;
273 if (end) *end = (WCHAR *)s;
274 while (*s == ' ' || *s == '\t') s++;
276 if (*s == '-')
278 negative = TRUE;
279 s++;
281 else if (*s == '+') s++;
283 if ((base == 0 || base == 16) && s[0] == '0' && (s[1] == 'x' || s[1] == 'X'))
285 base = 16;
286 s += 2;
288 if (base == 0) base = s[0] != '0' ? 10 : 8;
290 while (*s)
292 int v;
294 if ('0' <= *s && *s <= '9') v = *s - '0';
295 else if ('A' <= *s && *s <= 'Z') v = *s - 'A' + 10;
296 else if ('a' <= *s && *s <= 'z') v = *s - 'a' + 10;
297 else break;
298 if (v >= base) break;
299 if (negative) v = -v;
300 s++;
301 empty = FALSE;
303 if (!negative && (ret > MAXLONG / base || ret * base > MAXLONG - v))
304 ret = MAXLONG;
305 else if (negative && (ret < (LONG)MINLONG / base || ret * base < (LONG)(MINLONG - v)))
306 ret = MINLONG;
307 else
308 ret = ret * base + v;
311 if (end && !empty) *end = (WCHAR *)s;
312 return ret;
315 #define towupper(c) win32u_towupper(c)
316 #define wcschr(s,c) win32u_wcschr(s,c)
317 #define wcscmp(s1,s2) win32u_wcscmp(s1,s2)
318 #define wcsicmp(s1,s2) win32u_wcsicmp(s1,s2)
319 #define wcsrchr(s,c) win32u_wcsrchr(s,c)
320 #define wcstol(s,e,b) win32u_wcstol(s,e,b)
322 static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len )
324 while (len--) *dst++ = (unsigned char)*src++;
327 static inline UINT asciiz_to_unicode( WCHAR *dst, const char *src )
329 WCHAR *p = dst;
330 while ((*p++ = *src++));
331 return (p - dst) * sizeof(WCHAR);
334 DWORD win32u_mbtowc( CPTABLEINFO *info, WCHAR *dst, DWORD dstlen, const char *src,
335 DWORD srclen ) DECLSPEC_HIDDEN;
336 DWORD win32u_wctomb( CPTABLEINFO *info, char *dst, DWORD dstlen, const WCHAR *src,
337 DWORD srclen ) DECLSPEC_HIDDEN;
339 #endif /* __WINE_WIN32U_PRIVATE */