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
24 #define WIN32_NO_STATUS
28 #include "wow64win_private.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(wow
);
33 NTSTATUS WINAPI
wow64_NtUserInitializeClientPfnArrays( UINT
*args
)
36 return STATUS_NOT_SUPPORTED
;
39 NTSTATUS WINAPI
wow64_NtUserCreateWindowStation( UINT
*args
)
41 OBJECT_ATTRIBUTES32
*attr32
= get_ptr( &args
);
42 ACCESS_MASK access
= get_ulong( &args
);
43 ULONG arg3
= get_ulong( &args
);
44 ULONG arg4
= get_ulong( &args
);
45 ULONG arg5
= get_ulong( &args
);
46 ULONG arg6
= get_ulong( &args
);
47 ULONG arg7
= get_ulong( &args
);
49 struct object_attr64 attr
;
51 return HandleToUlong( NtUserCreateWindowStation( objattr_32to64( &attr
, attr32
), access
,
52 arg3
, arg4
, arg5
, arg6
, arg7
));
55 NTSTATUS WINAPI
wow64_NtUserOpenWindowStation( UINT
*args
)
57 OBJECT_ATTRIBUTES32
*attr32
= get_ptr( &args
);
58 ACCESS_MASK access
= get_ulong( &args
);
60 struct object_attr64 attr
;
62 return HandleToUlong( NtUserOpenWindowStation( objattr_32to64( &attr
, attr32
), access
));
65 NTSTATUS WINAPI
wow64_NtUserCloseWindowStation( UINT
*args
)
67 HWINSTA handle
= get_handle( &args
);
69 return NtUserCloseWindowStation( handle
);
72 NTSTATUS WINAPI
wow64_NtUserGetProcessWindowStation( UINT
*args
)
74 return HandleToUlong( NtUserGetProcessWindowStation() );
77 NTSTATUS WINAPI
wow64_NtUserSetProcessWindowStation( UINT
*args
)
79 HWINSTA handle
= get_handle( &args
);
81 return NtUserSetProcessWindowStation( handle
);
84 NTSTATUS WINAPI
wow64_NtUserCreateDesktopEx( UINT
*args
)
86 OBJECT_ATTRIBUTES32
*attr32
= get_ptr( &args
);
87 UNICODE_STRING32
*device32
= get_ptr( &args
);
88 DEVMODEW
*devmode
= get_ptr( &args
);
89 DWORD flags
= get_ulong( &args
);
90 ACCESS_MASK access
= get_ulong( &args
);
91 ULONG heap_size
= get_ulong( &args
);
93 struct object_attr64 attr
;
94 UNICODE_STRING device
;
97 ret
= NtUserCreateDesktopEx( objattr_32to64( &attr
, attr32
),
98 unicode_str_32to64( &device
, device32
),
99 devmode
, flags
, access
, heap_size
);
100 return HandleToUlong( ret
);
103 NTSTATUS WINAPI
wow64_NtUserOpenDesktop( UINT
*args
)
105 OBJECT_ATTRIBUTES32
*attr32
= get_ptr( &args
);
106 DWORD flags
= get_ulong( &args
);
107 ACCESS_MASK access
= get_ulong( &args
);
109 struct object_attr64 attr
;
112 ret
= NtUserOpenDesktop( objattr_32to64( &attr
, attr32
), flags
, access
);
113 return HandleToUlong( ret
);
116 NTSTATUS WINAPI
wow64_NtUserCloseDesktop( UINT
*args
)
118 HDESK handle
= get_handle( &args
);
120 return NtUserCloseDesktop( handle
);
123 NTSTATUS WINAPI
wow64_NtUserGetThreadDesktop( UINT
*args
)
125 DWORD thread
= get_ulong( &args
);
127 return HandleToUlong( NtUserGetThreadDesktop( thread
));
130 NTSTATUS WINAPI
wow64_NtUserSetThreadDesktop( UINT
*args
)
132 HDESK handle
= get_handle( &args
);
134 return NtUserSetThreadDesktop( handle
);
137 NTSTATUS WINAPI
wow64_NtUserOpenInputDesktop( UINT
*args
)
139 DWORD flags
= get_ulong( &args
);
140 BOOL inherit
= get_ulong( &args
);
141 ACCESS_MASK access
= get_ulong( &args
);
143 return HandleToUlong( NtUserOpenInputDesktop( flags
, inherit
, access
));
146 NTSTATUS WINAPI
wow64_NtUserGetObjectInformation( UINT
*args
)
148 HANDLE handle
= get_handle( &args
);
149 INT index
= get_ulong( &args
);
150 void *info
= get_ptr( &args
);
151 DWORD len
= get_ulong( &args
);
152 DWORD
*needed
= get_ptr( &args
);
154 return NtUserGetObjectInformation( handle
, index
, info
, len
, needed
);
157 NTSTATUS WINAPI
wow64_NtUserSetObjectInformation( UINT
*args
)
159 HANDLE handle
= get_handle( &args
);
160 INT index
= get_ulong( &args
);
161 void *info
= get_ptr( &args
);
162 DWORD len
= get_ulong( &args
);
164 return NtUserSetObjectInformation( handle
, index
, info
, len
);
167 NTSTATUS WINAPI
wow64_NtUserGetProp( UINT
*args
)
169 HWND hwnd
= get_handle( &args
);
170 const WCHAR
*str
= get_ptr( &args
);
172 return HandleToUlong( NtUserGetProp( hwnd
, str
));
175 NTSTATUS WINAPI
wow64_NtUserSetProp( UINT
*args
)
177 HWND hwnd
= get_handle( &args
);
178 const WCHAR
*str
= get_ptr( &args
);
179 HANDLE handle
= get_handle( &args
);
181 return NtUserSetProp( hwnd
, str
, handle
);
184 NTSTATUS WINAPI
wow64_NtUserRemoveProp( UINT
*args
)
186 HWND hwnd
= get_handle( &args
);
187 const WCHAR
*str
= get_ptr( &args
);
189 return HandleToUlong( NtUserRemoveProp( hwnd
, str
));
192 NTSTATUS WINAPI
wow64_NtUserGetAncestor( UINT
*args
)
194 HWND hwnd
= get_handle( &args
);
195 UINT type
= get_ulong( &args
);
197 return HandleToUlong( NtUserGetAncestor( hwnd
, type
));
200 NTSTATUS WINAPI
wow64_NtUserBuildHwndList( UINT
*args
)
202 HDESK desktop
= get_handle( &args
);
203 ULONG unk2
= get_ulong( &args
);
204 ULONG unk3
= get_ulong( &args
);
205 ULONG unk4
= get_ulong( &args
);
206 ULONG thread_id
= get_ulong( &args
);
207 ULONG count
= get_ulong( &args
);
208 UINT32
*buffer32
= get_ptr( &args
);
209 ULONG
*size
= get_ptr( &args
);
215 if (!(buffer
= Wow64AllocateTemp( count
* sizeof(*buffer
) ))) return STATUS_NO_MEMORY
;
217 if ((status
= NtUserBuildHwndList( desktop
, unk2
, unk3
, unk4
, thread_id
, count
, buffer
, size
)))
220 for (i
= 0; i
< *size
; i
++)
221 buffer32
[i
] = HandleToUlong( buffer
[i
] );
225 NTSTATUS WINAPI
wow64_NtUserInternalGetWindowText( UINT
*args
)
227 HWND hwnd
= get_handle( &args
);
228 WCHAR
*text
= get_ptr( &args
);
229 INT count
= get_ulong( &args
);
231 return NtUserInternalGetWindowText( hwnd
, text
, count
);
234 NTSTATUS WINAPI
wow64_NtUserGetLayeredWindowAttributes( UINT
*args
)
236 HWND hwnd
= get_handle( &args
);
237 COLORREF
*key
= get_ptr( &args
);
238 BYTE
*alpha
= get_ptr( &args
);
239 DWORD
*flags
= get_ptr( &args
);
241 return NtUserGetLayeredWindowAttributes( hwnd
, key
, alpha
, flags
);
244 NTSTATUS WINAPI
wow64_NtUserGetClipboardFormatName( UINT
*args
)
246 UINT format
= get_ulong( &args
);
247 WCHAR
*buffer
= get_ptr( &args
);
248 INT maxlen
= get_ulong( &args
);
250 return NtUserGetClipboardFormatName( format
, buffer
, maxlen
);
253 NTSTATUS WINAPI
wow64_NtUserGetClipboardOwner( UINT
*args
)
255 return HandleToUlong( NtUserGetClipboardOwner() );
258 NTSTATUS WINAPI
wow64_NtUserGetOpenClipboardWindow( UINT
*args
)
260 return HandleToUlong( NtUserGetOpenClipboardWindow() );
263 NTSTATUS WINAPI
wow64_NtUserGetClipboardSequenceNumber( UINT
*args
)
265 return NtUserGetClipboardSequenceNumber();
268 NTSTATUS WINAPI
wow64_NtUserGetClipboardViewer( UINT
*args
)
270 return HandleToUlong( NtUserGetClipboardViewer() );
273 NTSTATUS WINAPI
wow64_NtUserAddClipboardFormatListener( UINT
*args
)
275 HWND hwnd
= get_handle( &args
);
277 return NtUserAddClipboardFormatListener( hwnd
);
280 NTSTATUS WINAPI
wow64_NtUserRemoveClipboardFormatListener( UINT
*args
)
282 HWND hwnd
= get_handle( &args
);
284 return NtUserRemoveClipboardFormatListener( hwnd
);
287 NTSTATUS WINAPI
wow64_NtUserGetCursor( UINT
*args
)
289 return HandleToUlong( NtUserGetCursor() );
292 NTSTATUS WINAPI
wow64_NtUserFindExistingCursorIcon( UINT
*args
)
294 UNICODE_STRING32
*module32
= get_ptr( &args
);
295 UNICODE_STRING32
*res_name32
= get_ptr( &args
);
296 void *desc
= get_ptr( &args
);
298 UNICODE_STRING module
;
299 UNICODE_STRING res_name
;
302 ret
= NtUserFindExistingCursorIcon( unicode_str_32to64( &module
, module32
),
303 unicode_str_32to64( &res_name
, res_name32
), desc
);
304 return HandleToUlong( ret
);
307 NTSTATUS WINAPI
wow64_NtUserGetIconSize( UINT
*args
)
309 HICON handle
= get_handle( &args
);
310 UINT step
= get_ulong( &args
);
311 LONG
*width
= get_ptr( &args
);
312 LONG
*height
= get_ptr( &args
);
314 return NtUserGetIconSize( handle
, step
, width
, height
);
317 NTSTATUS WINAPI
wow64_NtUserGetCursorFrameInfo( UINT
*args
)
319 HCURSOR cursor
= get_ptr( &args
);
320 DWORD istep
= get_ulong( &args
);
321 DWORD
*rate_jiffies
= get_ptr( &args
);
322 DWORD
*num_steps
= get_ptr( &args
);
324 return HandleToUlong( NtUserGetCursorFrameInfo( cursor
, istep
, rate_jiffies
, num_steps
));
327 NTSTATUS WINAPI
wow64_NtUserAttachThreadInput( UINT
*args
)
329 DWORD from
= get_ulong( &args
);
330 DWORD to
= get_ulong( &args
);
331 BOOL attach
= get_ulong( &args
);
333 return NtUserAttachThreadInput( from
, to
, attach
);
336 NTSTATUS WINAPI
wow64_NtUserGetKeyState( UINT
*args
)
338 INT vkey
= get_ulong( &args
);
340 return NtUserGetKeyState( vkey
);
343 NTSTATUS WINAPI
wow64_NtUserGetKeyboardLayout( UINT
*args
)
345 DWORD tid
= get_ulong( &args
);
347 return HandleToUlong( NtUserGetKeyboardLayout( tid
));
350 NTSTATUS WINAPI
wow64_NtUserGetKeyboardLayoutName( UINT
*args
)
352 WCHAR
*name
= get_ptr( &args
);
354 return NtUserGetKeyboardLayoutName( name
);
357 NTSTATUS WINAPI
wow64_NtUserGetKeyboardState( UINT
*args
)
359 BYTE
*state
= get_ptr( &args
);
361 return NtUserGetKeyboardState( state
);
364 NTSTATUS WINAPI
wow64_NtUserSetKeyboardState( UINT
*args
)
366 BYTE
*state
= get_ptr( &args
);
368 return NtUserSetKeyboardState( state
);
371 NTSTATUS WINAPI
wow64_NtUserGetMouseMovePointsEx( UINT
*args
)
373 UINT size
= get_ulong( &args
);
374 MOUSEMOVEPOINT
*ptin
= get_ptr( &args
);
375 MOUSEMOVEPOINT
*ptout
= get_ptr( &args
);
376 int count
= get_ulong( &args
);
377 DWORD resolution
= get_ulong( &args
);
379 return NtUserGetMouseMovePointsEx( size
, ptin
, ptout
, count
, resolution
);
382 NTSTATUS WINAPI
wow64_NtUserSetProcessDpiAwarenessContext( UINT
*args
)
384 ULONG awareness
= get_ulong( &args
);
385 ULONG unknown
= get_ulong( &args
);
387 return NtUserSetProcessDpiAwarenessContext( awareness
, unknown
);
390 NTSTATUS WINAPI
wow64_NtUserGetProcessDpiAwarenessContext( UINT
*args
)
392 HANDLE process
= get_handle( &args
);
394 return NtUserGetProcessDpiAwarenessContext( process
);
397 NTSTATUS WINAPI
wow64_NtUserGetSystemDpiForProcess( UINT
*args
)
399 HANDLE process
= get_handle( &args
);
401 return NtUserGetSystemDpiForProcess( process
);
404 NTSTATUS WINAPI
wow64_NtUserGetDpiForMonitor( UINT
*args
)
406 HMONITOR monitor
= get_handle( &args
);
407 UINT type
= get_ulong( &args
);
408 UINT
*x
= get_ptr( &args
);
409 UINT
*y
= get_ptr( &args
);
411 return NtUserGetDpiForMonitor( monitor
, type
, x
, y
);
414 NTSTATUS WINAPI
wow64_NtUserGetDoubleClickTime( UINT
*args
)
416 return NtUserGetDoubleClickTime();
419 NTSTATUS WINAPI
wow64_NtUserNotifyWinEvent( UINT
*args
)
421 DWORD event
= get_ulong( &args
);
422 HWND hwnd
= get_handle( &args
);
423 LONG object_id
= get_ulong( &args
);
424 LONG child_id
= get_ulong( &args
);
426 NtUserNotifyWinEvent( event
, hwnd
, object_id
, child_id
);
430 NTSTATUS WINAPI
wow64_NtUserSetWinEventHook( UINT
*args
)
432 DWORD event_min
= get_ulong( &args
);
433 DWORD event_max
= get_ulong( &args
);
434 HMODULE inst
= get_handle( &args
);
435 UNICODE_STRING32
*module32
= get_ptr( &args
);
436 WINEVENTPROC proc
= get_ptr(&args
);
437 DWORD pid
= get_ulong( &args
);
438 DWORD tid
= get_ulong( &args
);
439 DWORD flags
= get_ulong( &args
);
440 UNICODE_STRING module
;
443 ret
= NtUserSetWinEventHook( event_min
, event_max
, inst
,
444 unicode_str_32to64( &module
, module32
),
445 proc
, pid
, tid
, flags
);
446 return HandleToUlong( ret
);
449 NTSTATUS WINAPI
wow64_NtUserUnhookWinEvent( UINT
*args
)
451 HWINEVENTHOOK handle
= get_handle( &args
);
453 return NtUserUnhookWinEvent( handle
);
456 NTSTATUS WINAPI
wow64_NtUserSetWindowsHookEx( UINT
*args
)
458 HINSTANCE inst
= get_handle( &args
);
459 UNICODE_STRING32
*module32
= get_ptr( &args
);
460 DWORD tid
= get_ulong( &args
);
461 INT id
= get_ulong( &args
);
462 HOOKPROC proc
= get_ptr( &args
);
463 BOOL ansi
= get_ulong( &args
);
464 UNICODE_STRING module
;
467 ret
= NtUserSetWindowsHookEx( inst
, unicode_str_32to64( &module
, module32
),
468 tid
, id
, proc
, ansi
);
469 return HandleToUlong( ret
);
472 NTSTATUS WINAPI
wow64_NtUserUnhookWindowsHookEx( UINT
*args
)
474 HHOOK handle
= get_handle( &args
);
476 return NtUserUnhookWindowsHookEx( handle
);
479 NTSTATUS WINAPI
wow64_NtUserGetForegroundWindow( UINT
*args
)
481 return HandleToUlong( NtUserGetForegroundWindow() );
484 NTSTATUS WINAPI
wow64_NtUserGetGUIThreadInfo( UINT
*args
)
486 DWORD id
= get_ulong( &args
);
498 } *info32
= get_ptr( &args
);
501 if (info32
->cbSize
!= sizeof(*info32
))
503 SetLastError( ERROR_INVALID_PARAMETER
);
507 info
.cbSize
= sizeof(info
);
508 if (!NtUserGetGUIThreadInfo( id
, &info
)) return FALSE
;
509 info32
->flags
= info
.flags
;
510 info32
->hwndActive
= HandleToUlong( info
.hwndActive
);
511 info32
->hwndFocus
= HandleToUlong( info
.hwndFocus
);
512 info32
->hwndCapture
= HandleToUlong( info
.hwndCapture
);
513 info32
->hwndMenuOwner
= HandleToUlong( info
.hwndMenuOwner
);
514 info32
->hwndMoveSize
= HandleToUlong( info
.hwndMoveSize
);
515 info32
->hwndCaret
= HandleToUlong( info
.hwndCaret
);
516 info32
->rcCaret
= info
.rcCaret
;
520 NTSTATUS WINAPI
wow64_NtUserCopyAcceleratorTable( UINT
*args
)
522 HACCEL src
= get_handle( &args
);
523 ACCEL
*dst
= get_ptr( &args
);
524 INT count
= get_ulong( &args
);
526 return NtUserCopyAcceleratorTable( src
, dst
, count
);
529 NTSTATUS WINAPI
wow64_NtUserCreateAcceleratorTable( UINT
*args
)
531 ACCEL
*table
= get_ptr( &args
);
532 INT count
= get_ulong( &args
);
534 return HandleToUlong( NtUserCreateAcceleratorTable( table
, count
));
537 NTSTATUS WINAPI
wow64_NtUserDestroyAcceleratorTable( UINT
*args
)
539 HACCEL handle
= get_handle( &args
);
541 return NtUserDestroyAcceleratorTable( handle
);