ReactOS 0.4.15-dev-7693-gd0e2924
misc.c File Reference
#include <win32k.h>
Include dependency graph for misc.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (UserMisc)
 
int __cdecl _scwprintf (const wchar_t *format,...)
 
PTHREADINFO FASTCALL IntTID2PTI (HANDLE id)
 
DWORD FASTCALL UserGetLanguageToggle (_In_ PCWSTR pszType, _In_ DWORD dwDefaultValue)
 
USHORT FASTCALL UserGetLanguageID (VOID)
 
HBRUSH FASTCALL GetControlColor (PWND pwndParent, PWND pwnd, HDC hdc, UINT CtlMsg)
 
HBRUSH FASTCALL GetControlBrush (PWND pwnd, HDC hdc, UINT ctlType)
 
HBRUSH APIENTRY NtUserGetControlBrush (HWND hwnd, HDC hdc, UINT ctlType)
 
HBRUSH APIENTRY NtUserGetControlColor (HWND hwndParent, HWND hwnd, HDC hdc, UINT CtlMsg)
 
DWORD_PTR APIENTRY NtUserGetThreadState (DWORD Routine)
 
DWORD APIENTRY NtUserSetThreadState (DWORD Set, DWORD Flags)
 
UINT APIENTRY NtUserGetDoubleClickTime (VOID)
 
BOOL APIENTRY NtUserGetGUIThreadInfo (DWORD idThread, LPGUITHREADINFO lpgui)
 
DWORD APIENTRY NtUserGetGuiResources (HANDLE hProcess, DWORD uiFlags)
 
VOID FASTCALL IntSetWindowState (PWND pWnd, UINT Flag)
 
VOID FASTCALL IntClearWindowState (PWND pWnd, UINT Flag)
 
NTSTATUS FASTCALL IntSafeCopyUnicodeString (PUNICODE_STRING Dest, PUNICODE_STRING Source)
 
NTSTATUS FASTCALL IntSafeCopyUnicodeStringTerminateNULL (PUNICODE_STRING Dest, PUNICODE_STRING Source)
 
void UserDbgAssertThreadInfo (BOOL showCaller)
 
void NTAPI UserDbgPreServiceHook (ULONG ulSyscallId, PULONG_PTR pulArguments)
 
ULONG_PTR NTAPI UserDbgPostServiceHook (ULONG ulSyscallId, ULONG_PTR ulResult)
 
PPROCESSINFO GetW32ProcessInfo (VOID)
 
PTHREADINFO GetW32ThreadInfo (VOID)
 
NTSTATUS GetProcessLuid (IN PETHREAD Thread OPTIONAL, IN PEPROCESS Process OPTIONAL, OUT PLUID Luid)
 

Function Documentation

◆ _scwprintf()

int __cdecl _scwprintf ( const wchar_t format,
  ... 
)

Definition at line 21 of file misc.c.

24{
25 int len;
27
30 va_end(args);
31
32 return len;
33}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_ _CRTIMP int __cdecl _vscwprintf(_In_z_ _Printf_format_string_ const wchar_t *_Format, va_list _ArgList)
#define args
Definition: format.c:66
Definition: match.c:390

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserMisc  )

◆ GetControlBrush()

HBRUSH FASTCALL GetControlBrush ( PWND  pwnd,
HDC  hdc,
UINT  ctlType 
)

Definition at line 180 of file misc.c.

184{
185 PWND pwndParent = IntGetParent(pwnd);
186 return GetControlColor( pwndParent, pwnd, hdc, ctlType);
187}
HDC hdc
Definition: main.c:9
Definition: ntuser.h:694
HBRUSH FASTCALL GetControlColor(PWND pwndParent, PWND pwnd, HDC hdc, UINT CtlMsg)
Definition: misc.c:154
PWND FASTCALL IntGetParent(PWND Wnd)
Definition: window.c:204

Referenced by EDIT_NotifyCtlColor(), IntDrawScrollInterior(), NtUserGetControlBrush(), and STATIC_SendWmCtlColorStatic().

◆ GetControlColor()

HBRUSH FASTCALL GetControlColor ( PWND  pwndParent,
PWND  pwnd,
HDC  hdc,
UINT  CtlMsg 
)

Definition at line 154 of file misc.c.

159{
160 HBRUSH hBrush;
161
162 if (!pwndParent) pwndParent = pwnd;
163
164 if ( pwndParent->head.pti->ppi != PsGetCurrentProcessWin32Process())
165 {
166 return (HBRUSH)IntDefWindowProc( pwndParent, CtlMsg, (WPARAM)hdc, (LPARAM)UserHMGetHandle(pwnd), FALSE);
167 }
168
169 hBrush = (HBRUSH)co_IntSendMessage( UserHMGetHandle(pwndParent), CtlMsg, (WPARAM)hdc, (LPARAM)UserHMGetHandle(pwnd));
170
171 if (!hBrush || !GreIsHandleValid(hBrush))
172 {
173 hBrush = (HBRUSH)IntDefWindowProc( pwndParent, CtlMsg, (WPARAM)hdc, (LPARAM)UserHMGetHandle(pwnd), FALSE);
174 }
175 return hBrush;
176}
#define FALSE
Definition: types.h:117
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
LRESULT FASTCALL IntDefWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Ansi)
Definition: defwnd.c:535
THRDESKHEAD head
Definition: ntuser.h:695
BOOL NTAPI GreIsHandleValid(HGDIOBJ hobj)
Definition: gdiobj.c:1146
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1445
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207

