#define MIN_CARETBLINKRATE 100
#define MAX_CARETBLINKRATE 10000
-#define DEFAULT_CARETBLINKRATE 530
-#define CARET_REGKEY L"\\Registry\\User\\.Default\\Control Panel\\Desktop"
-#define CARET_VALUENAME L"CursorBlinkRate"
/* FUNCTIONS *****************************************************************/
IntSetCaretBlinkTime(UINT uMSeconds)
{
/* Don't save the new value to the registry! */
- PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
- PWINSTATION_OBJECT WinStaObject = pti->rpdesk->rpwinstaParent;
/* Windows doesn't do this check */
if((uMSeconds < MIN_CARETBLINKRATE) || (uMSeconds > MAX_CARETBLINKRATE))
{
EngSetLastError(ERROR_INVALID_PARAMETER);
- ObDereferenceObject(WinStaObject);
return FALSE;
}
- WinStaObject->CaretBlinkRate = uMSeconds;
gpsi->dtCaretBlink = uMSeconds;
return TRUE;
}
-static
-UINT FASTCALL
-IntQueryCaretBlinkRate(VOID)
-{
- UNICODE_STRING KeyName = RTL_CONSTANT_STRING(CARET_REGKEY);
- UNICODE_STRING ValueName = RTL_CONSTANT_STRING(CARET_VALUENAME);
- NTSTATUS Status;
- HANDLE KeyHandle = NULL;
- OBJECT_ATTRIBUTES KeyAttributes;
- PKEY_VALUE_PARTIAL_INFORMATION KeyValuePartialInfo;
- ULONG Length = 0;
- ULONG ResLength = 0;
- ULONG Val = 0;
-
- InitializeObjectAttributes(&KeyAttributes, &KeyName, OBJ_CASE_INSENSITIVE,
- NULL, NULL);
-
- Status = ZwOpenKey(&KeyHandle, KEY_READ, &KeyAttributes);
- if(!NT_SUCCESS(Status))
- {
- return 0;
- }
-
- Status = ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation,
- 0, 0, &ResLength);
- if((Status != STATUS_BUFFER_TOO_SMALL))
- {
- NtClose(KeyHandle);
- return 0;
- }
-
- ResLength += sizeof(KEY_VALUE_PARTIAL_INFORMATION);
- KeyValuePartialInfo = ExAllocatePoolWithTag(PagedPool, ResLength, TAG_STRING);
- Length = ResLength;
-
- if(!KeyValuePartialInfo)
- {
- NtClose(KeyHandle);
- return 0;
- }
-
- Status = ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation,
- (PVOID)KeyValuePartialInfo, Length, &ResLength);
- if(!NT_SUCCESS(Status) || (KeyValuePartialInfo->Type != REG_SZ))
- {
- NtClose(KeyHandle);
- ExFreePoolWithTag(KeyValuePartialInfo, TAG_STRING);
- return 0;
- }
-
- ValueName.Length = KeyValuePartialInfo->DataLength;
- ValueName.MaximumLength = KeyValuePartialInfo->DataLength;
- ValueName.Buffer = (PWSTR)KeyValuePartialInfo->Data;
-
- Status = RtlUnicodeStringToInteger(&ValueName, 0, &Val);
- if(!NT_SUCCESS(Status))
- {
- Val = 0;
- }
-
- ExFreePoolWithTag(KeyValuePartialInfo, TAG_STRING);
- NtClose(KeyHandle);
-
- return (UINT)Val;
-}
-
-static
-UINT FASTCALL
-IntGetCaretBlinkTime(VOID)
-{
- PTHREADINFO pti;
- PWINSTATION_OBJECT WinStaObject;
- UINT Ret;
-
- pti = PsGetCurrentThreadWin32Thread();
- WinStaObject = pti->rpdesk->rpwinstaParent;
-
- Ret = WinStaObject->CaretBlinkRate;
- if(!Ret)
- {
- /* Load it from the registry the first call only! */
- Ret = WinStaObject->CaretBlinkRate = IntQueryCaretBlinkRate();
- }
-
- /* Windows doesn't do this check */
- if((Ret < MIN_CARETBLINKRATE) || (Ret > MAX_CARETBLINKRATE))
- {
- Ret = DEFAULT_CARETBLINKRATE;
- }
-
- return Ret;
-}
-
-
BOOL FASTCALL
co_IntSetCaretPos(int X, int Y)
{
ThreadQueue->CaretInfo->Pos.x = X;
ThreadQueue->CaretInfo->Pos.y = Y;
co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
- IntSetTimer(UserGetWindowObject(ThreadQueue->CaretInfo->hWnd), IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TMRF_SYSTEM);
+ IntSetTimer(UserGetWindowObject(ThreadQueue->CaretInfo->hWnd), IDCARETTIMER, gpsi->dtCaretBlink, NULL, TMRF_SYSTEM);
IntNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, pWnd, OBJID_CARET, CHILDID_SELF, 0);
}
return TRUE;
co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
IntNotifyWinEvent(EVENT_OBJECT_SHOW, pWnd, OBJID_CARET, OBJID_CARET, 0);
}
- IntSetTimer(UserGetWindowObject(ThreadQueue->CaretInfo->hWnd), IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TMRF_SYSTEM);
+ IntSetTimer(UserGetWindowObject(ThreadQueue->CaretInfo->hWnd), IDCARETTIMER, gpsi->dtCaretBlink, NULL, TMRF_SYSTEM);
}
return TRUE;
}
APIENTRY
NtUserGetCaretBlinkTime(VOID)
{
- DECLARE_RETURN(UINT);
+ UINT ret;
- TRACE("Enter NtUserGetCaretBlinkTime\n");
UserEnterShared();
- RETURN(IntGetCaretBlinkTime());
+ ret = gpsi->dtCaretBlink;
-CLEANUP:
- TRACE("Leave NtUserGetCaretBlinkTime, ret=%i\n",_ret_);
UserLeave();
- END_CLEANUP;
+
+ return ret;
}
BOOL