2008-03-21 00:07:06 +00:00
|
|
|
/*
|
2003-05-26 18:52:37 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
2011-12-14 04:07:06 +00:00
|
|
|
* PROJECT: ReactOS Win32k subsystem
|
|
|
|
* PURPOSE: Miscellaneous User functions
|
2013-05-11 19:33:40 +00:00
|
|
|
* FILE: win32ss/user/ntuser/misc.c
|
2003-05-26 18:52:37 +00:00
|
|
|
* PROGRAMER: Ge van Geldorp (ge@gse.nl)
|
|
|
|
*/
|
2004-05-10 17:07:20 +00:00
|
|
|
|
2010-04-26 13:58:46 +00:00
|
|
|
#include <win32k.h>
|
2011-08-21 12:38:52 +00:00
|
|
|
DBG_DEFAULT_CHANNEL(UserMisc);
|
2003-08-28 18:04:59 +00:00
|
|
|
|
2018-07-16 23:47:59 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: _scwprintf() is NOT exported by ntoskrnl.exe,
|
|
|
|
* only _vscwprintf() is, so we need to implement it here.
|
|
|
|
* Code comes from sdk/lib/crt/printf/_scwprintf.c .
|
|
|
|
* See also win32ss/user/winsrv/usersrv/harderror.c .
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
__cdecl
|
|
|
|
_scwprintf(
|
|
|
|
const wchar_t *format,
|
|
|
|
...)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start(args, format);
|
|
|
|
len = _vscwprintf(format, args);
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-11 19:33:40 +00:00
|
|
|
/*
|
|
|
|
* Test the Thread to verify and validate it. Hard to the core tests are required.
|
|
|
|
*/
|
|
|
|
PTHREADINFO
|
|
|
|
FASTCALL
|
|
|
|
IntTID2PTI(HANDLE id)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
PETHREAD Thread;
|
|
|
|
PTHREADINFO pti;
|
|
|
|
Status = PsLookupThreadByThreadId(id, &Thread);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (PsIsThreadTerminating(Thread))
|
|
|
|
{
|
|
|
|
ObDereferenceObject(Thread);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
pti = PsGetThreadWin32Thread(Thread);
|
|
|
|
if (!pti)
|
|
|
|
{
|
|
|
|
ObDereferenceObject(Thread);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
// Validate and verify!
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
if (pti->TIF_flags & TIF_INCLEANUP) pti = NULL;
|
|
|
|
if (pti && !(pti->TIF_flags & TIF_GUITHREADINITIALIZED)) pti = NULL;
|
|
|
|
if (PsGetThreadId(Thread) != id) pti = NULL;
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
pti = NULL;
|
|
|
|
}
|
|
|
|
_SEH2_END
|
|
|
|
ObDereferenceObject(Thread);
|
|
|
|
return pti;
|
|
|
|
}
|
|
|
|
|
2016-08-11 15:53:05 +00:00
|
|
|
DWORD
|
|
|
|
FASTCALL
|
|
|
|
UserGetLanguageToggle(VOID)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
DWORD dwValue = 0;
|
|
|
|
|
|
|
|
Status = RegReadUserSetting(L"Keyboard Layout\\Toggle", L"Layout Hotkey", REG_SZ, &dwValue, sizeof(dwValue));
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
dwValue = atoi((char *)&dwValue);
|
2016-08-11 21:36:55 +00:00
|
|
|
TRACE("Layout Hotkey %d\n",dwValue);
|
2016-08-11 15:53:05 +00:00
|
|
|
}
|
|
|
|
return dwValue;
|
|
|
|
}
|
|
|
|
|
2008-10-30 10:46:27 +00:00
|
|
|
SHORT
|
|
|
|
FASTCALL
|
2012-02-05 20:21:22 +00:00
|
|
|
UserGetLanguageID(VOID)
|
2008-10-30 10:46:27 +00:00
|
|
|
{
|
|
|
|
HANDLE KeyHandle;
|
|
|
|
OBJECT_ATTRIBUTES ObAttr;
|
|
|
|
// http://support.microsoft.com/kb/324097
|
2015-03-10 00:12:41 +00:00
|
|
|
ULONG Ret = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
|
2011-09-08 16:38:38 +00:00
|
|
|
PKEY_VALUE_PARTIAL_INFORMATION pKeyInfo;
|
|
|
|
ULONG Size = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + MAX_PATH*sizeof(WCHAR);
|
2008-10-30 10:46:27 +00:00
|
|
|
UNICODE_STRING Language;
|
2011-09-08 16:38:38 +00:00
|
|
|
|
2008-10-30 10:46:27 +00:00
|
|
|
RtlInitUnicodeString( &Language,
|
|
|
|
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Nls\\Language");
|
|
|
|
|
|
|
|
InitializeObjectAttributes( &ObAttr,
|
2015-10-16 14:04:19 +00:00
|
|
|
&Language,
|
|
|
|
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2008-10-30 10:46:27 +00:00
|
|
|
|
|
|
|
if ( NT_SUCCESS(ZwOpenKey(&KeyHandle, KEY_READ, &ObAttr)))
|
|
|
|
{
|
2011-09-08 16:38:38 +00:00
|
|
|
pKeyInfo = ExAllocatePoolWithTag(PagedPool, Size, TAG_STRING);
|
|
|
|
if ( pKeyInfo )
|
2008-10-30 10:46:27 +00:00
|
|
|
{
|
|
|
|
RtlInitUnicodeString(&Language, L"Default");
|
|
|
|
|
|
|
|
if ( NT_SUCCESS(ZwQueryValueKey( KeyHandle,
|
|
|
|
&Language,
|
|
|
|
KeyValuePartialInformation,
|
2011-09-08 16:38:38 +00:00
|
|
|
pKeyInfo,
|
2008-10-30 10:46:27 +00:00
|
|
|
Size,
|
|
|
|
&Size)) )
|
|
|
|
{
|
2011-09-08 16:38:38 +00:00
|
|
|
RtlInitUnicodeString(&Language, (PWSTR)pKeyInfo->Data);
|
2015-03-10 00:12:41 +00:00
|
|
|
if (!NT_SUCCESS(RtlUnicodeStringToInteger(&Language, 16, &Ret)))
|
|
|
|
{
|
|
|
|
Ret = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
|
|
|
|
}
|
2008-10-30 10:46:27 +00:00
|
|
|
}
|
2011-09-08 16:38:38 +00:00
|
|
|
ExFreePoolWithTag(pKeyInfo, TAG_STRING);
|
2008-10-30 10:46:27 +00:00
|
|
|
}
|
|
|
|
ZwClose(KeyHandle);
|
|
|
|
}
|
2011-08-21 12:38:52 +00:00
|
|
|
TRACE("Language ID = %x\n",Ret);
|
2008-10-30 10:46:27 +00:00
|
|
|
return (SHORT) Ret;
|
|
|
|
}
|
|
|
|
|
2011-11-04 13:16:48 +00:00
|
|
|
HBRUSH
|
|
|
|
FASTCALL
|
|
|
|
GetControlColor(
|
|
|
|
PWND pwndParent,
|
|
|
|
PWND pwnd,
|
|
|
|
HDC hdc,
|
|
|
|
UINT CtlMsg)
|
|
|
|
{
|
|
|
|
HBRUSH hBrush;
|
|
|
|
|
|
|
|
if (!pwndParent) pwndParent = pwnd;
|
|
|
|
|
|
|
|
if ( pwndParent->head.pti->ppi != PsGetCurrentProcessWin32Process())
|
|
|
|
{
|
|
|
|
return (HBRUSH)IntDefWindowProc( pwndParent, CtlMsg, (WPARAM)hdc, (LPARAM)UserHMGetHandle(pwnd), FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
hBrush = (HBRUSH)co_IntSendMessage( UserHMGetHandle(pwndParent), CtlMsg, (WPARAM)hdc, (LPARAM)UserHMGetHandle(pwnd));
|
|
|
|
|
|
|
|
if (!hBrush || !GreIsHandleValid(hBrush))
|
|
|
|
{
|
|
|
|
hBrush = (HBRUSH)IntDefWindowProc( pwndParent, CtlMsg, (WPARAM)hdc, (LPARAM)UserHMGetHandle(pwnd), FALSE);
|
|
|
|
}
|
|
|
|
return hBrush;
|
|
|
|
}
|
|
|
|
|
|
|
|
HBRUSH
|
|
|
|
FASTCALL
|
|
|
|
GetControlBrush(
|
|
|
|
PWND pwnd,
|
|
|
|
HDC hdc,
|
|
|
|
UINT ctlType)
|
|
|
|
{
|
|
|
|
PWND pwndParent = IntGetParent(pwnd);
|
|
|
|
return GetControlColor( pwndParent, pwnd, hdc, ctlType);
|
|
|
|
}
|
|
|
|
|
|
|
|
HBRUSH
|
|
|
|
APIENTRY
|
|
|
|
NtUserGetControlBrush(
|
|
|
|
HWND hwnd,
|
|
|
|
HDC hdc,
|
|
|
|
UINT ctlType)
|
|
|
|
{
|
|
|
|
PWND pwnd;
|
|
|
|
HBRUSH hBrush = NULL;
|
|
|
|
|
|
|
|
UserEnterExclusive();
|
|
|
|
if ( (pwnd = UserGetWindowObject(hwnd)) &&
|
|
|
|
((ctlType - WM_CTLCOLORMSGBOX) < CTLCOLOR_MAX) &&
|
|
|
|
hdc )
|
|
|
|
{
|
|
|
|
hBrush = GetControlBrush(pwnd, hdc, ctlType);
|
|
|
|
}
|
|
|
|
UserLeave();
|
|
|
|
return hBrush;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called from PaintRect, works almost like wine PaintRect16 but returns hBrush.
|
|
|
|
*/
|
|
|
|
HBRUSH
|
|
|
|
APIENTRY
|
|
|
|
NtUserGetControlColor(
|
|
|
|
HWND hwndParent,
|
|
|
|
HWND hwnd,
|
|
|
|
HDC hdc,
|
|
|
|
UINT CtlMsg) // Wine PaintRect: WM_CTLCOLORMSGBOX + hbrush
|
|
|
|
{
|
|
|
|
PWND pwnd, pwndParent = NULL;
|
|
|
|
HBRUSH hBrush = NULL;
|
|
|
|
|
|
|
|
UserEnterExclusive();
|
|
|
|
if ( (pwnd = UserGetWindowObject(hwnd)) &&
|
|
|
|
((CtlMsg - WM_CTLCOLORMSGBOX) < CTLCOLOR_MAX) &&
|
|
|
|
hdc )
|
|
|
|
{
|
|
|
|
if (hwndParent) pwndParent = UserGetWindowObject(hwndParent);
|
|
|
|
hBrush = GetControlColor( pwndParent, pwnd, hdc, CtlMsg);
|
|
|
|
}
|
|
|
|
UserLeave();
|
|
|
|
return hBrush;
|
|
|
|
}
|
|
|
|
|
2003-11-30 20:03:47 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2010-01-05 19:26:32 +00:00
|
|
|
DWORD_PTR APIENTRY
|
2003-11-30 20:03:47 +00:00
|
|
|
NtUserGetThreadState(
|
2005-09-07 21:25:42 +00:00
|
|
|
DWORD Routine)
|
2003-11-30 20:03:47 +00:00
|
|
|
{
|
2010-01-05 19:26:32 +00:00
|
|
|
DWORD_PTR ret = 0;
|
2005-09-05 21:19:23 +00:00
|
|
|
|
2011-08-21 12:38:52 +00:00
|
|
|
TRACE("Enter NtUserGetThreadState\n");
|
2006-04-05 08:05:55 +00:00
|
|
|
if (Routine != THREADSTATE_GETTHREADINFO)
|
|
|
|
{
|
|
|
|
UserEnterShared();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UserEnterExclusive();
|
|
|
|
}
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2003-11-30 20:03:47 +00:00
|
|
|
switch (Routine)
|
|
|
|
{
|
2006-04-05 08:05:55 +00:00
|
|
|
case THREADSTATE_GETTHREADINFO:
|
|
|
|
GetW32ThreadInfo();
|
2010-01-05 19:26:32 +00:00
|
|
|
break;
|
2006-04-05 08:05:55 +00:00
|
|
|
case THREADSTATE_FOCUSWINDOW:
|
2012-04-23 18:51:48 +00:00
|
|
|
ret = (DWORD_PTR)IntGetThreadFocusWindow();
|
2010-01-05 19:26:32 +00:00
|
|
|
break;
|
Patch by Stefan Ginsberg (stefan__100__ AT hotmail DOT com):
- remove NtUserEnumClipboardFormats, use ->ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMAT insetad
- remove NtUserRegisterClipboardFormat, use NtUserRegisterWIndowsMessage instead
- remove NtUserKillSystemTimer, use HWNDPARAM_ROUTINE_KILLSYSTEMTIMER instead
- remove NtUserInsertMenuItem, use NtUserThunkedMenuItemInfo instead
- remove NtUserGetCapture, use THREADSTATE_CAPTUREWINDOW instead
- remove NtUserGetActiveWindow, use THREADSTATE_ACTIVEWINDOW instead
- remove NtUserGetQueueStatus, use ONEPARAM_ROUTIME_GETQUEUESTATUS instead
- remove NtUserGetLastActivePopup, wasn't implemented
- remove NtUserRealizePalette from ntuser.h, it's not implemented
- remove duplicate NtUserGetLastInputInfo from ntuser.h
- remove PrivateCsrssRergisterPrimitive from user32, it was unused and unimplemented
- remove NtUserDereferenceWndprocHandle, it was unused
- move WNDPROC_INFO structure from ntuser.h to win32k/include/class.h, as it's not used in usermode anymore
tested with AbiWord and FF on VMWare
svn path=/trunk/; revision=32825
2008-04-03 02:13:34 +00:00
|
|
|
case THREADSTATE_CAPTUREWINDOW:
|
2011-12-14 04:07:06 +00:00
|
|
|
/* FIXME: Should use UserEnterShared */
|
2010-01-05 19:26:32 +00:00
|
|
|
ret = (DWORD_PTR)IntGetCapture();
|
|
|
|
break;
|
2006-07-22 16:50:23 +00:00
|
|
|
case THREADSTATE_PROGMANWINDOW:
|
2010-01-05 19:26:32 +00:00
|
|
|
ret = (DWORD_PTR)GetW32ThreadInfo()->pDeskInfo->hProgmanWindow;
|
|
|
|
break;
|
2006-07-22 16:50:23 +00:00
|
|
|
case THREADSTATE_TASKMANWINDOW:
|
2010-01-05 19:26:32 +00:00
|
|
|
ret = (DWORD_PTR)GetW32ThreadInfo()->pDeskInfo->hTaskManWindow;
|
|
|
|
break;
|
Patch by Stefan Ginsberg (stefan__100__ AT hotmail DOT com):
- remove NtUserEnumClipboardFormats, use ->ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMAT insetad
- remove NtUserRegisterClipboardFormat, use NtUserRegisterWIndowsMessage instead
- remove NtUserKillSystemTimer, use HWNDPARAM_ROUTINE_KILLSYSTEMTIMER instead
- remove NtUserInsertMenuItem, use NtUserThunkedMenuItemInfo instead
- remove NtUserGetCapture, use THREADSTATE_CAPTUREWINDOW instead
- remove NtUserGetActiveWindow, use THREADSTATE_ACTIVEWINDOW instead
- remove NtUserGetQueueStatus, use ONEPARAM_ROUTIME_GETQUEUESTATUS instead
- remove NtUserGetLastActivePopup, wasn't implemented
- remove NtUserRealizePalette from ntuser.h, it's not implemented
- remove duplicate NtUserGetLastInputInfo from ntuser.h
- remove PrivateCsrssRergisterPrimitive from user32, it was unused and unimplemented
- remove NtUserDereferenceWndprocHandle, it was unused
- move WNDPROC_INFO structure from ntuser.h to win32k/include/class.h, as it's not used in usermode anymore
tested with AbiWord and FF on VMWare
svn path=/trunk/; revision=32825
2008-04-03 02:13:34 +00:00
|
|
|
case THREADSTATE_ACTIVEWINDOW:
|
2010-01-05 19:26:32 +00:00
|
|
|
ret = (DWORD_PTR)UserGetActiveWindow();
|
|
|
|
break;
|
2009-05-06 18:49:53 +00:00
|
|
|
case THREADSTATE_INSENDMESSAGE:
|
|
|
|
{
|
2014-05-11 23:11:16 +00:00
|
|
|
PUSER_SENT_MESSAGE Message =
|
2010-12-03 18:02:02 +00:00
|
|
|
((PTHREADINFO)PsGetCurrentThreadWin32Thread())->pusmCurrent;
|
2015-11-29 17:45:09 +00:00
|
|
|
TRACE("THREADSTATE_INSENDMESSAGE\n");
|
2009-05-06 18:49:53 +00:00
|
|
|
|
2010-01-05 19:26:32 +00:00
|
|
|
ret = ISMEX_NOSEND;
|
2010-12-03 18:02:02 +00:00
|
|
|
if (Message)
|
2009-05-06 18:49:53 +00:00
|
|
|
{
|
2013-05-10 22:28:18 +00:00
|
|
|
if (Message->ptiSender)
|
2010-12-03 15:34:06 +00:00
|
|
|
ret = ISMEX_SEND;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Message->CompletionCallback)
|
|
|
|
ret = ISMEX_CALLBACK;
|
|
|
|
else
|
|
|
|
ret = ISMEX_NOTIFY;
|
|
|
|
}
|
2011-12-14 04:07:06 +00:00
|
|
|
/* If ReplyMessage */
|
2010-12-03 15:34:06 +00:00
|
|
|
if (Message->QS_Flags & QS_SMRESULT) ret |= ISMEX_REPLIED;
|
2009-05-06 18:49:53 +00:00
|
|
|
}
|
2010-12-03 15:34:06 +00:00
|
|
|
|
2014-05-11 23:11:16 +00:00
|
|
|
break;
|
2009-05-06 18:49:53 +00:00
|
|
|
}
|
2010-12-03 15:34:06 +00:00
|
|
|
case THREADSTATE_GETMESSAGETIME:
|
2010-01-05 19:26:32 +00:00
|
|
|
ret = ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->timeLast;
|
|
|
|
break;
|
2009-05-19 15:47:16 +00:00
|
|
|
|
2010-12-03 15:34:06 +00:00
|
|
|
case THREADSTATE_UPTIMELASTREAD:
|
|
|
|
{
|
|
|
|
PTHREADINFO pti;
|
|
|
|
pti = PsGetCurrentThreadWin32Thread();
|
2019-04-11 22:56:04 +00:00
|
|
|
pti->timeLast = EngGetTickCount32();
|
|
|
|
pti->pcti->tickLastMsgChecked = pti->timeLast;
|
2010-12-03 15:34:06 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-05-19 15:47:16 +00:00
|
|
|
case THREADSTATE_GETINPUTSTATE:
|
2010-11-20 04:24:44 +00:00
|
|
|
ret = LOWORD(IntGetQueueStatus(QS_POSTMESSAGE|QS_TIMER|QS_PAINT|QS_SENDMESSAGE|QS_INPUT)) & (QS_KEY | QS_MOUSEBUTTON);
|
2010-01-05 19:26:32 +00:00
|
|
|
break;
|
2012-06-02 03:34:04 +00:00
|
|
|
|
|
|
|
case THREADSTATE_FOREGROUNDTHREAD:
|
|
|
|
ret = (gpqForeground == GetW32ThreadInfo()->MessageQueue);
|
|
|
|
break;
|
2012-06-07 12:05:17 +00:00
|
|
|
case THREADSTATE_GETCURSOR:
|
|
|
|
ret = (DWORD_PTR) (GetW32ThreadInfo()->MessageQueue->CursorObject ?
|
|
|
|
UserHMGetHandle(GetW32ThreadInfo()->MessageQueue->CursorObject) : 0);
|
|
|
|
break;
|
2014-12-01 14:47:05 +00:00
|
|
|
case THREADSTATE_GETMESSAGEEXTRAINFO:
|
|
|
|
ret = (DWORD_PTR)MsqGetMessageExtraInfo();
|
|
|
|
break;
|
2003-11-30 20:03:47 +00:00
|
|
|
}
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2013-09-01 23:58:37 +00:00
|
|
|
TRACE("Leave NtUserGetThreadState, ret=%lu\n", ret);
|
2005-09-05 21:19:23 +00:00
|
|
|
UserLeave();
|
2010-01-05 19:26:32 +00:00
|
|
|
|
|
|
|
return ret;
|
2003-11-30 20:03:47 +00:00
|
|
|
}
|
|
|
|
|
2011-05-05 12:43:31 +00:00
|
|
|
DWORD
|
|
|
|
APIENTRY
|
|
|
|
NtUserSetThreadState(
|
|
|
|
DWORD Set,
|
|
|
|
DWORD Flags)
|
|
|
|
{
|
|
|
|
PTHREADINFO pti;
|
|
|
|
DWORD Ret = 0;
|
|
|
|
// Test the only flags user can change.
|
|
|
|
if (Set & ~(QF_FF10STATUS|QF_DIALOGACTIVE|QF_TABSWITCHING|QF_FMENUSTATUS|QF_FMENUSTATUSBREAK)) return 0;
|
2014-05-11 23:11:16 +00:00
|
|
|
if (Flags & ~(QF_FF10STATUS|QF_DIALOGACTIVE|QF_TABSWITCHING|QF_FMENUSTATUS|QF_FMENUSTATUSBREAK)) return 0;
|
2011-05-05 12:43:31 +00:00
|
|
|
UserEnterExclusive();
|
|
|
|
pti = PsGetCurrentThreadWin32Thread();
|
|
|
|
if (pti->MessageQueue)
|
|
|
|
{
|
|
|
|
Ret = pti->MessageQueue->QF_flags; // Get the queue flags.
|
|
|
|
if (Set)
|
|
|
|
pti->MessageQueue->QF_flags |= (Set&Flags); // Set the queue flags.
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Flags) pti->MessageQueue->QF_flags &= ~Flags; // Clr the queue flags.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
UserLeave();
|
|
|
|
return Ret;
|
|
|
|
}
|
2005-09-05 21:19:23 +00:00
|
|
|
|
2003-09-12 12:54:26 +00:00
|
|
|
UINT
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2003-09-12 12:54:26 +00:00
|
|
|
NtUserGetDoubleClickTime(VOID)
|
|
|
|
{
|
2005-09-07 21:25:42 +00:00
|
|
|
UINT Result;
|
|
|
|
|
2011-08-21 12:38:52 +00:00
|
|
|
TRACE("Enter NtUserGetDoubleClickTime\n");
|
2005-09-07 21:25:42 +00:00
|
|
|
UserEnterShared();
|
|
|
|
|
2009-06-25 02:43:38 +00:00
|
|
|
// FIXME: Check if this works on non-interactive winsta
|
|
|
|
Result = gspv.iDblClickTime;
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2013-09-01 23:58:37 +00:00
|
|
|
TRACE("Leave NtUserGetDoubleClickTime, ret=%u\n", Result);
|
2005-09-07 21:25:42 +00:00
|
|
|
UserLeave();
|
2009-06-25 02:43:38 +00:00
|
|
|
return Result;
|
2003-09-12 12:54:26 +00:00
|
|
|
}
|
|
|
|
|
2003-11-18 23:33:31 +00:00
|
|
|
BOOL
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2003-11-18 23:33:31 +00:00
|
|
|
NtUserGetGUIThreadInfo(
|
2011-12-14 04:07:06 +00:00
|
|
|
DWORD idThread, /* If NULL use foreground thread */
|
2005-09-07 21:25:42 +00:00
|
|
|
LPGUITHREADINFO lpgui)
|
2003-11-18 23:33:31 +00:00
|
|
|
{
|
2005-09-07 21:25:42 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
PTHRDCARETINFO CaretInfo;
|
|
|
|
GUITHREADINFO SafeGui;
|
2008-10-17 13:09:56 +00:00
|
|
|
PDESKTOP Desktop;
|
2005-09-07 21:25:42 +00:00
|
|
|
PUSER_MESSAGE_QUEUE MsgQueue;
|
2011-04-04 07:18:54 +00:00
|
|
|
PTHREADINFO W32Thread;
|
2005-09-07 21:25:42 +00:00
|
|
|
PETHREAD Thread = NULL;
|
2011-04-04 07:18:54 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
DECLARE_RETURN(BOOLEAN);
|
|
|
|
|
2011-08-21 12:38:52 +00:00
|
|
|
TRACE("Enter NtUserGetGUIThreadInfo\n");
|
2005-09-07 21:25:42 +00:00
|
|
|
UserEnterShared();
|
|
|
|
|
|
|
|
Status = MmCopyFromCaller(&SafeGui, lpgui, sizeof(DWORD));
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
RETURN( FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(SafeGui.cbSize != sizeof(GUITHREADINFO))
|
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
2005-09-05 21:19:23 +00:00
|
|
|
RETURN( FALSE);
|
2005-09-07 21:25:42 +00:00
|
|
|
}
|
|
|
|
|
2011-04-04 07:18:54 +00:00
|
|
|
if (idThread)
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
2010-01-05 19:26:32 +00:00
|
|
|
Status = PsLookupThreadByThreadId((HANDLE)(DWORD_PTR)idThread, &Thread);
|
2005-09-07 21:25:42 +00:00
|
|
|
if(!NT_SUCCESS(Status))
|
2003-11-18 23:33:31 +00:00
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_ACCESS_DENIED);
|
2005-09-07 21:25:42 +00:00
|
|
|
RETURN( FALSE);
|
2003-11-18 23:33:31 +00:00
|
|
|
}
|
2011-04-04 07:18:54 +00:00
|
|
|
W32Thread = (PTHREADINFO)Thread->Tcb.Win32Thread;
|
|
|
|
Desktop = W32Thread->rpdesk;
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2015-12-13 06:08:12 +00:00
|
|
|
if (!Thread || !Desktop )
|
|
|
|
{
|
|
|
|
if(Thread)
|
|
|
|
ObDereferenceObject(Thread);
|
|
|
|
EngSetLastError(ERROR_ACCESS_DENIED);
|
|
|
|
RETURN( FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( W32Thread->MessageQueue )
|
|
|
|
MsgQueue = W32Thread->MessageQueue;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( Desktop ) MsgQueue = Desktop->ActiveMessageQueue;
|
|
|
|
}
|
2005-09-07 21:25:42 +00:00
|
|
|
}
|
2011-04-04 07:18:54 +00:00
|
|
|
else
|
2015-12-13 06:08:12 +00:00
|
|
|
{ /* Get the foreground thread */
|
|
|
|
/* FIXME: Handle NULL queue properly? */
|
|
|
|
MsgQueue = IntGetFocusMessageQueue();
|
|
|
|
if(!MsgQueue)
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_ACCESS_DENIED);
|
|
|
|
RETURN( FALSE);
|
|
|
|
}
|
2011-04-04 07:18:54 +00:00
|
|
|
}
|
|
|
|
|
2015-10-24 15:46:34 +00:00
|
|
|
CaretInfo = &MsgQueue->CaretInfo;
|
2005-09-07 21:25:42 +00:00
|
|
|
|
|
|
|
SafeGui.flags = (CaretInfo->Visible ? GUI_CARETBLINKING : 0);
|
2015-09-01 22:10:13 +00:00
|
|
|
/*
|
|
|
|
if (W32Thread->pMenuState->pGlobalPopupMenu)
|
|
|
|
{
|
|
|
|
SafeGui.flags |= GUI_INMENUMODE;
|
|
|
|
|
|
|
|
if (W32Thread->pMenuState->pGlobalPopupMenu->spwndNotify)
|
|
|
|
SafeGui.hwndMenuOwner = UserHMGetHandle(W32Thread->pMenuState->pGlobalPopupMenu->spwndNotify);
|
|
|
|
|
|
|
|
if (W32Thread->pMenuState->pGlobalPopupMenu->fHasMenuBar)
|
|
|
|
{
|
|
|
|
if (W32Thread->pMenuState->pGlobalPopupMenu->fIsSysMenu)
|
|
|
|
{
|
|
|
|
SafeGui.flags |= GUI_SYSTEMMENUMODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SafeGui.flags |= GUI_POPUPMENUMODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
SafeGui.hwndMenuOwner = MsgQueue->MenuOwner;
|
2011-04-04 07:18:54 +00:00
|
|
|
|
|
|
|
if (MsgQueue->MenuOwner)
|
2005-09-07 21:25:42 +00:00
|
|
|
SafeGui.flags |= GUI_INMENUMODE | MsgQueue->MenuState;
|
2011-04-04 07:18:54 +00:00
|
|
|
|
|
|
|
if (MsgQueue->MoveSize)
|
2005-09-07 21:25:42 +00:00
|
|
|
SafeGui.flags |= GUI_INMOVESIZE;
|
|
|
|
|
2011-12-14 04:07:06 +00:00
|
|
|
/* FIXME: Add flag GUI_16BITTASK */
|
2005-09-07 21:25:42 +00:00
|
|
|
|
2012-04-23 18:51:48 +00:00
|
|
|
SafeGui.hwndActive = MsgQueue->spwndActive ? UserHMGetHandle(MsgQueue->spwndActive) : 0;
|
|
|
|
SafeGui.hwndFocus = MsgQueue->spwndFocus ? UserHMGetHandle(MsgQueue->spwndFocus) : 0;
|
2012-08-15 23:31:30 +00:00
|
|
|
SafeGui.hwndCapture = MsgQueue->spwndCapture ? UserHMGetHandle(MsgQueue->spwndCapture) : 0;
|
2005-09-07 21:25:42 +00:00
|
|
|
SafeGui.hwndMoveSize = MsgQueue->MoveSize;
|
|
|
|
SafeGui.hwndCaret = CaretInfo->hWnd;
|
|
|
|
|
|
|
|
SafeGui.rcCaret.left = CaretInfo->Pos.x;
|
|
|
|
SafeGui.rcCaret.top = CaretInfo->Pos.y;
|
|
|
|
SafeGui.rcCaret.right = SafeGui.rcCaret.left + CaretInfo->Size.cx;
|
|
|
|
SafeGui.rcCaret.bottom = SafeGui.rcCaret.top + CaretInfo->Size.cy;
|
|
|
|
|
2011-04-04 07:18:54 +00:00
|
|
|
if (idThread)
|
2003-11-23 13:46:33 +00:00
|
|
|
ObDereferenceObject(Thread);
|
2005-09-07 21:25:42 +00:00
|
|
|
|
|
|
|
Status = MmCopyToCaller(lpgui, &SafeGui, sizeof(GUITHREADINFO));
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
RETURN( FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN( TRUE);
|
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
CLEANUP:
|
2013-09-01 23:58:37 +00:00
|
|
|
TRACE("Leave NtUserGetGUIThreadInfo, ret=%u\n",_ret_);
|
2005-09-07 21:25:42 +00:00
|
|
|
UserLeave();
|
|
|
|
END_CLEANUP;
|
2003-11-18 23:33:31 +00:00
|
|
|
}
|
|
|
|
|
2003-11-19 12:25:03 +00:00
|
|
|
|
|
|
|
DWORD
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2003-11-19 12:25:03 +00:00
|
|
|
NtUserGetGuiResources(
|
2005-09-07 21:25:42 +00:00
|
|
|
HANDLE hProcess,
|
|
|
|
DWORD uiFlags)
|
2003-11-19 12:25:03 +00:00
|
|
|
{
|
2005-09-07 21:25:42 +00:00
|
|
|
PEPROCESS Process;
|
2009-07-26 16:17:50 +00:00
|
|
|
PPROCESSINFO W32Process;
|
2005-09-07 21:25:42 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
DWORD Ret = 0;
|
|
|
|
DECLARE_RETURN(DWORD);
|
|
|
|
|
2011-08-21 12:38:52 +00:00
|
|
|
TRACE("Enter NtUserGetGuiResources\n");
|
2005-09-07 21:25:42 +00:00
|
|
|
UserEnterShared();
|
|
|
|
|
|
|
|
Status = ObReferenceObjectByHandle(hProcess,
|
|
|
|
PROCESS_QUERY_INFORMATION,
|
2014-05-11 23:11:16 +00:00
|
|
|
*PsProcessType,
|
2005-09-07 21:25:42 +00:00
|
|
|
ExGetPreviousMode(),
|
|
|
|
(PVOID*)&Process,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
RETURN( 0);
|
|
|
|
}
|
|
|
|
|
2009-07-26 16:17:50 +00:00
|
|
|
W32Process = (PPROCESSINFO)Process->Win32Process;
|
2005-09-07 21:25:42 +00:00
|
|
|
if(!W32Process)
|
|
|
|
{
|
|
|
|
ObDereferenceObject(Process);
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
2005-09-07 21:25:42 +00:00
|
|
|
RETURN( 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(uiFlags)
|
|
|
|
{
|
|
|
|
case GR_GDIOBJECTS:
|
|
|
|
{
|
2009-03-30 03:56:53 +00:00
|
|
|
Ret = (DWORD)W32Process->GDIHandleCount;
|
2005-09-07 21:25:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GR_USEROBJECTS:
|
|
|
|
{
|
2009-03-30 03:56:53 +00:00
|
|
|
Ret = (DWORD)W32Process->UserHandleCount;
|
2005-09-07 21:25:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
2010-12-25 11:01:14 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
2005-09-07 21:25:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
ObDereferenceObject(Process);
|
|
|
|
|
|
|
|
RETURN( Ret);
|
2003-11-19 12:25:03 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
CLEANUP:
|
2013-09-01 23:58:37 +00:00
|
|
|
TRACE("Leave NtUserGetGuiResources, ret=%lu\n",_ret_);
|
2005-09-07 21:25:42 +00:00
|
|
|
UserLeave();
|
|
|
|
END_CLEANUP;
|
2003-11-19 12:25:03 +00:00
|
|
|
}
|
|
|
|
|
2012-05-28 04:51:31 +00:00
|
|
|
VOID FASTCALL
|
|
|
|
IntSetWindowState(PWND pWnd, UINT Flag)
|
|
|
|
{
|
|
|
|
UINT bit;
|
|
|
|
if (gptiCurrent->ppi != pWnd->head.pti->ppi) return;
|
|
|
|
bit = 1 << LOWORD(Flag);
|
|
|
|
TRACE("SWS %x\n",bit);
|
|
|
|
switch(HIWORD(Flag))
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
pWnd->state |= bit;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
pWnd->state2 |= bit;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
pWnd->ExStyle2 |= bit;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID FASTCALL
|
|
|
|
IntClearWindowState(PWND pWnd, UINT Flag)
|
|
|
|
{
|
|
|
|
UINT bit;
|
|
|
|
if (gptiCurrent->ppi != pWnd->head.pti->ppi) return;
|
|
|
|
bit = 1 << LOWORD(Flag);
|
|
|
|
TRACE("CWS %x\n",bit);
|
|
|
|
switch(HIWORD(Flag))
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
pWnd->state &= ~bit;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
pWnd->state2 &= ~bit;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
pWnd->ExStyle2 &= ~bit;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-13 15:49:32 +00:00
|
|
|
NTSTATUS FASTCALL
|
|
|
|
IntSafeCopyUnicodeString(PUNICODE_STRING Dest,
|
|
|
|
PUNICODE_STRING Source)
|
|
|
|
{
|
2005-09-07 21:25:42 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
PWSTR Src;
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
Status = MmCopyFromCaller(Dest, Source, sizeof(UNICODE_STRING));
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
2003-12-13 15:49:32 +00:00
|
|
|
return Status;
|
2005-09-07 21:25:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(Dest->Length > 0x4000)
|
|
|
|
{
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Src = Dest->Buffer;
|
|
|
|
Dest->Buffer = NULL;
|
2007-12-04 22:52:05 +00:00
|
|
|
Dest->MaximumLength = Dest->Length;
|
2005-09-07 21:25:42 +00:00
|
|
|
|
|
|
|
if(Dest->Length > 0 && Src)
|
|
|
|
{
|
|
|
|
Dest->Buffer = ExAllocatePoolWithTag(PagedPool, Dest->MaximumLength, TAG_STRING);
|
|
|
|
if(!Dest->Buffer)
|
|
|
|
{
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = MmCopyFromCaller(Dest->Buffer, Src, Dest->Length);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
2008-11-04 23:49:07 +00:00
|
|
|
ExFreePoolWithTag(Dest->Buffer, TAG_STRING);
|
2005-09-07 21:25:42 +00:00
|
|
|
Dest->Buffer = NULL;
|
|
|
|
return Status;
|
|
|
|
}
|
2005-05-08 02:11:54 +00:00
|
|
|
|
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2011-12-14 04:07:06 +00:00
|
|
|
/* String is empty */
|
2005-09-07 21:25:42 +00:00
|
|
|
return STATUS_SUCCESS;
|
2003-12-13 15:49:32 +00:00
|
|
|
}
|
|
|
|
|
2004-05-19 19:09:20 +00:00
|
|
|
NTSTATUS FASTCALL
|
|
|
|
IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest,
|
|
|
|
PUNICODE_STRING Source)
|
|
|
|
{
|
2005-09-07 21:25:42 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
PWSTR Src;
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
Status = MmCopyFromCaller(Dest, Source, sizeof(UNICODE_STRING));
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
2004-05-19 19:09:20 +00:00
|
|
|
return Status;
|
2005-09-07 21:25:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(Dest->Length > 0x4000)
|
|
|
|
{
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Src = Dest->Buffer;
|
|
|
|
Dest->Buffer = NULL;
|
2007-12-04 22:52:05 +00:00
|
|
|
Dest->MaximumLength = 0;
|
2005-09-07 21:25:42 +00:00
|
|
|
|
|
|
|
if(Dest->Length > 0 && Src)
|
|
|
|
{
|
|
|
|
Dest->MaximumLength = Dest->Length + sizeof(WCHAR);
|
|
|
|
Dest->Buffer = ExAllocatePoolWithTag(PagedPool, Dest->MaximumLength, TAG_STRING);
|
|
|
|
if(!Dest->Buffer)
|
|
|
|
{
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = MmCopyFromCaller(Dest->Buffer, Src, Dest->Length);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
2008-11-04 23:49:07 +00:00
|
|
|
ExFreePoolWithTag(Dest->Buffer, TAG_STRING);
|
2005-09-07 21:25:42 +00:00
|
|
|
Dest->Buffer = NULL;
|
|
|
|
return Status;
|
|
|
|
}
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2011-12-14 04:07:06 +00:00
|
|
|
/* Make sure the string is null-terminated */
|
2005-09-07 21:25:42 +00:00
|
|
|
Src = (PWSTR)((PBYTE)Dest->Buffer + Dest->Length);
|
|
|
|
*Src = L'\0';
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2011-12-14 04:07:06 +00:00
|
|
|
/* String is empty */
|
2005-09-07 21:25:42 +00:00
|
|
|
return STATUS_SUCCESS;
|
2004-05-19 19:09:20 +00:00
|
|
|
}
|
|
|
|
|
2012-02-06 12:30:59 +00:00
|
|
|
void UserDbgAssertThreadInfo(BOOL showCaller)
|
2006-04-05 08:05:55 +00:00
|
|
|
{
|
|
|
|
PTEB Teb;
|
2009-05-13 21:32:10 +00:00
|
|
|
PPROCESSINFO ppi;
|
|
|
|
PCLIENTINFO pci;
|
2012-02-06 12:30:59 +00:00
|
|
|
PTHREADINFO pti;
|
2006-04-05 08:05:55 +00:00
|
|
|
|
2012-02-06 12:30:59 +00:00
|
|
|
ppi = PsGetCurrentProcessWin32Process();
|
|
|
|
pti = PsGetCurrentThreadWin32Thread();
|
2009-08-16 21:44:59 +00:00
|
|
|
Teb = NtCurrentTeb();
|
|
|
|
pci = GetWin32ClientInfo();
|
|
|
|
|
2012-02-06 12:30:59 +00:00
|
|
|
ASSERT(Teb);
|
|
|
|
ASSERT(pti);
|
|
|
|
ASSERT(pti->ppi == ppi);
|
|
|
|
ASSERT(pti->pClientInfo == pci);
|
|
|
|
ASSERT(Teb->Win32ThreadInfo == pti);
|
|
|
|
ASSERT(pci->ppi == ppi);
|
|
|
|
ASSERT(pci->fsHooks == pti->fsHooks);
|
|
|
|
ASSERT(pci->ulClientDelta == DesktopHeapGetUserDelta());
|
|
|
|
if (pti->pcti && pci->pDeskInfo)
|
|
|
|
ASSERT(pci->pClientThreadInfo == (PVOID)((ULONG_PTR)pti->pcti - pci->ulClientDelta));
|
2014-08-14 07:46:59 +00:00
|
|
|
if (pti->pcti && IsListEmpty(&pti->SentMessagesListHead))
|
|
|
|
ASSERT((pti->pcti->fsChangeBits & QS_SENDMESSAGE) == 0);
|
2014-05-11 23:11:16 +00:00
|
|
|
if (pti->KeyboardLayout)
|
2012-02-06 12:30:59 +00:00
|
|
|
ASSERT(pci->hKL == pti->KeyboardLayout->hkl);
|
|
|
|
if(pti->rpdesk != NULL)
|
|
|
|
ASSERT(pti->pDeskInfo == pti->rpdesk->pDeskInfo);
|
|
|
|
|
|
|
|
/*too bad we still get this assertion*/
|
2013-10-20 05:16:52 +00:00
|
|
|
|
|
|
|
// Why? Not all flags are passed to the user and doing so could crash the system........
|
|
|
|
|
2012-02-06 12:30:59 +00:00
|
|
|
/* ASSERT(pci->dwTIFlags == pti->TIF_flags); */
|
2013-10-20 05:16:52 +00:00
|
|
|
/* if(pci->dwTIFlags != pti->TIF_flags)
|
2012-02-06 12:30:59 +00:00
|
|
|
{
|
|
|
|
ERR("pci->dwTIFlags(0x%x) doesn't match pti->TIF_flags(0x%x)\n", pci->dwTIFlags, pti->TIF_flags);
|
|
|
|
if(showCaller)
|
|
|
|
{
|
|
|
|
DbgPrint("Caller:\n");
|
|
|
|
KeRosDumpStackFrames(NULL, 10);
|
2011-09-04 15:58:48 +00:00
|
|
|
}
|
2009-10-27 19:02:02 +00:00
|
|
|
pci->dwTIFlags = pti->TIF_flags;
|
2012-02-06 12:30:59 +00:00
|
|
|
}
|
2013-10-20 05:16:52 +00:00
|
|
|
*/
|
2012-02-06 12:30:59 +00:00
|
|
|
}
|
2009-08-16 21:44:59 +00:00
|
|
|
|
2012-02-06 12:30:59 +00:00
|
|
|
void
|
|
|
|
NTAPI
|
|
|
|
UserDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments)
|
|
|
|
{
|
|
|
|
UserDbgAssertThreadInfo(FALSE);
|
|
|
|
}
|
2010-11-20 04:24:44 +00:00
|
|
|
|
2012-02-06 12:30:59 +00:00
|
|
|
ULONG_PTR
|
|
|
|
NTAPI
|
|
|
|
UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult)
|
|
|
|
{
|
|
|
|
/* Make sure that the first syscall is NtUserInitialize */
|
|
|
|
/* too bad this fails */
|
2014-12-17 00:33:40 +00:00
|
|
|
// ASSERT(gpepCSRSS);
|
2012-02-06 12:30:59 +00:00
|
|
|
|
|
|
|
UserDbgAssertThreadInfo(TRUE);
|
|
|
|
|
|
|
|
return ulResult;
|
|
|
|
}
|
2006-04-05 08:05:55 +00:00
|
|
|
|
2012-02-06 12:30:59 +00:00
|
|
|
|
|
|
|
PPROCESSINFO
|
|
|
|
GetW32ProcessInfo(VOID)
|
|
|
|
{
|
|
|
|
return (PPROCESSINFO)PsGetCurrentProcessWin32Process();
|
|
|
|
}
|
|
|
|
|
|
|
|
PTHREADINFO
|
|
|
|
GetW32ThreadInfo(VOID)
|
|
|
|
{
|
|
|
|
UserDbgAssertThreadInfo(TRUE);
|
|
|
|
return (PTHREADINFO)PsGetCurrentThreadWin32Thread();
|
2006-04-05 08:05:55 +00:00
|
|
|
}
|
|
|
|
|
2018-06-16 17:44:15 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
GetProcessLuid(
|
|
|
|
IN PETHREAD Thread OPTIONAL,
|
2018-06-16 17:44:27 +00:00
|
|
|
IN PEPROCESS Process OPTIONAL,
|
2018-06-16 17:44:15 +00:00
|
|
|
OUT PLUID Luid)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
2018-06-16 17:44:27 +00:00
|
|
|
PACCESS_TOKEN Token = NULL;
|
2018-06-16 17:44:15 +00:00
|
|
|
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
|
|
|
|
BOOLEAN CopyOnOpen, EffectiveOnly;
|
|
|
|
|
2018-06-16 17:44:27 +00:00
|
|
|
if (Thread && Process)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/* If nothing has been specified, use the current thread */
|
|
|
|
if (!Thread && !Process)
|
2018-06-16 17:44:15 +00:00
|
|
|
Thread = PsGetCurrentThread();
|
|
|
|
|
2018-06-16 17:44:27 +00:00
|
|
|
if (Thread)
|
|
|
|
{
|
|
|
|
/* Use a thread token */
|
|
|
|
ASSERT(!Process);
|
|
|
|
Token = PsReferenceImpersonationToken(Thread,
|
|
|
|
&CopyOnOpen,
|
|
|
|
&EffectiveOnly,
|
|
|
|
&ImpersonationLevel);
|
|
|
|
|
|
|
|
/* If we don't have a thread token, use a process token */
|
|
|
|
if (!Token)
|
|
|
|
Process = PsGetThreadProcess(Thread);
|
|
|
|
}
|
|
|
|
if (!Token && Process)
|
2018-06-16 17:44:15 +00:00
|
|
|
{
|
2018-06-16 17:44:27 +00:00
|
|
|
/* Use a process token */
|
|
|
|
Token = PsReferencePrimaryToken(Process);
|
2018-06-16 17:44:15 +00:00
|
|
|
|
2018-06-16 17:44:27 +00:00
|
|
|
/* If we don't have a token, fail */
|
|
|
|
if (!Token)
|
2018-06-16 17:44:15 +00:00
|
|
|
return STATUS_NO_TOKEN;
|
|
|
|
}
|
2018-06-16 17:44:27 +00:00
|
|
|
ASSERT(Token);
|
2018-06-16 17:44:15 +00:00
|
|
|
|
|
|
|
/* Query the LUID */
|
|
|
|
Status = SeQueryAuthenticationIdToken(Token, Luid);
|
|
|
|
|
|
|
|
/* Get rid of the token and return */
|
|
|
|
ObDereferenceObject(Token);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2004-06-16 06:09:40 +00:00
|
|
|
/* EOF */
|