Referenced by ButtonWndProc_common(), CB_Paint(), COMBO_PrepareColors(), DEFDLG_Proc(), GB_Paint(), GetControlBrush(), IntFillWindow(), LISTBOX_Paint(), LISTBOX_RepaintItem(), ListBoxWndProc_common(), NtUserGetControlColor(), OB_Paint(), PB_Paint(), and UB_Paint().

◆ GetProcessLuid()

NTSTATUS GetProcessLuid ( IN PETHREAD Thread  OPTIONAL,
IN PEPROCESS Process  OPTIONAL,
OUT PLUID  Luid 
)

Definition at line 813 of file misc.c.

817{
822
823 if (Thread && Process)
825
826 /* If nothing has been specified, use the current thread */
827 if (!Thread && !Process)
829
830 if (Thread)
831 {
832 /* Use a thread token */
833 ASSERT(!Process);
835 &CopyOnOpen,
838
839 /* If we don't have a thread token, use a process token */
840 if (!Token)
842 }
843 if (!Token && Process)
844 {
845 /* Use a process token */
847
848 /* If we don't have a token, fail */
849 if (!Token)
850 return STATUS_NO_TOKEN;
851 }
852 ASSERT(Token);
853
854 /* Query the LUID */
856
857 /* Get rid of the token and return */
859 return Status;
860}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
PEPROCESS __stdcall PsGetThreadProcess(_In_ PETHREAD Thread)
#define NULL
Definition: types.h:112
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
Status
Definition: gdiplustypes.h:25
enum _SECURITY_IMPERSONATION_LEVEL SECURITY_IMPERSONATION_LEVEL
#define ASSERT(a)
Definition: mode.c:44
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_ BOOLEAN EffectiveOnly
Definition: sefuncs.h:410
PACCESS_TOKEN NTAPI PsReferencePrimaryToken(PEPROCESS Process)
Definition: security.c:440
PACCESS_TOKEN NTAPI PsReferenceImpersonationToken(IN PETHREAD Thread, OUT PBOOLEAN CopyOnOpen, OUT PBOOLEAN EffectiveOnly, OUT PSECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
Definition: security.c:871
NTSTATUS NTAPI SeQueryAuthenticationIdToken(_In_ PACCESS_TOKEN Token, _Out_ PLUID LogonId)
Queries the authentication ID of an access token.
Definition: token.c:2036
#define STATUS_NO_TOKEN
Definition: ntstatus.h:360
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define ObDereferenceObject
Definition: obfuncs.h:203
_Out_ PBOOLEAN CopyOnOpen
Definition: psfuncs.h:154
_Out_ PBOOLEAN _Out_ PBOOLEAN _Out_ PSECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: psfuncs.h:156

Referenced by BuildUserModeWindowStationName(), IntResolveDesktop(), UserEndShutdown(), and UserInitiateShutdown().

◆ GetW32ProcessInfo()

◆ GetW32ThreadInfo()

PTHREADINFO GetW32ThreadInfo ( VOID  )

Definition at line 805 of file misc.c.

806{
809}
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
void UserDbgAssertThreadInfo(BOOL showCaller)
Definition: misc.c:732

Referenced by NtUserGetThreadState().

◆ IntClearWindowState()

VOID FASTCALL IntClearWindowState ( PWND  pWnd,
UINT  Flag 
)

Definition at line 616 of file misc.c.

617{
618 UINT bit;
619 if (gptiCurrent->ppi != pWnd->head.pti->ppi) return;
620 bit = 1 << LOWORD(Flag);
621 TRACE("CWS %x\n",bit);
622 switch(HIWORD(Flag))
623 {
624 case 0:
625 pWnd->state &= ~bit;
626 break;
627 case 1:
628 pWnd->state2 &= ~bit;
629 break;
630 case 2:
631 pWnd->ExStyle2 &= ~bit;
632 break;
633 }
634}
unsigned int UINT
Definition: ndis.h:50
PTHREADINFO gptiCurrent
Definition: ntuser.c:15
#define LOWORD(l)
Definition: pedump.c:82
#define TRACE(s)
Definition: solgame.cpp:4
Definition: xml2sdb.h:80
PPROCESSINFO ppi
Definition: win32.h:88
DWORD ExStyle2
Definition: ntuser.h:745
DWORD state2
Definition: ntuser.h:702
DWORD state
Definition: ntuser.h:701
#define HIWORD(l)
Definition: typedefs.h:247

Referenced by NtUserCallHwndParam().

◆ IntSafeCopyUnicodeString()

NTSTATUS FASTCALL IntSafeCopyUnicodeString ( PUNICODE_STRING  Dest,
PUNICODE_STRING  Source 
)

Definition at line 637 of file misc.c.

639{
641 PWSTR Src;
642
644 if(!NT_SUCCESS(Status))
645 {
646 return Status;
647 }
648
649 if(Dest->Length > 0x4000)
650 {
651 return STATUS_UNSUCCESSFUL;
652 }
653
654 Src = Dest->Buffer;
655 Dest->Buffer = NULL;
656 Dest->MaximumLength = Dest->Length;
657
658 if(Dest->Length > 0 && Src)
659 {
661 if(!Dest->Buffer)
662 {
663 return STATUS_NO_MEMORY;
664 }
665
666 Status = MmCopyFromCaller(Dest->Buffer, Src, Dest->Length);
667 if(!NT_SUCCESS(Status))
668 {
670 Dest->Buffer = NULL;
671 return Status;
672 }
673
674
675 return STATUS_SUCCESS;
676 }
677
678 /* String is empty */
679 return STATUS_SUCCESS;
680}
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define TAG_STRING
Definition: oslist.h:22
#define MmCopyFromCaller
Definition: polytest.cpp:29
#define STATUS_SUCCESS
Definition: shellext.h:65
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWSTR
Definition: typedefs.h:56
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

◆ IntSafeCopyUnicodeStringTerminateNULL()

NTSTATUS FASTCALL IntSafeCopyUnicodeStringTerminateNULL ( PUNICODE_STRING  Dest,
PUNICODE_STRING  Source 
)

Definition at line 683 of file misc.c.

685{
687 PWSTR Src;
688
690 if(!NT_SUCCESS(Status))
691 {
692 return Status;
693 }
694
695 if(Dest->Length > 0x4000)
696 {
697 return STATUS_UNSUCCESSFUL;
698 }
699
700 Src = Dest->Buffer;
701 Dest->Buffer = NULL;
702 Dest->MaximumLength = 0;
703
704 if(Dest->Length > 0 && Src)
705 {
706 Dest->MaximumLength = Dest->Length + sizeof(WCHAR);
708 if(!Dest->Buffer)
709 {
710 return STATUS_NO_MEMORY;
711 }
712
713 Status = MmCopyFromCaller(Dest->Buffer, Src, Dest->Length);
714 if(!NT_SUCCESS(Status))
715 {
717 Dest->Buffer = NULL;
718 return Status;
719 }
720
721 /* Make sure the string is null-terminated */
722 Src = (PWSTR)((PBYTE)Dest->Buffer + Dest->Length);
723 *Src = L'\0';
724
725 return STATUS_SUCCESS;
726 }
727
728 /* String is empty */
729 return STATUS_SUCCESS;
730}
#define L(x)
Definition: ntvdm.h:50
BYTE * PBYTE
Definition: pedump.c:66
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by InitThreadCallback(), and NtUserRegisterWindowMessage().

◆ IntSetWindowState()

VOID FASTCALL IntSetWindowState ( PWND  pWnd,
UINT  Flag 
)

Definition at line 595 of file misc.c.

596{
597 UINT bit;
598 if (gptiCurrent->ppi != pWnd->head.pti->ppi) return;
599 bit = 1 << LOWORD(Flag);
600 TRACE("SWS %x\n",bit);
601 switch(HIWORD(Flag))
602 {
603 case 0:
604 pWnd->state |= bit;
605 break;
606 case 1:
607 pWnd->state2 |= bit;
608 break;
609 case 2:
610 pWnd->ExStyle2 |= bit;
611 break;
612 }
613}

Referenced by NtUserCallHwndParam().

◆ IntTID2PTI()

PTHREADINFO FASTCALL IntTID2PTI ( HANDLE  id)

Definition at line 42 of file misc.c.

43{
46 PTHREADINFO pti;
48 if (!NT_SUCCESS(Status))
49 {
50 return NULL;
51 }
53 {
55 return NULL;
56 }
58 if (!pti)
59 {
61 return NULL;
62 }
63 // Validate and verify!
65 {
66 if (pti->TIF_flags & TIF_INCLEANUP) pti = NULL;
67 if (pti && !(pti->TIF_flags & TIF_GUITHREADINITIALIZED)) pti = NULL;
68 if (PsGetThreadId(Thread) != id) pti = NULL;
69 }
71 {
72 pti = NULL;
73 }
76 return pti;
77}
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define TIF_INCLEANUP
Definition: ntuser.h:263
#define TIF_GUITHREADINITIALIZED
Definition: ntuser.h:287
HANDLE NTAPI PsGetThreadId(IN PETHREAD Thread)
Definition: thread.c:705
NTSTATUS NTAPI PsLookupThreadByThreadId(IN HANDLE ThreadId, OUT PETHREAD *Thread)
Definition: thread.c:643
PVOID NTAPI PsGetThreadWin32Thread(IN PETHREAD Thread)
Definition: thread.c:795
BOOLEAN NTAPI PsIsThreadTerminating(IN PETHREAD Thread)
Definition: thread.c:868
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
FLONG TIF_flags
Definition: win32.h:95

Referenced by NtUserAttachThreadInput(), NtUserBuildHimcList(), NtUserDisableThreadIme(), NtUserGetGUIThreadInfo(), NtUserGetThreadDesktop(), NtUserGetThreadState(), and NtUserSetWindowsHookEx().

◆ NtUserGetControlBrush()

HBRUSH APIENTRY NtUserGetControlBrush ( HWND  hwnd,
HDC  hdc,
UINT  ctlType 
)

Definition at line 191 of file misc.c.

195{
196 PWND pwnd;
197 HBRUSH hBrush = NULL;
198
200 if ( (pwnd = UserGetWindowObject(hwnd)) &&
201 ((ctlType - WM_CTLCOLORMSGBOX) < CTLCOLOR_MAX) &&
202 hdc )
203 {
204 hBrush = GetControlBrush(pwnd, hdc, ctlType);
205 }
206 UserLeave();
207 return hBrush;
208}
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:251
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:242
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:122
HBRUSH FASTCALL GetControlBrush(PWND pwnd, HDC hdc, UINT ctlType)
Definition: misc.c:180
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define WM_CTLCOLORMSGBOX
Definition: winuser.h:1765
#define CTLCOLOR_MAX
Definition: winuser.h:957

Referenced by GetControlBrush().

◆ NtUserGetControlColor()

HBRUSH APIENTRY NtUserGetControlColor ( HWND  hwndParent,
HWND  hwnd,
HDC  hdc,
UINT  CtlMsg 
)

Definition at line 215 of file misc.c.

220{
221 PWND pwnd, pwndParent = NULL;
222 HBRUSH hBrush = NULL;
223
225 if ( (pwnd = UserGetWindowObject(hwnd)) &&
226 ((CtlMsg - WM_CTLCOLORMSGBOX) < CTLCOLOR_MAX) &&
227 hdc )
228 {
229 if (hwndParent) pwndParent = UserGetWindowObject(hwndParent);
230 hBrush = GetControlColor( pwndParent, pwnd, hdc, CtlMsg);
231 }
232 UserLeave();
233 return hBrush;
234}
static HWND hwndParent
Definition: cryptui.c:300

Referenced by GetControlColor().

◆ NtUserGetDoubleClickTime()

UINT APIENTRY NtUserGetDoubleClickTime ( VOID  )

Definition at line 386 of file misc.c.

387{
388 UINT Result;
389
390 TRACE("Enter NtUserGetDoubleClickTime\n");
392
393 // FIXME: Check if this works on non-interactive winsta
395
396 TRACE("Leave NtUserGetDoubleClickTime, ret=%u\n", Result);
397 UserLeave();
398 return Result;
399}
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:235
INT iDblClickTime
Definition: sysparams.h:90
SPIVALUES gspv
Definition: sysparams.c:17
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by GetDoubleClickTime().

◆ NtUserGetGuiResources()

DWORD APIENTRY NtUserGetGuiResources ( HANDLE  hProcess,
DWORD  uiFlags 
)

Definition at line 534 of file misc.c.

537{
539 PPROCESSINFO W32Process;
541 DWORD Ret = 0;
542
543 TRACE("Enter NtUserGetGuiResources\n");
545
550 (PVOID*)&Process,
551 NULL);
552
553 if(!NT_SUCCESS(Status))
554 {
556 goto Exit; // Return 0
557 }
558
559 W32Process = (PPROCESSINFO)Process->Win32Process;
560 if(!W32Process)
561 {
564 goto Exit; // Return 0
565 }
566
567 switch(uiFlags)
568 {
569 case GR_GDIOBJECTS:
570 {
571 Ret = (DWORD)W32Process->GDIHandleCount;
572 break;
573 }
574 case GR_USEROBJECTS:
575 {
576 Ret = (DWORD)W32Process->UserHandleCount;
577 break;
578 }
579 default:
580 {
582 break;
583 }
584 }
585
587
588Exit:
589 TRACE("Leave NtUserGetGuiResources, ret=%lu\n", Ret);
590 UserLeave();
591 return Ret;
592}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ExGetPreviousMode
Definition: ex.h:140
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:166
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define DWORD
Definition: nt_native.h:44
POBJECT_TYPE PsProcessType
Definition: process.c:20
struct _PROCESSINFO * PPROCESSINFO
Definition: ntwin32.h:5
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
static void Exit(void)
Definition: sock.c:1330
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22

