0cb5fd114d09643181edca058bd0fbb33b3bc452
[reactos.git] / reactos / win32ss / user / ntuser / misc.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Win32k subsystem
4 * PURPOSE: Miscellaneous User functions
5 * FILE: win32ss/user/ntuser/misc.c
6 * PROGRAMER: Ge van Geldorp (ge@gse.nl)
7 */
8
9 #include <win32k.h>
10 DBG_DEFAULT_CHANNEL(UserMisc);
11
12 /*
13 * Test the Thread to verify and validate it. Hard to the core tests are required.
14 */
15 PTHREADINFO
16 FASTCALL
17 IntTID2PTI(HANDLE id)
18 {
19 NTSTATUS Status;
20 PETHREAD Thread;
21 PTHREADINFO pti;
22 Status = PsLookupThreadByThreadId(id, &Thread);
23 if (!NT_SUCCESS(Status))
24 {
25 return NULL;
26 }
27 if (PsIsThreadTerminating(Thread))
28 {
29 ObDereferenceObject(Thread);
30 return NULL;
31 }
32 pti = PsGetThreadWin32Thread(Thread);
33 if (!pti)
34 {
35 ObDereferenceObject(Thread);
36 return NULL;
37 }
38 // Validate and verify!
39 _SEH2_TRY
40 {
41 if (pti->TIF_flags & TIF_INCLEANUP) pti = NULL;
42 if (pti && !(pti->TIF_flags & TIF_GUITHREADINITIALIZED)) pti = NULL;
43 if (PsGetThreadId(Thread) != id) pti = NULL;
44 }
45 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
46 {
47 pti = NULL;
48 }
49 _SEH2_END
50 ObDereferenceObject(Thread);
51 return pti;
52 }
53
54 SHORT
55 FASTCALL
56 UserGetLanguageID(VOID)
57 {
58 HANDLE KeyHandle;
59 OBJECT_ATTRIBUTES ObAttr;
60 // http://support.microsoft.com/kb/324097
61 ULONG Ret = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
62 PKEY_VALUE_PARTIAL_INFORMATION pKeyInfo;
63 ULONG Size = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + MAX_PATH*sizeof(WCHAR);
64 UNICODE_STRING Language;
65
66 RtlInitUnicodeString( &Language,
67 L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Nls\\Language");
68
69 InitializeObjectAttributes( &ObAttr,
70 &Language,
71 OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
72 NULL,
73 NULL);
74
75 if ( NT_SUCCESS(ZwOpenKey(&KeyHandle, KEY_READ, &ObAttr)))
76 {
77 pKeyInfo = ExAllocatePoolWithTag(PagedPool, Size, TAG_STRING);
78 if ( pKeyInfo )
79 {
80 RtlInitUnicodeString(&Language, L"Default");
81
82 if ( NT_SUCCESS(ZwQueryValueKey( KeyHandle,
83 &Language,
84 KeyValuePartialInformation,
85 pKeyInfo,
86 Size,
87 &Size)) )
88 {
89 RtlInitUnicodeString(&Language, (PWSTR)pKeyInfo->Data);
90 if (!NT_SUCCESS(RtlUnicodeStringToInteger(&Language, 16, &Ret)))
91 {
92 Ret = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
93 }
94 }
95 ExFreePoolWithTag(pKeyInfo, TAG_STRING);
96 }
97 ZwClose(KeyHandle);
98 }
99 TRACE("Language ID = %x\n",Ret);
100 return (SHORT) Ret;
101 }
102
103 HBRUSH
104 FASTCALL
105 GetControlColor(
106 PWND pwndParent,
107 PWND pwnd,
108 HDC hdc,
109 UINT CtlMsg)
110 {
111 HBRUSH hBrush;
112
113 if (!pwndParent) pwndParent = pwnd;
114
115 if ( pwndParent->head.pti->ppi != PsGetCurrentProcessWin32Process())
116 {
117 return (HBRUSH)IntDefWindowProc( pwndParent, CtlMsg, (WPARAM)hdc, (LPARAM)UserHMGetHandle(pwnd), FALSE);
118 }
119
120 hBrush = (HBRUSH)co_IntSendMessage( UserHMGetHandle(pwndParent), CtlMsg, (WPARAM)hdc, (LPARAM)UserHMGetHandle(pwnd));
121
122 if (!hBrush || !GreIsHandleValid(hBrush))
123 {
124 hBrush = (HBRUSH)IntDefWindowProc( pwndParent, CtlMsg, (WPARAM)hdc, (LPARAM)UserHMGetHandle(pwnd), FALSE);
125 }
126 return hBrush;
127 }
128
129 HBRUSH
130 FASTCALL
131 GetControlBrush(
132 PWND pwnd,
133 HDC hdc,
134 UINT ctlType)
135 {
136 PWND pwndParent = IntGetParent(pwnd);
137 return GetControlColor( pwndParent, pwnd, hdc, ctlType);
138 }
139
140 HBRUSH
141 APIENTRY
142 NtUserGetControlBrush(
143 HWND hwnd,
144 HDC hdc,
145 UINT ctlType)
146 {
147 PWND pwnd;
148 HBRUSH hBrush = NULL;
149
150 UserEnterExclusive();
151 if ( (pwnd = UserGetWindowObject(hwnd)) &&
152 ((ctlType - WM_CTLCOLORMSGBOX) < CTLCOLOR_MAX) &&
153 hdc )
154 {
155 hBrush = GetControlBrush(pwnd, hdc, ctlType);
156 }
157 UserLeave();
158 return hBrush;
159 }
160
161 /*
162 * Called from PaintRect, works almost like wine PaintRect16 but returns hBrush.
163 */
164 HBRUSH
165 APIENTRY
166 NtUserGetControlColor(
167 HWND hwndParent,
168 HWND hwnd,
169 HDC hdc,
170 UINT CtlMsg) // Wine PaintRect: WM_CTLCOLORMSGBOX + hbrush
171 {
172 PWND pwnd, pwndParent = NULL;
173 HBRUSH hBrush = NULL;
174
175 UserEnterExclusive();
176 if ( (pwnd = UserGetWindowObject(hwnd)) &&
177 ((CtlMsg - WM_CTLCOLORMSGBOX) < CTLCOLOR_MAX) &&
178 hdc )
179 {
180 if (hwndParent) pwndParent = UserGetWindowObject(hwndParent);
181 hBrush = GetControlColor( pwndParent, pwnd, hdc, CtlMsg);
182 }
183 UserLeave();
184 return hBrush;
185 }
186
187 /*
188 * @unimplemented
189 */
190 DWORD_PTR APIENTRY
191 NtUserGetThreadState(
192 DWORD Routine)
193 {
194 DWORD_PTR ret = 0;
195
196 TRACE("Enter NtUserGetThreadState\n");
197 if (Routine != THREADSTATE_GETTHREADINFO)
198 {
199 UserEnterShared();
200 }
201 else
202 {
203 UserEnterExclusive();
204 }
205
206 switch (Routine)
207 {
208 case THREADSTATE_GETTHREADINFO:
209 GetW32ThreadInfo();
210 break;
211 case THREADSTATE_FOCUSWINDOW:
212 ret = (DWORD_PTR)IntGetThreadFocusWindow();
213 break;
214 case THREADSTATE_CAPTUREWINDOW:
215 /* FIXME: Should use UserEnterShared */
216 ret = (DWORD_PTR)IntGetCapture();
217 break;
218 case THREADSTATE_PROGMANWINDOW:
219 ret = (DWORD_PTR)GetW32ThreadInfo()->pDeskInfo->hProgmanWindow;
220 break;
221 case THREADSTATE_TASKMANWINDOW:
222 ret = (DWORD_PTR)GetW32ThreadInfo()->pDeskInfo->hTaskManWindow;
223 break;
224 case THREADSTATE_ACTIVEWINDOW:
225 ret = (DWORD_PTR)UserGetActiveWindow();
226 break;
227 case THREADSTATE_INSENDMESSAGE:
228 {
229 PUSER_SENT_MESSAGE Message =
230 ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->pusmCurrent;
231 ERR("THREADSTATE_INSENDMESSAGE\n");
232
233 ret = ISMEX_NOSEND;
234 if (Message)
235 {
236 if (Message->ptiSender)
237 ret = ISMEX_SEND;
238 else
239 {
240 if (Message->CompletionCallback)
241 ret = ISMEX_CALLBACK;
242 else
243 ret = ISMEX_NOTIFY;
244 }
245 /* If ReplyMessage */
246 if (Message->QS_Flags & QS_SMRESULT) ret |= ISMEX_REPLIED;
247 }
248
249 break;
250 }
251 case THREADSTATE_GETMESSAGETIME:
252 ret = ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->timeLast;
253 break;
254
255 case THREADSTATE_UPTIMELASTREAD:
256 {
257 PTHREADINFO pti;
258 LARGE_INTEGER LargeTickCount;
259 pti = PsGetCurrentThreadWin32Thread();
260 KeQueryTickCount(&LargeTickCount);
261 pti->timeLast = LargeTickCount.u.LowPart;
262 pti->pcti->tickLastMsgChecked = LargeTickCount.u.LowPart;
263 }
264 break;
265
266 case THREADSTATE_GETINPUTSTATE:
267 ret = LOWORD(IntGetQueueStatus(QS_POSTMESSAGE|QS_TIMER|QS_PAINT|QS_SENDMESSAGE|QS_INPUT)) & (QS_KEY | QS_MOUSEBUTTON);
268 break;
269
270 case THREADSTATE_FOREGROUNDTHREAD:
271 ret = (gpqForeground == GetW32ThreadInfo()->MessageQueue);
272 break;
273 case THREADSTATE_GETCURSOR:
274 ret = (DWORD_PTR) (GetW32ThreadInfo()->MessageQueue->CursorObject ?
275 UserHMGetHandle(GetW32ThreadInfo()->MessageQueue->CursorObject) : 0);
276 break;
277 case THREADSTATE_GETMESSAGEEXTRAINFO:
278 ret = (DWORD_PTR)MsqGetMessageExtraInfo();
279 break;
280 }
281
282 TRACE("Leave NtUserGetThreadState, ret=%lu\n", ret);
283 UserLeave();
284
285 return ret;
286 }
287
288 DWORD
289 APIENTRY
290 NtUserSetThreadState(
291 DWORD Set,
292 DWORD Flags)
293 {
294 PTHREADINFO pti;
295 DWORD Ret = 0;
296 // Test the only flags user can change.
297 if (Set & ~(QF_FF10STATUS|QF_DIALOGACTIVE|QF_TABSWITCHING|QF_FMENUSTATUS|QF_FMENUSTATUSBREAK)) return 0;
298 if (Flags & ~(QF_FF10STATUS|QF_DIALOGACTIVE|QF_TABSWITCHING|QF_FMENUSTATUS|QF_FMENUSTATUSBREAK)) return 0;
299 UserEnterExclusive();
300 pti = PsGetCurrentThreadWin32Thread();
301 if (pti->MessageQueue)
302 {
303 Ret = pti->MessageQueue->QF_flags; // Get the queue flags.
304 if (Set)
305 pti->MessageQueue->QF_flags |= (Set&Flags); // Set the queue flags.
306 else
307 {
308 if (Flags) pti->MessageQueue->QF_flags &= ~Flags; // Clr the queue flags.
309 }
310 }
311 UserLeave();
312 return Ret;
313 }
314
315 UINT
316 APIENTRY
317 NtUserGetDoubleClickTime(VOID)
318 {
319 UINT Result;
320
321 TRACE("Enter NtUserGetDoubleClickTime\n");
322 UserEnterShared();
323
324 // FIXME: Check if this works on non-interactive winsta
325 Result = gspv.iDblClickTime;
326
327 TRACE("Leave NtUserGetDoubleClickTime, ret=%u\n", Result);
328 UserLeave();
329 return Result;
330 }
331
332 BOOL
333 APIENTRY
334 NtUserGetGUIThreadInfo(
335 DWORD idThread, /* If NULL use foreground thread */
336 LPGUITHREADINFO lpgui)
337 {
338 NTSTATUS Status;
339 PTHRDCARETINFO CaretInfo;
340 GUITHREADINFO SafeGui;
341 PDESKTOP Desktop;
342 PUSER_MESSAGE_QUEUE MsgQueue;
343 PTHREADINFO W32Thread;
344 PETHREAD Thread = NULL;
345
346 DECLARE_RETURN(BOOLEAN);
347
348 TRACE("Enter NtUserGetGUIThreadInfo\n");
349 UserEnterShared();
350
351 Status = MmCopyFromCaller(&SafeGui, lpgui, sizeof(DWORD));
352 if(!NT_SUCCESS(Status))
353 {
354 SetLastNtError(Status);
355 RETURN( FALSE);
356 }
357
358 if(SafeGui.cbSize != sizeof(GUITHREADINFO))
359 {
360 EngSetLastError(ERROR_INVALID_PARAMETER);
361 RETURN( FALSE);
362 }
363
364 if (idThread)
365 {
366 Status = PsLookupThreadByThreadId((HANDLE)(DWORD_PTR)idThread, &Thread);
367 if(!NT_SUCCESS(Status))
368 {
369 EngSetLastError(ERROR_ACCESS_DENIED);
370 RETURN( FALSE);
371 }
372 W32Thread = (PTHREADINFO)Thread->Tcb.Win32Thread;
373 Desktop = W32Thread->rpdesk;
374 }
375 else
376 { /* Get the foreground thread */
377 Thread = PsGetCurrentThread();
378 W32Thread = (PTHREADINFO)Thread->Tcb.Win32Thread;
379 Desktop = W32Thread->rpdesk;
380 }
381
382 if (!Thread || !Desktop )
383 {
384 if(idThread && Thread)
385 ObDereferenceObject(Thread);
386 EngSetLastError(ERROR_ACCESS_DENIED);
387 RETURN( FALSE);
388 }
389
390 if ( W32Thread->MessageQueue )
391 MsgQueue = W32Thread->MessageQueue;
392 else
393 {
394 if ( Desktop ) MsgQueue = Desktop->ActiveMessageQueue;
395 }
396
397 CaretInfo = &MsgQueue->CaretInfo;
398
399 SafeGui.flags = (CaretInfo->Visible ? GUI_CARETBLINKING : 0);
400 /*
401 if (W32Thread->pMenuState->pGlobalPopupMenu)
402 {
403 SafeGui.flags |= GUI_INMENUMODE;
404
405 if (W32Thread->pMenuState->pGlobalPopupMenu->spwndNotify)
406 SafeGui.hwndMenuOwner = UserHMGetHandle(W32Thread->pMenuState->pGlobalPopupMenu->spwndNotify);
407
408 if (W32Thread->pMenuState->pGlobalPopupMenu->fHasMenuBar)
409 {
410 if (W32Thread->pMenuState->pGlobalPopupMenu->fIsSysMenu)
411 {
412 SafeGui.flags |= GUI_SYSTEMMENUMODE;
413 }
414 }
415 else
416 {
417 SafeGui.flags |= GUI_POPUPMENUMODE;
418 }
419 }
420 */
421 SafeGui.hwndMenuOwner = MsgQueue->MenuOwner;
422
423 if (MsgQueue->MenuOwner)
424 SafeGui.flags |= GUI_INMENUMODE | MsgQueue->MenuState;
425
426 if (MsgQueue->MoveSize)
427 SafeGui.flags |= GUI_INMOVESIZE;
428
429 /* FIXME: Add flag GUI_16BITTASK */
430
431 SafeGui.hwndActive = MsgQueue->spwndActive ? UserHMGetHandle(MsgQueue->spwndActive) : 0;
432 SafeGui.hwndFocus = MsgQueue->spwndFocus ? UserHMGetHandle(MsgQueue->spwndFocus) : 0;
433 SafeGui.hwndCapture = MsgQueue->spwndCapture ? UserHMGetHandle(MsgQueue->spwndCapture) : 0;
434 SafeGui.hwndMoveSize = MsgQueue->MoveSize;
435 SafeGui.hwndCaret = CaretInfo->hWnd;
436
437 SafeGui.rcCaret.left = CaretInfo->Pos.x;
438 SafeGui.rcCaret.top = CaretInfo->Pos.y;
439 SafeGui.rcCaret.right = SafeGui.rcCaret.left + CaretInfo->Size.cx;
440 SafeGui.rcCaret.bottom = SafeGui.rcCaret.top + CaretInfo->Size.cy;
441
442 if (idThread)
443 ObDereferenceObject(Thread);
444
445 Status = MmCopyToCaller(lpgui, &SafeGui, sizeof(GUITHREADINFO));
446 if(!NT_SUCCESS(Status))
447 {
448 SetLastNtError(Status);
449 RETURN( FALSE);
450 }
451
452 RETURN( TRUE);
453
454 CLEANUP:
455 TRACE("Leave NtUserGetGUIThreadInfo, ret=%u\n",_ret_);
456 UserLeave();
457 END_CLEANUP;
458 }
459
460
461 DWORD
462 APIENTRY
463 NtUserGetGuiResources(
464 HANDLE hProcess,
465 DWORD uiFlags)
466 {
467 PEPROCESS Process;
468 PPROCESSINFO W32Process;
469 NTSTATUS Status;
470 DWORD Ret = 0;
471 DECLARE_RETURN(DWORD);
472
473 TRACE("Enter NtUserGetGuiResources\n");
474 UserEnterShared();
475
476 Status = ObReferenceObjectByHandle(hProcess,
477 PROCESS_QUERY_INFORMATION,
478 *PsProcessType,
479 ExGetPreviousMode(),
480 (PVOID*)&Process,
481 NULL);
482
483 if(!NT_SUCCESS(Status))
484 {
485 SetLastNtError(Status);
486 RETURN( 0);
487 }
488
489 W32Process = (PPROCESSINFO)Process->Win32Process;
490 if(!W32Process)
491 {
492 ObDereferenceObject(Process);
493 EngSetLastError(ERROR_INVALID_PARAMETER);
494 RETURN( 0);
495 }
496
497 switch(uiFlags)
498 {
499 case GR_GDIOBJECTS:
500 {
501 Ret = (DWORD)W32Process->GDIHandleCount;
502 break;
503 }
504 case GR_USEROBJECTS:
505 {
506 Ret = (DWORD)W32Process->UserHandleCount;
507 break;
508 }
509 default:
510 {
511 EngSetLastError(ERROR_INVALID_PARAMETER);
512 break;
513 }
514 }
515
516 ObDereferenceObject(Process);
517
518 RETURN( Ret);
519
520 CLEANUP:
521 TRACE("Leave NtUserGetGuiResources, ret=%lu\n",_ret_);
522 UserLeave();
523 END_CLEANUP;
524 }
525
526 VOID FASTCALL
527 IntSetWindowState(PWND pWnd, UINT Flag)
528 {
529 UINT bit;
530 if (gptiCurrent->ppi != pWnd->head.pti->ppi) return;
531 bit = 1 << LOWORD(Flag);
532 TRACE("SWS %x\n",bit);
533 switch(HIWORD(Flag))
534 {
535 case 0:
536 pWnd->state |= bit;
537 break;
538 case 1:
539 pWnd->state2 |= bit;
540 break;
541 case 2:
542 pWnd->ExStyle2 |= bit;
543 break;
544 }
545 }
546
547 VOID FASTCALL
548 IntClearWindowState(PWND pWnd, UINT Flag)
549 {
550 UINT bit;
551 if (gptiCurrent->ppi != pWnd->head.pti->ppi) return;
552 bit = 1 << LOWORD(Flag);
553 TRACE("CWS %x\n",bit);
554 switch(HIWORD(Flag))
555 {
556 case 0:
557 pWnd->state &= ~bit;
558 break;
559 case 1:
560 pWnd->state2 &= ~bit;
561 break;
562 case 2:
563 pWnd->ExStyle2 &= ~bit;
564 break;
565 }
566 }
567
568 NTSTATUS FASTCALL
569 IntSafeCopyUnicodeString(PUNICODE_STRING Dest,
570 PUNICODE_STRING Source)
571 {
572 NTSTATUS Status;
573 PWSTR Src;
574
575 Status = MmCopyFromCaller(Dest, Source, sizeof(UNICODE_STRING));
576 if(!NT_SUCCESS(Status))
577 {
578 return Status;
579 }
580
581 if(Dest->Length > 0x4000)
582 {
583 return STATUS_UNSUCCESSFUL;
584 }
585
586 Src = Dest->Buffer;
587 Dest->Buffer = NULL;
588 Dest->MaximumLength = Dest->Length;
589
590 if(Dest->Length > 0 && Src)
591 {
592 Dest->Buffer = ExAllocatePoolWithTag(PagedPool, Dest->MaximumLength, TAG_STRING);
593 if(!Dest->Buffer)
594 {
595 return STATUS_NO_MEMORY;
596 }
597
598 Status = MmCopyFromCaller(Dest->Buffer, Src, Dest->Length);
599 if(!NT_SUCCESS(Status))
600 {
601 ExFreePoolWithTag(Dest->Buffer, TAG_STRING);
602 Dest->Buffer = NULL;
603 return Status;
604 }
605
606
607 return STATUS_SUCCESS;
608 }
609
610 /* String is empty */
611 return STATUS_SUCCESS;
612 }
613
614 NTSTATUS FASTCALL
615 IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest,
616 PUNICODE_STRING Source)
617 {
618 NTSTATUS Status;
619 PWSTR Src;
620
621 Status = MmCopyFromCaller(Dest, Source, sizeof(UNICODE_STRING));
622 if(!NT_SUCCESS(Status))
623 {
624 return Status;
625 }
626
627 if(Dest->Length > 0x4000)
628 {
629 return STATUS_UNSUCCESSFUL;
630 }
631
632 Src = Dest->Buffer;
633 Dest->Buffer = NULL;
634 Dest->MaximumLength = 0;
635
636 if(Dest->Length > 0 && Src)
637 {
638 Dest->MaximumLength = Dest->Length + sizeof(WCHAR);
639 Dest->Buffer = ExAllocatePoolWithTag(PagedPool, Dest->MaximumLength, TAG_STRING);
640 if(!Dest->Buffer)
641 {
642 return STATUS_NO_MEMORY;
643 }
644
645 Status = MmCopyFromCaller(Dest->Buffer, Src, Dest->Length);
646 if(!NT_SUCCESS(Status))
647 {
648 ExFreePoolWithTag(Dest->Buffer, TAG_STRING);
649 Dest->Buffer = NULL;
650 return Status;
651 }
652
653 /* Make sure the string is null-terminated */
654 Src = (PWSTR)((PBYTE)Dest->Buffer + Dest->Length);
655 *Src = L'\0';
656
657 return STATUS_SUCCESS;
658 }
659
660 /* String is empty */
661 return STATUS_SUCCESS;
662 }
663
664 void UserDbgAssertThreadInfo(BOOL showCaller)
665 {
666 PTEB Teb;
667 PPROCESSINFO ppi;
668 PCLIENTINFO pci;
669 PTHREADINFO pti;
670
671 ppi = PsGetCurrentProcessWin32Process();
672 pti = PsGetCurrentThreadWin32Thread();
673 Teb = NtCurrentTeb();
674 pci = GetWin32ClientInfo();
675
676 ASSERT(Teb);
677 ASSERT(pti);
678 ASSERT(pti->ppi == ppi);
679 ASSERT(pti->pClientInfo == pci);
680 ASSERT(Teb->Win32ThreadInfo == pti);
681 ASSERT(pci->ppi == ppi);
682 ASSERT(pci->fsHooks == pti->fsHooks);
683 ASSERT(pci->ulClientDelta == DesktopHeapGetUserDelta());
684 if (pti->pcti && pci->pDeskInfo)
685 ASSERT(pci->pClientThreadInfo == (PVOID)((ULONG_PTR)pti->pcti - pci->ulClientDelta));
686 if (pti->pcti && IsListEmpty(&pti->SentMessagesListHead))
687 ASSERT((pti->pcti->fsChangeBits & QS_SENDMESSAGE) == 0);
688 if (pti->KeyboardLayout)
689 ASSERT(pci->hKL == pti->KeyboardLayout->hkl);
690 if(pti->rpdesk != NULL)
691 ASSERT(pti->pDeskInfo == pti->rpdesk->pDeskInfo);
692
693 /*too bad we still get this assertion*/
694
695 // Why? Not all flags are passed to the user and doing so could crash the system........
696
697 /* ASSERT(pci->dwTIFlags == pti->TIF_flags); */
698 /* if(pci->dwTIFlags != pti->TIF_flags)
699 {
700 ERR("pci->dwTIFlags(0x%x) doesn't match pti->TIF_flags(0x%x)\n", pci->dwTIFlags, pti->TIF_flags);
701 if(showCaller)
702 {
703 DbgPrint("Caller:\n");
704 KeRosDumpStackFrames(NULL, 10);
705 }
706 pci->dwTIFlags = pti->TIF_flags;
707 }
708 */
709 }
710
711 void
712 NTAPI
713 UserDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments)
714 {
715 UserDbgAssertThreadInfo(FALSE);
716 }
717
718 ULONG_PTR
719 NTAPI
720 UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult)
721 {
722 /* Make sure that the first syscall is NtUserInitialize */
723 /* too bad this fails */
724 // ASSERT(gpepCSRSS);
725
726 UserDbgAssertThreadInfo(TRUE);
727
728 return ulResult;
729 }
730
731
732 PPROCESSINFO
733 GetW32ProcessInfo(VOID)
734 {
735 return (PPROCESSINFO)PsGetCurrentProcessWin32Process();
736 }
737
738 PTHREADINFO
739 GetW32ThreadInfo(VOID)
740 {
741 UserDbgAssertThreadInfo(TRUE);
742 return (PTHREADINFO)PsGetCurrentThreadWin32Thread();
743 }
744
745 /* EOF */