dbghelp: Use local declarations of r_debug and link_map structs.
[wine.git] / dlls / user32 / misc.c
blobbed5812a47d5d9a31c65ca72a0effb253b30f2aa
1 /*
2 * Misc USER functions
4 * Copyright 1995 Thomas Sandford
5 * Copyright 1997 Marcus Meissner
6 * Copyright 1998 Turchanov Sergey
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "config.h"
25 #include <stdarg.h>
27 #include "windef.h"
28 #include "wine/windef16.h"
29 #include "winbase.h"
30 #include "wingdi.h"
31 #include "controls.h"
32 #include "user_private.h"
34 #include "wine/unicode.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(win);
39 #define IMM_INIT_MAGIC 0x19650412
40 static HWND (WINAPI *imm_get_ui_window)(HKL);
41 BOOL (WINAPI *imm_register_window)(HWND) = NULL;
42 void (WINAPI *imm_unregister_window)(HWND) = NULL;
44 /* MSIME messages */
45 static UINT WM_MSIME_SERVICE;
46 static UINT WM_MSIME_RECONVERTOPTIONS;
47 static UINT WM_MSIME_MOUSE;
48 static UINT WM_MSIME_RECONVERTREQUEST;
49 static UINT WM_MSIME_RECONVERT;
50 static UINT WM_MSIME_QUERYPOSITION;
51 static UINT WM_MSIME_DOCUMENTFEED;
53 /* USER signal proc flags and codes */
54 /* See UserSignalProc for comments */
55 #define USIG_FLAGS_WIN32 0x0001
56 #define USIG_FLAGS_GUI 0x0002
57 #define USIG_FLAGS_FEEDBACK 0x0004
58 #define USIG_FLAGS_FAULT 0x0008
60 #define USIG_DLL_UNLOAD_WIN16 0x0001
61 #define USIG_DLL_UNLOAD_WIN32 0x0002
62 #define USIG_FAULT_DIALOG_PUSH 0x0003
63 #define USIG_FAULT_DIALOG_POP 0x0004
64 #define USIG_DLL_UNLOAD_ORPHANS 0x0005
65 #define USIG_THREAD_INIT 0x0010
66 #define USIG_THREAD_EXIT 0x0020
67 #define USIG_PROCESS_CREATE 0x0100
68 #define USIG_PROCESS_INIT 0x0200
69 #define USIG_PROCESS_EXIT 0x0300
70 #define USIG_PROCESS_DESTROY 0x0400
71 #define USIG_PROCESS_RUNNING 0x0500
72 #define USIG_PROCESS_LOADED 0x0600
74 /***********************************************************************
75 * SignalProc32 (USER.391)
76 * UserSignalProc (USER32.@)
78 * The exact meaning of the USER signals is undocumented, but this
79 * should cover the basic idea:
81 * USIG_DLL_UNLOAD_WIN16
82 * This is sent when a 16-bit module is unloaded.
84 * USIG_DLL_UNLOAD_WIN32
85 * This is sent when a 32-bit module is unloaded.
87 * USIG_DLL_UNLOAD_ORPHANS
88 * This is sent after the last Win3.1 module is unloaded,
89 * to allow removal of orphaned menus.
91 * USIG_FAULT_DIALOG_PUSH
92 * USIG_FAULT_DIALOG_POP
93 * These are called to allow USER to prepare for displaying a
94 * fault dialog, even though the fault might have happened while
95 * inside a USER critical section.
97 * USIG_THREAD_INIT
98 * This is called from the context of a new thread, as soon as it
99 * has started to run.
101 * USIG_THREAD_EXIT
102 * This is called, still in its context, just before a thread is
103 * about to terminate.
105 * USIG_PROCESS_CREATE
106 * This is called, in the parent process context, after a new process
107 * has been created.
109 * USIG_PROCESS_INIT
110 * This is called in the new process context, just after the main thread
111 * has started execution (after the main thread's USIG_THREAD_INIT has
112 * been sent).
114 * USIG_PROCESS_LOADED
115 * This is called after the executable file has been loaded into the
116 * new process context.
118 * USIG_PROCESS_RUNNING
119 * This is called immediately before the main entry point is called.
121 * USIG_PROCESS_EXIT
122 * This is called in the context of a process that is about to
123 * terminate (but before the last thread's USIG_THREAD_EXIT has
124 * been sent).
126 * USIG_PROCESS_DESTROY
127 * This is called after a process has terminated.
130 * The meaning of the dwFlags bits is as follows:
132 * USIG_FLAGS_WIN32
133 * Current process is 32-bit.
135 * USIG_FLAGS_GUI
136 * Current process is a (Win32) GUI process.
138 * USIG_FLAGS_FEEDBACK
139 * Current process needs 'feedback' (determined from the STARTUPINFO
140 * flags STARTF_FORCEONFEEDBACK / STARTF_FORCEOFFFEEDBACK).
142 * USIG_FLAGS_FAULT
143 * The signal is being sent due to a fault.
145 WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
146 DWORD dwFlags, HMODULE16 hModule )
148 FIXME("(%04x, %08x, %04x, %04x)\n",
149 uCode, dwThreadOrProcessID, dwFlags, hModule );
150 /* FIXME: Should chain to GdiSignalProc now. */
151 return 0;
155 /**********************************************************************
156 * SetLastErrorEx [USER32.@]
158 * Sets the last-error code.
160 * RETURNS
161 * None.
163 void WINAPI SetLastErrorEx(
164 DWORD error, /* [in] Per-thread error code */
165 DWORD type) /* [in] Error type */
167 TRACE("(0x%08x, 0x%08x)\n", error,type);
168 switch(type) {
169 case 0:
170 break;
171 case SLE_ERROR:
172 case SLE_MINORERROR:
173 case SLE_WARNING:
174 /* Fall through for now */
175 default:
176 FIXME("(error=%08x, type=%08x): Unhandled type\n", error,type);
177 break;
179 SetLastError( error );
182 /******************************************************************************
183 * GetAltTabInfoA [USER32.@]
185 BOOL WINAPI GetAltTabInfoA(HWND hwnd, int iItem, PALTTABINFO pati, LPSTR pszItemText, UINT cchItemText)
187 FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd, iItem, pati, pszItemText, cchItemText);
188 return FALSE;
191 /******************************************************************************
192 * GetAltTabInfoW [USER32.@]
194 BOOL WINAPI GetAltTabInfoW(HWND hwnd, int iItem, PALTTABINFO pati, LPWSTR pszItemText, UINT cchItemText)
196 FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd, iItem, pati, pszItemText, cchItemText);
197 return FALSE;
200 /******************************************************************************
201 * SetDebugErrorLevel [USER32.@]
202 * Sets the minimum error level for generating debugging events
204 * PARAMS
205 * dwLevel [I] Debugging error level
207 * RETURNS
208 * Nothing.
210 VOID WINAPI SetDebugErrorLevel( DWORD dwLevel )
212 FIXME("(%d): stub\n", dwLevel);
216 /***********************************************************************
217 * SetWindowStationUser (USER32.@)
219 DWORD WINAPI SetWindowStationUser(DWORD x1,DWORD x2)
221 FIXME("(0x%08x,0x%08x),stub!\n",x1,x2);
222 return 1;
225 /***********************************************************************
226 * RegisterLogonProcess (USER32.@)
228 DWORD WINAPI RegisterLogonProcess(HANDLE hprocess,BOOL x)
230 FIXME("(%p,%d),stub!\n",hprocess,x);
231 return 1;
234 /***********************************************************************
235 * SetLogonNotifyWindow (USER32.@)
237 DWORD WINAPI SetLogonNotifyWindow(HWINSTA hwinsta,HWND hwnd)
239 FIXME("(%p,%p),stub!\n",hwinsta,hwnd);
240 return 1;
243 /***********************************************************************
244 * QueryDisplayConfig (USER32.@)
246 LONG WINAPI QueryDisplayConfig(UINT32 flags, UINT32 *numpathelements, DISPLAYCONFIG_PATH_INFO *pathinfo,
247 UINT32 *numinfoelements, DISPLAYCONFIG_MODE_INFO *modeinfo,
248 DISPLAYCONFIG_TOPOLOGY_ID *topologyid)
250 FIXME("(%08x %p %p %p %p %p)\n", flags, numpathelements, pathinfo, numinfoelements, modeinfo, topologyid);
251 return ERROR_CALL_NOT_IMPLEMENTED;
254 /***********************************************************************
255 * RegisterSystemThread (USER32.@)
257 void WINAPI RegisterSystemThread(DWORD flags, DWORD reserved)
259 FIXME("(%08x, %08x)\n", flags, reserved);
262 /***********************************************************************
263 * RegisterShellHookWindow [USER32.@]
265 BOOL WINAPI RegisterShellHookWindow(HWND hWnd)
267 FIXME("(%p): stub\n", hWnd);
268 return FALSE;
272 /***********************************************************************
273 * DeregisterShellHookWindow [USER32.@]
275 BOOL WINAPI DeregisterShellHookWindow(HWND hWnd)
277 FIXME("(%p): stub\n", hWnd);
278 return FALSE;
282 /***********************************************************************
283 * RegisterTasklist [USER32.@]
285 DWORD WINAPI RegisterTasklist (DWORD x)
287 FIXME("0x%08x\n",x);
288 return TRUE;
292 /***********************************************************************
293 * RegisterDeviceNotificationA (USER32.@)
295 * See RegisterDeviceNotificationW.
297 HDEVNOTIFY WINAPI RegisterDeviceNotificationA(HANDLE hnd, LPVOID notifyfilter, DWORD flags)
299 FIXME("(hwnd=%p, filter=%p,flags=0x%08x) returns a fake device notification handle!\n",
300 hnd,notifyfilter,flags );
301 return (HDEVNOTIFY) 0xcafecafe;
304 /***********************************************************************
305 * RegisterDeviceNotificationW (USER32.@)
307 * Registers a window with the system so that it will receive
308 * notifications about a device.
310 * PARAMS
311 * hRecipient [I] Window or service status handle that
312 * will receive notifications.
313 * pNotificationFilter [I] DEV_BROADCAST_HDR followed by some
314 * type-specific data.
315 * dwFlags [I] See notes
317 * RETURNS
319 * A handle to the device notification.
321 * NOTES
323 * The dwFlags parameter can be one of two values:
324 *| DEVICE_NOTIFY_WINDOW_HANDLE - hRecipient is a window handle
325 *| DEVICE_NOTIFY_SERVICE_HANDLE - hRecipient is a service status handle
327 HDEVNOTIFY WINAPI RegisterDeviceNotificationW(HANDLE hRecipient, LPVOID pNotificationFilter, DWORD dwFlags)
329 FIXME("(hwnd=%p, filter=%p,flags=0x%08x) returns a fake device notification handle!\n",
330 hRecipient,pNotificationFilter,dwFlags );
331 return (HDEVNOTIFY) 0xcafeaffe;
334 /***********************************************************************
335 * UnregisterDeviceNotification (USER32.@)
338 BOOL WINAPI UnregisterDeviceNotification(HDEVNOTIFY hnd)
340 FIXME("(handle=%p), STUB!\n", hnd);
341 return TRUE;
344 /***********************************************************************
345 * GetAppCompatFlags (USER32.@)
347 DWORD WINAPI GetAppCompatFlags( HTASK hTask )
349 FIXME("(%p) stub\n", hTask);
350 return 0;
353 /***********************************************************************
354 * GetAppCompatFlags2 (USER32.@)
356 DWORD WINAPI GetAppCompatFlags2( HTASK hTask )
358 FIXME("(%p) stub\n", hTask);
359 return 0;
363 /***********************************************************************
364 * AlignRects (USER32.@)
366 BOOL WINAPI AlignRects(LPRECT rect, DWORD b, DWORD c, DWORD d)
368 FIXME("(%p, %d, %d, %d): stub\n", rect, b, c, d);
369 if (rect)
370 FIXME("rect: %s\n", wine_dbgstr_rect(rect));
371 /* Calls OffsetRect */
372 return FALSE;
376 /***********************************************************************
377 * LoadLocalFonts (USER32.@)
379 VOID WINAPI LoadLocalFonts(VOID)
381 /* are loaded. */
382 return;
386 /***********************************************************************
387 * User32InitializeImmEntryTable
389 BOOL WINAPI User32InitializeImmEntryTable(DWORD magic)
391 static const WCHAR imm32_dllW[] = {'i','m','m','3','2','.','d','l','l',0};
392 HMODULE imm32 = GetModuleHandleW(imm32_dllW);
394 TRACE("(%x)\n", magic);
396 if (!imm32 || magic != IMM_INIT_MAGIC)
397 return FALSE;
399 if (imm_get_ui_window)
400 return TRUE;
402 WM_MSIME_SERVICE = RegisterWindowMessageA("MSIMEService");
403 WM_MSIME_RECONVERTOPTIONS = RegisterWindowMessageA("MSIMEReconvertOptions");
404 WM_MSIME_MOUSE = RegisterWindowMessageA("MSIMEMouseOperation");
405 WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageA("MSIMEReconvertRequest");
406 WM_MSIME_RECONVERT = RegisterWindowMessageA("MSIMEReconvert");
407 WM_MSIME_QUERYPOSITION = RegisterWindowMessageA("MSIMEQueryPosition");
408 WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed");
410 /* this part is not compatible with native imm32.dll */
411 imm_get_ui_window = (void*)GetProcAddress(imm32, "__wine_get_ui_window");
412 imm_register_window = (void*)GetProcAddress(imm32, "__wine_register_window");
413 imm_unregister_window = (void*)GetProcAddress(imm32, "__wine_unregister_window");
414 if (!imm_get_ui_window)
415 FIXME("native imm32.dll not supported\n");
416 return TRUE;
419 /**********************************************************************
420 * WINNLSGetIMEHotkey [USER32.@]
423 UINT WINAPI WINNLSGetIMEHotkey(HWND hwnd)
425 FIXME("hwnd %p: stub!\n", hwnd);
426 return 0; /* unknown */
429 /**********************************************************************
430 * WINNLSEnableIME [USER32.@]
433 BOOL WINAPI WINNLSEnableIME(HWND hwnd, BOOL enable)
435 FIXME("hwnd %p enable %d: stub!\n", hwnd, enable);
436 return TRUE; /* success (?) */
439 /**********************************************************************
440 * WINNLSGetEnableStatus [USER32.@]
443 BOOL WINAPI WINNLSGetEnableStatus(HWND hwnd)
445 FIXME("hwnd %p: stub!\n", hwnd);
446 return TRUE; /* success (?) */
449 /**********************************************************************
450 * SendIMEMessageExA [USER32.@]
453 LRESULT WINAPI SendIMEMessageExA(HWND hwnd, LPARAM lparam)
455 FIXME("(%p,%lx): stub\n", hwnd, lparam);
456 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
457 return 0;
460 /**********************************************************************
461 * SendIMEMessageExW [USER32.@]
464 LRESULT WINAPI SendIMEMessageExW(HWND hwnd, LPARAM lparam)
466 FIXME("(%p,%lx): stub\n", hwnd, lparam);
467 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
468 return 0;
471 /**********************************************************************
472 * DisableProcessWindowsGhosting [USER32.@]
475 VOID WINAPI DisableProcessWindowsGhosting(VOID)
477 FIXME(": stub\n");
478 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
479 return;
482 /**********************************************************************
483 * UserHandleGrantAccess [USER32.@]
486 BOOL WINAPI UserHandleGrantAccess(HANDLE handle, HANDLE job, BOOL grant)
488 FIXME("(%p,%p,%d): stub\n", handle, job, grant);
489 return TRUE;
492 /**********************************************************************
493 * RegisterPowerSettingNotification [USER32.@]
495 HPOWERNOTIFY WINAPI RegisterPowerSettingNotification(HANDLE recipient, const GUID *guid, DWORD flags)
497 FIXME("(%p,%s,%x): stub\n", recipient, debugstr_guid(guid), flags);
498 return (HPOWERNOTIFY)0xdeadbeef;
501 /**********************************************************************
502 * UnregisterPowerSettingNotification [USER32.@]
504 BOOL WINAPI UnregisterPowerSettingNotification(HPOWERNOTIFY handle)
506 FIXME("(%p): stub\n", handle);
507 return TRUE;
510 /*****************************************************************************
511 * GetGestureConfig (USER32.@)
513 BOOL WINAPI GetGestureConfig( HWND hwnd, DWORD reserved, DWORD flags, UINT *count, GESTURECONFIG *config, UINT size )
515 FIXME("(%p %08x %08x %p %p %u): stub\n", hwnd, reserved, flags, count, config, size);
516 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
517 return FALSE;
520 /**********************************************************************
521 * SetGestureConfig [USER32.@]
523 BOOL WINAPI SetGestureConfig( HWND hwnd, DWORD reserved, UINT id, PGESTURECONFIG config, UINT size )
525 FIXME("(%p %08x %u %p %u): stub\n", hwnd, reserved, id, config, size);
526 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
527 return FALSE;
530 /**********************************************************************
531 * IsTouchWindow [USER32.@]
533 BOOL WINAPI IsTouchWindow( HWND hwnd, PULONG flags )
535 FIXME("(%p %p): stub\n", hwnd, flags);
536 return FALSE;
539 /**********************************************************************
540 * IsWindowRedirectedForPrint [USER32.@]
542 BOOL WINAPI IsWindowRedirectedForPrint( HWND hwnd )
544 FIXME("(%p): stub\n", hwnd);
545 return FALSE;
548 /**********************************************************************
549 * GetDisplayConfigBufferSizes [USER32.@]
551 LONG WINAPI GetDisplayConfigBufferSizes(UINT32 flags, UINT32 *num_path_info, UINT32 *num_mode_info)
553 FIXME("(0x%x %p %p): stub\n", flags, num_path_info, num_mode_info);
555 if (!num_path_info || !num_mode_info)
556 return ERROR_INVALID_PARAMETER;
558 *num_path_info = 0;
559 *num_mode_info = 0;
560 return ERROR_NOT_SUPPORTED;
563 /**********************************************************************
564 * RegisterPointerDeviceNotifications [USER32.@]
566 BOOL WINAPI RegisterPointerDeviceNotifications(HWND hwnd, BOOL notifyrange)
568 FIXME("(%p %d): stub\n", hwnd, notifyrange);
569 return TRUE;
572 /**********************************************************************
573 * GetPointerDevices [USER32.@]
575 BOOL WINAPI GetPointerDevices(UINT32 *device_count, POINTER_DEVICE_INFO *devices)
577 FIXME("(%p %p): partial stub\n", device_count, devices);
579 if (!device_count)
580 return FALSE;
582 if (devices)
583 return FALSE;
585 *device_count = 0;
586 return TRUE;
589 /**********************************************************************
590 * RegisterTouchHitTestingWindow [USER32.@]
592 BOOL WINAPI RegisterTouchHitTestingWindow(HWND hwnd, ULONG value)
594 FIXME("(%p %d): stub\n", hwnd, value);
595 return TRUE;
598 /**********************************************************************
599 * GetPointerType [USER32.@]
601 BOOL WINAPI GetPointerType(UINT32 id, POINTER_INPUT_TYPE *type)
603 FIXME("(%d %p): stub\n", id, type);
605 if(!id || !type)
607 SetLastError(ERROR_INVALID_PARAMETER);
608 return FALSE;
611 *type = PT_MOUSE;
612 return TRUE;
615 static const WCHAR imeW[] = {'I','M','E',0};
616 const struct builtin_class_descr IME_builtin_class =
618 imeW, /* name */
619 0, /* style */
620 WINPROC_IME, /* proc */
621 2*sizeof(LONG_PTR), /* extra */
622 IDC_ARROW, /* cursor */
623 0 /* brush */
626 static BOOL is_ime_ui_msg( UINT msg )
628 switch(msg) {
629 case WM_IME_STARTCOMPOSITION:
630 case WM_IME_ENDCOMPOSITION:
631 case WM_IME_COMPOSITION:
632 case WM_IME_SETCONTEXT:
633 case WM_IME_NOTIFY:
634 case WM_IME_CONTROL:
635 case WM_IME_COMPOSITIONFULL:
636 case WM_IME_SELECT:
637 case WM_IME_CHAR:
638 case WM_IME_REQUEST:
639 case WM_IME_KEYDOWN:
640 case WM_IME_KEYUP:
641 return TRUE;
642 default:
643 if ((msg == WM_MSIME_RECONVERTOPTIONS) ||
644 (msg == WM_MSIME_SERVICE) ||
645 (msg == WM_MSIME_MOUSE) ||
646 (msg == WM_MSIME_RECONVERTREQUEST) ||
647 (msg == WM_MSIME_RECONVERT) ||
648 (msg == WM_MSIME_QUERYPOSITION) ||
649 (msg == WM_MSIME_DOCUMENTFEED))
650 return TRUE;
652 return FALSE;
656 LRESULT WINAPI ImeWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
658 HWND uiwnd;
660 if (msg==WM_CREATE)
661 return TRUE;
663 if (imm_get_ui_window && is_ime_ui_msg(msg))
665 if ((uiwnd = imm_get_ui_window(GetKeyboardLayout(0))))
666 return SendMessageA(uiwnd, msg, wParam, lParam);
667 return FALSE;
670 return DefWindowProcA(hwnd, msg, wParam, lParam);
673 LRESULT WINAPI ImeWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
675 HWND uiwnd;
677 if (msg==WM_CREATE)
678 return TRUE;
680 if (imm_get_ui_window && is_ime_ui_msg(msg))
682 if ((uiwnd = imm_get_ui_window(GetKeyboardLayout(0))))
683 return SendMessageW(uiwnd, msg, wParam, lParam);
684 return FALSE;
687 return DefWindowProcW(hwnd, msg, wParam, lParam);