Referenced by GetGuiResources().

◆ NtUserGetGUIThreadInfo()

BOOL APIENTRY NtUserGetGUIThreadInfo ( DWORD  idThread,
LPGUITHREADINFO  lpgui 
)

Definition at line 403 of file misc.c.

406{
408 PTHRDCARETINFO CaretInfo;
409 GUITHREADINFO SafeGui;
411 PUSER_MESSAGE_QUEUE MsgQueue;
412 PTHREADINFO W32Thread, pti;
413 BOOL Ret = FALSE;
414
415 TRACE("Enter NtUserGetGUIThreadInfo\n");
417
418 Status = MmCopyFromCaller(&SafeGui, lpgui, sizeof(DWORD));
419 if(!NT_SUCCESS(Status))
420 {
422 goto Exit; // Return FALSE
423 }
424
425 if(SafeGui.cbSize != sizeof(GUITHREADINFO))
426 {
428 goto Exit; // Return FALSE
429 }
430
431 if (idThread)
432 {
434
435 // Validate Tread ID
436 W32Thread = IntTID2PTI((HANDLE)(DWORD_PTR)idThread);
437
438 if ( !W32Thread )
439 {
441 goto Exit; // Return FALSE
442 }
443
444 Desktop = W32Thread->rpdesk;
445
446 // Check Desktop and it must be the same as current.
447 if ( !Desktop || Desktop != pti->rpdesk )
448 {
450 goto Exit; // Return FALSE
451 }
452
453 if ( W32Thread->MessageQueue )
454 MsgQueue = W32Thread->MessageQueue;
455 else
456 {
457 MsgQueue = Desktop->ActiveMessageQueue;
458 }
459 }
460 else
461 { /* Get the foreground thread */
462 /* FIXME: Handle NULL queue properly? */
463 MsgQueue = IntGetFocusMessageQueue();
464 if(!MsgQueue)
465 {
467 goto Exit; // Return FALSE
468 }
469 }
470
471 CaretInfo = &MsgQueue->CaretInfo;
472
473 SafeGui.flags = (CaretInfo->Visible ? GUI_CARETBLINKING : 0);
474/*
475 if (W32Thread->pMenuState->pGlobalPopupMenu)
476 {
477 SafeGui.flags |= GUI_INMENUMODE;
478
479 if (W32Thread->pMenuState->pGlobalPopupMenu->spwndNotify)
480 SafeGui.hwndMenuOwner = UserHMGetHandle(W32Thread->pMenuState->pGlobalPopupMenu->spwndNotify);
481
482 if (W32Thread->pMenuState->pGlobalPopupMenu->fHasMenuBar)
483 {
484 if (W32Thread->pMenuState->pGlobalPopupMenu->fIsSysMenu)
485 {
486 SafeGui.flags |= GUI_SYSTEMMENUMODE;
487 }
488 }
489 else
490 {
491 SafeGui.flags |= GUI_POPUPMENUMODE;
492 }
493 }
494 */
495 SafeGui.hwndMenuOwner = MsgQueue->MenuOwner;
496
497 if (MsgQueue->MenuOwner)
498 SafeGui.flags |= GUI_INMENUMODE | MsgQueue->MenuState;
499
500 if (MsgQueue->MoveSize)
501 SafeGui.flags |= GUI_INMOVESIZE;
502
503 /* FIXME: Add flag GUI_16BITTASK */
504
505 SafeGui.hwndActive = MsgQueue->spwndActive ? UserHMGetHandle(MsgQueue->spwndActive) : 0;
506 SafeGui.hwndFocus = MsgQueue->spwndFocus ? UserHMGetHandle(MsgQueue->spwndFocus) : 0;
507 SafeGui.hwndCapture = MsgQueue->spwndCapture ? UserHMGetHandle(MsgQueue->spwndCapture) : 0;
508 SafeGui.hwndMoveSize = MsgQueue->MoveSize;
509 SafeGui.hwndCaret = CaretInfo->hWnd;
510
511 SafeGui.rcCaret.left = CaretInfo->Pos.x;
512 SafeGui.rcCaret.top = CaretInfo->Pos.y;
513 SafeGui.rcCaret.right = SafeGui.rcCaret.left + CaretInfo->Size.cx;
514 SafeGui.rcCaret.bottom = SafeGui.rcCaret.top + CaretInfo->Size.cy;
515
516 Status = MmCopyToCaller(lpgui, &SafeGui, sizeof(GUITHREADINFO));
517 if(!NT_SUCCESS(Status))
518 {
520 goto Exit; // Return FALSE
521 }
522
523 Ret = TRUE;
524
525Exit:
526 TRACE("Leave NtUserGetGUIThreadInfo, ret=%i\n", Ret);
527 UserLeave();
528 return Ret;
529}
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
struct _DESKTOP * rpdesk
Definition: win32.h:92
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:89
THRDCARETINFO CaretInfo
Definition: msgqueue.h:92
HWND hwndCaret
Definition: winable.h:77
HWND hwndFocus
Definition: winable.h:73
HWND hwndMenuOwner
Definition: winable.h:75
HWND hwndMoveSize
Definition: winable.h:76
DWORD cbSize
Definition: winable.h:70
HWND hwndCapture
Definition: winable.h:74
HWND hwndActive
Definition: winable.h:72
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
uint32_t DWORD_PTR
Definition: typedefs.h:65
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID)
Definition: desktop.c:1307
PTHREADINFO FASTCALL IntTID2PTI(HANDLE id)
Definition: misc.c:42
#define GUI_INMENUMODE
Definition: winable.h:29
#define GUI_CARETBLINKING
Definition: winable.h:27
#define GUI_INMOVESIZE
Definition: winable.h:28

Referenced by GetGUIThreadInfo().

◆ NtUserGetThreadState()

DWORD_PTR APIENTRY NtUserGetThreadState ( DWORD  Routine)

Definition at line 240 of file misc.c.

242{
243 DWORD_PTR ret = 0;
244 PTHREADINFO pti;
245
246 TRACE("Enter NtUserGetThreadState\n");
247 if (Routine != THREADSTATE_GETTHREADINFO)
248 {
250 }
251 else
252 {
254 }
255
257
258 switch (Routine)
259 {
261 ret = TRUE;
262 break;
265 break;
267 /* FIXME: Should use UserEnterShared */
269 break;
270 case THREADSTATE_PROGMANWINDOW: /* FIXME: Delete this HACK */
271 ret = (DWORD_PTR)GetW32ThreadInfo()->pDeskInfo->hProgmanWindow;
272 break;
273 case THREADSTATE_TASKMANWINDOW: /* FIXME: Delete this HACK */
274 ret = (DWORD_PTR)GetW32ThreadInfo()->pDeskInfo->hTaskManWindow;
275 break;
278 break;
280 {
283 TRACE("THREADSTATE_INSENDMESSAGE\n");
284
285 ret = ISMEX_NOSEND;
286 if (Message)
287 {
288 if (Message->ptiSender)
289 ret = ISMEX_SEND;
290 else
291 {
292 if (Message->CompletionCallback)
293 ret = ISMEX_CALLBACK;
294 else
295 ret = ISMEX_NOTIFY;
296 }
297 /* If ReplyMessage */
298 if (Message->QS_Flags & QS_SMRESULT) ret |= ISMEX_REPLIED;
299 }
300
301 break;
302 }
305 break;
306
308 pti->pcti->timeLastRead = EngGetTickCount32();
309 break;
310
313 break;
314
317 break;
319 ret = (DWORD_PTR) (GetW32ThreadInfo()->MessageQueue->CursorObject ?
320 UserHMGetHandle(GetW32ThreadInfo()->MessageQueue->CursorObject) : 0);
321 break;
324 break;
326 if (pti->spwndDefaultIme)
328 break;
330 if (pti->spDefaultImc)
332 break;
334 ret = pti->pcti->fsChangeBits;
335 break;
337 ret = pti->ppi->dwImeCompatFlags;
338 break;
340 ret = (ULONG_PTR)pti->hklPrev;
341 break;
345 break;
347 ret = (IntTID2PTI(UlongToHandle(pti->rpdesk->dwConsoleThreadId)) == pti);
348 break;
349 }
350
351 TRACE("Leave NtUserGetThreadState, ret=%lu\n", ret);
352 UserLeave();
353
354 return ret;
355}
#define UlongToHandle(ul)
Definition: basetsd.h:97
static const WCHAR Message[]
Definition: register.c:74
#define ULONG_PTR
Definition: config.h:101
#define EngGetTickCount32()
Definition: eng.h:43
HWND FASTCALL IntGetThreadFocusWindow(VOID)
Definition: focus.c:41
PUSER_MESSAGE_QUEUE gpqForeground
Definition: focus.c:13
HWND APIENTRY IntGetCapture(VOID)
Definition: focus.c:1440
HWND FASTCALL UserGetActiveWindow(VOID)
Definition: focus.c:1429
@ THREADSTATE_GETCURSOR
Definition: ntuser.h:2478
@ THREADSTATE_DEFAULTIMEWINDOW
Definition: ntuser.h:2475
@ THREADSTATE_DEFAULTINPUTCONTEXT
Definition: ntuser.h:2476
@ THREADSTATE_CHECKCONIME
Definition: ntuser.h:2489
@ THREADSTATE_INSENDMESSAGE
Definition: ntuser.h:2482
@ THREADSTATE_GETTHREADINFO
Definition: ntuser.h:2490
@ THREADSTATE_CAPTUREWINDOW
Definition: ntuser.h:2474
@ THREADSTATE_TASKMANWINDOW
Definition: ntuser.h:2492
@ THREADSTATE_FOREGROUNDTHREAD
Definition: ntuser.h:2484
@ THREADSTATE_OLDKEYBOARDLAYOUT
Definition: ntuser.h:2486
@ THREADSTATE_GETINPUTSTATE
Definition: ntuser.h:2477
@ THREADSTATE_ISWINLOGON2
Definition: ntuser.h:2488
@ THREADSTATE_PROGMANWINDOW
Definition: ntuser.h:2491
@ THREADSTATE_ACTIVEWINDOW
Definition: ntuser.h:2473
@ THREADSTATE_GETMESSAGETIME
Definition: ntuser.h:2483
@ THREADSTATE_FOCUSWINDOW
Definition: ntuser.h:2472
@ THREADSTATE_GETMESSAGEEXTRAINFO
Definition: ntuser.h:2481
@ THREADSTATE_ISWINLOGON
Definition: ntuser.h:2487
@ THREADSTATE_UPTIMELASTREAD
Definition: ntuser.h:2480
@ THREADSTATE_CHANGEBITS
Definition: ntuser.h:2479
@ THREADSTATE_IMECOMPATFLAGS
Definition: ntuser.h:2485
LPARAM FASTCALL MsqGetMessageExtraInfo(VOID)
Definition: msgqueue.c:2449
HANDLE NTAPI PsGetCurrentProcessId(VOID)
Definition: process.c:1123
struct _THREADINFO * PTHREADINFO
Definition: ntwin32.h:6
HANDLE gpidLogon
Definition: simplecall.c:15
DWORD dwImeCompatFlags
Definition: win32.h:276
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:93
struct tagIMC * spDefaultImc
Definition: win32.h:132
HKL hklPrev
Definition: win32.h:133
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:91
struct _WND * spwndDefaultIme
Definition: win32.h:131
#define DWORD_PTR
Definition: treelist.c:76
#define QS_SMRESULT
Definition: undocuser.h:95
int ret
DWORD APIENTRY IntGetQueueStatus(DWORD Changes)
Definition: message.c:2089
PTHREADINFO GetW32ThreadInfo(VOID)
Definition: misc.c:805
#define QS_KEY
Definition: winuser.h:873
#define QS_SENDMESSAGE
Definition: winuser.h:879
#define QS_TIMER
Definition: winuser.h:877
#define QS_MOUSEBUTTON
Definition: winuser.h:875
#define QS_INPUT
Definition: winuser.h:898
#define QS_POSTMESSAGE
Definition: winuser.h:876
#define QS_PAINT
Definition: winuser.h:878

Referenced by CheckThreadState(), DIALOG_CreateIndirect(), DoTest_BUTTON(), DoTest_EDIT(), GetActiveWindow(), GetCapture(), GetCursor(), GetFocus(), GetInputState(), GetMessageTime(), GetProgmanWindow(), GetTaskmanWindow(), GetW32ThreadInfo(), ImeWnd_OnImeSetContext(), Imm32CurrentPti(), Imm32ImeNonImeToggle(), Imm32InquireIme(), ImmCreateContext(), ImmDllInitialize(), ImmGetDefaultIMEWnd(), ImmGetSaveContext(), ImmLockClientImc(), ImmWINNLSEnableIME(), InSendMessage(), InSendMessageEx(), IsGUIThread(), NtUserxGetMessageExtraInfo(), and PeekMessageWorker().

◆ NtUserSetThreadState()

DWORD APIENTRY NtUserSetThreadState ( DWORD  Set,
DWORD  Flags 
)

Definition at line 359 of file misc.c.

362{
363 PTHREADINFO pti;
364 DWORD Ret = 0;
365 // Test the only flags user can change.
370 if (pti->MessageQueue)
371 {
372 Ret = pti->MessageQueue->QF_flags; // Get the queue flags.
373 if (Set)
374 pti->MessageQueue->QF_flags |= (Set&Flags); // Set the queue flags.
375 else
376 {
377 if (Flags) pti->MessageQueue->QF_flags &= ~Flags; // Clr the queue flags.
378 }
379 }
380 UserLeave();
381 return Ret;
382}
#define QF_DIALOGACTIVE
Definition: msgqueue.h:106
#define QF_TABSWITCHING
Definition: msgqueue.h:101
#define QF_FMENUSTATUSBREAK
Definition: msgqueue.h:96
#define QF_FMENUSTATUS
Definition: msgqueue.h:97
#define QF_FF10STATUS
Definition: msgqueue.h:98
static BOOL Set
Definition: pageheap.c:10
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by DEFDLG_Proc().

◆ UserDbgAssertThreadInfo()

void UserDbgAssertThreadInfo ( BOOL  showCaller)

Definition at line 732 of file misc.c.

733{
734 PTEB Teb;
735 PPROCESSINFO ppi;
736 PCLIENTINFO pci;
737 PTHREADINFO pti;
738
741 Teb = NtCurrentTeb();
742 pci = GetWin32ClientInfo();
743
744 ASSERT(Teb);
745 ASSERT(pti);
746 ASSERT(pti->ppi == ppi);
747 ASSERT(pti->pClientInfo == pci);
748 ASSERT(Teb->Win32ThreadInfo == pti);
749 ASSERT(pci->ppi == ppi);
750 ASSERT(pci->fsHooks == pti->fsHooks);
752 if (pti->pcti && pci->pDeskInfo)
753 ASSERT(pci->pClientThreadInfo == (PVOID)((ULONG_PTR)pti->pcti - pci->ulClientDelta));
754 if (pti->KeyboardLayout)
755 ASSERT(pci->hKL == pti->KeyboardLayout->hkl);
756 if(pti->rpdesk != NULL)
757 ASSERT(pti->pDeskInfo == pti->rpdesk->pDeskInfo);
758
759 /*too bad we still get this assertion*/
760
761 // Why? Not all flags are passed to the user and doing so could crash the system........
762
763 /* ASSERT(pci->dwTIFlags == pti->TIF_flags); */
764/* if(pci->dwTIFlags != pti->TIF_flags)
765 {
766 ERR("pci->dwTIFlags(0x%x) doesn't match pti->TIF_flags(0x%x)\n", pci->dwTIFlags, pti->TIF_flags);
767 if(showCaller)
768 {
769 DbgPrint("Caller:\n");
770 KeRosDumpStackFrames(NULL, 10);
771 }
772 pci->dwTIFlags = pti->TIF_flags;
773 }
774*/
775}
#define GetWin32ClientInfo()
Definition: ntuser.h:352
#define NtCurrentTeb
HKL hKL
Definition: ntuser.h:339
ULONG_PTR ulClientDelta
Definition: ntuser.h:326
ULONG fsHooks
Definition: ntuser.h:328
PCLIENTTHREADINFO pClientThreadInfo
Definition: ntuser.h:332
PDESKTOPINFO pDeskInfo
Definition: ntuser.h:325
struct _PROCESSINFO * ppi
Definition: ntuser.h:346
Definition: compat.h:836
PVOID Win32ThreadInfo
Definition: compat.h:846
ULONG fsHooks
Definition: win32.h:117
struct _CLIENTINFO * pClientInfo
Definition: win32.h:94
struct tagKL * KeyboardLayout
Definition: win32.h:90
uint32_t ULONG_PTR
Definition: typedefs.h:65
static __inline ULONG_PTR DesktopHeapGetUserDelta(VOID)
Definition: desktop.h:272

Referenced by GetW32ThreadInfo(), UserDbgPostServiceHook(), and UserDbgPreServiceHook().

◆ UserDbgPostServiceHook()

ULONG_PTR NTAPI UserDbgPostServiceHook ( ULONG  ulSyscallId,
ULONG_PTR  ulResult 
)

Definition at line 786 of file misc.c.

787{
788 /* Make sure that the first syscall is NtUserInitialize */
789 /* too bad this fails */
790 // ASSERT(gpepCSRSS);
791
793
794 return ulResult;
795}

◆ UserDbgPreServiceHook()

void NTAPI UserDbgPreServiceHook ( ULONG  ulSyscallId,
PULONG_PTR  pulArguments 
)

Definition at line 779 of file misc.c.

780{
782}

◆ UserGetLanguageID()

USHORT FASTCALL UserGetLanguageID ( VOID  )

Definition at line 105 of file misc.c.

106{
108 OBJECT_ATTRIBUTES ObAttr;
109// http://support.microsoft.com/kb/324097
113 UNICODE_STRING Language;
114
115 RtlInitUnicodeString( &Language,
116 L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Nls\\Language");
117
119 &Language,
121 NULL,
122 NULL);
123
124 if ( NT_SUCCESS(ZwOpenKey(&KeyHandle, KEY_READ, &ObAttr)))
125 {
127 if ( pKeyInfo )
128 {
129 RtlInitUnicodeString(&Language, L"Default");
130
131 if ( NT_SUCCESS(ZwQueryValueKey( KeyHandle,
132 &Language,
134 pKeyInfo,
135 Size,
136 &Size)) )
137 {
138 RtlInitUnicodeString(&Language, (PWSTR)pKeyInfo->Data);
139 if (!NT_SUCCESS(RtlUnicodeStringToInteger(&Language, 16, &Ret)))
140 {
142 }
143 }
144 ExFreePoolWithTag(pKeyInfo, TAG_STRING);
145 }
147 }
148 TRACE("Language ID = %x\n",Ret);
149 return (USHORT) Ret;
150}
#define MAX_PATH
Definition: compat.h:34
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ KeyValuePartialInformation
Definition: nt_native.h:1182
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
unsigned short USHORT
Definition: pedump.c:61
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_ENGLISH
Definition: nls.h:52
#define SUBLANG_DEFAULT
Definition: nls.h:168
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by InitializeGreCSRSS().

◆ UserGetLanguageToggle()

DWORD FASTCALL UserGetLanguageToggle ( _In_ PCWSTR  pszType,
_In_ DWORD  dwDefaultValue 
)
See also
https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-2000-server/cc976564%28v=technet.10%29

Definition at line 84 of file misc.c.

87{
89 DWORD dwValue = dwDefaultValue;
90 WCHAR szBuff[4];
91
92 Status = RegReadUserSetting(L"Keyboard Layout\\Toggle", pszType, REG_SZ, szBuff, sizeof(szBuff));
93 if (NT_SUCCESS(Status))
94 {
95 szBuff[RTL_NUMBER_OF(szBuff) - 1] = UNICODE_NULL;
96 dwValue = _wtoi(szBuff);
97 }
98
99 TRACE("%ls: %lu\n", pszType, dwValue);
100 return dwValue;
101}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22
#define UNICODE_NULL

Referenced by SpiGetSet(), and SpiUpdatePerUserSystemParameters().