ULONG FASTCALL IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG nSize) { NTSTATUS Status = STATUS_SUCCESS; PTHREADINFO pti; ULONG Size = nSize; pti = PsGetCurrentThreadWin32Thread(); if (pti->rpdesk == NULL) { SetLastNtError(Status); return 0; } Status = RtlQueryAtomInAtomTable(gAtomTable, nAtom, NULL, NULL, lpBuffer, &Size); if (Size < nSize) *(lpBuffer + Size) = 0; if (!NT_SUCCESS(Status)) { SetLastNtError(Status); return 0; } return Size; }
BOOL APIENTRY NtUserSBGetParms( HWND hWnd, int fnBar, PSBDATA pSBData, LPSCROLLINFO lpsi) { NTSTATUS Status; PWND Window; SCROLLINFO psi; DWORD sz; BOOL Ret; DECLARE_RETURN(BOOL); USER_REFERENCE_ENTRY Ref; TRACE("Enter NtUserGetScrollInfo\n"); UserEnterExclusive(); Status = MmCopyFromCaller(&psi.cbSize, &(lpsi->cbSize), sizeof(UINT)); if(!NT_SUCCESS(Status) || !((psi.cbSize == sizeof(SCROLLINFO)) || (psi.cbSize == sizeof(SCROLLINFO) - sizeof(psi.nTrackPos)))) { SetLastNtError(Status); RETURN(FALSE); } sz = psi.cbSize; Status = MmCopyFromCaller(&psi, lpsi, sz); if (!NT_SUCCESS(Status)) { SetLastNtError(Status); RETURN(FALSE); } if(!(Window = UserGetWindowObject(hWnd))) { RETURN(FALSE); } UserRefObjectCo(Window, &Ref); Ret = co_IntGetScrollInfo(Window, fnBar, &psi); UserDerefObjectCo(Window); Status = MmCopyToCaller(lpsi, &psi, sz); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); RETURN( FALSE); } RETURN( Ret); CLEANUP: TRACE("Leave NtUserGetScrollInfo, ret=%i\n",_ret_); UserLeave(); END_CLEANUP; }
INT APIENTRY NtGdiGetAppClipBox(HDC hDC, PRECTL rc) { INT Ret; NTSTATUS Status = STATUS_SUCCESS; RECTL Saferect; Ret = GdiGetClipBox(hDC, &Saferect); _SEH2_TRY { ProbeForWrite(rc, sizeof(RECT), 1); *rc = Saferect; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { Status = _SEH2_GetExceptionCode(); } _SEH2_END; if(!NT_SUCCESS(Status)) { SetLastNtError(Status); return ERROR; } return Ret; }
HWINSTA APIENTRY NtUserOpenWindowStation( POBJECT_ATTRIBUTES ObjectAttributes, ACCESS_MASK dwDesiredAccess) { HWINSTA hwinsta; NTSTATUS Status; Status = ObOpenObjectByName(ObjectAttributes, ExWindowStationObjectType, UserMode, NULL, dwDesiredAccess, NULL, (PVOID*)&hwinsta); if (!NT_SUCCESS(Status)) { ERR("NtUserOpenWindowStation failed\n"); SetLastNtError(Status); return 0; } TRACE("Opened window station %wZ with handle %p\n", ObjectAttributes->ObjectName, hwinsta); return hwinsta; }
HANDLE APIENTRY NtGdiCreateColorSpace( IN PLOGCOLORSPACEEXW pLogColorSpace) { LOGCOLORSPACEEXW Safelcs; NTSTATUS Status = STATUS_SUCCESS; _SEH2_TRY { ProbeForRead( pLogColorSpace, sizeof(LOGCOLORSPACEEXW), 1); RtlCopyMemory(&Safelcs, pLogColorSpace, sizeof(LOGCOLORSPACEEXW)); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { Status = _SEH2_GetExceptionCode(); } _SEH2_END; if (!NT_SUCCESS(Status)) { SetLastNtError(Status); return NULL; } return IntGdiCreateColorSpace(&Safelcs); }
NTSTATUS FASTCALL IntValidateWindowStationHandle( HWINSTA WindowStation, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PWINSTATION_OBJECT *Object, POBJECT_HANDLE_INFORMATION pObjectHandleInfo) { NTSTATUS Status; if (WindowStation == NULL) { ERR("Invalid window station handle\n"); EngSetLastError(ERROR_INVALID_HANDLE); return STATUS_INVALID_HANDLE; } Status = ObReferenceObjectByHandle(WindowStation, DesiredAccess, ExWindowStationObjectType, AccessMode, (PVOID*)Object, pObjectHandleInfo); if (!NT_SUCCESS(Status)) SetLastNtError(Status); return Status; }
BOOL APIENTRY NtUserLockWindowStation(HWINSTA hWindowStation) { PWINSTATION_OBJECT Object; NTSTATUS Status; TRACE("About to set process window station with handle (%p)\n", hWindowStation); if (gpidLogon != PsGetCurrentProcessId()) { ERR("Unauthorized process attempted to lock the window station!\n"); EngSetLastError(ERROR_ACCESS_DENIED); return FALSE; } Status = IntValidateWindowStationHandle(hWindowStation, UserMode, 0, &Object, 0); if (!NT_SUCCESS(Status)) { TRACE("Validation of window station handle (%p) failed\n", hWindowStation); SetLastNtError(Status); return FALSE; } Object->Flags |= WSS_LOCKED; ObDereferenceObject(Object); return TRUE; }
HANDLE APIENTRY NtUserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA pUnsafeScd) { SETCLIPBDATA scd; HANDLE hRet; TRACE("NtUserSetClipboardData(%x %p %p)\n", fmt, hData, pUnsafeScd); _SEH2_TRY { ProbeForRead(pUnsafeScd, sizeof(*pUnsafeScd), 1); RtlCopyMemory(&scd, pUnsafeScd, sizeof(scd)); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastNtError(_SEH2_GetExceptionCode()); _SEH2_YIELD(return NULL;) } _SEH2_END UserEnterExclusive(); /* Call internal function */ hRet = UserSetClipboardData(fmt, hData, &scd); UserLeave(); return hRet; }
/* * NtUserGetKeyboardLayoutName * * Returns KLID of current thread keyboard layout */ BOOL APIENTRY NtUserGetKeyboardLayoutName( LPWSTR pwszName) { BOOL bRet = FALSE; PKL pKl; PTHREADINFO pti; UserEnterShared(); pti = PsGetCurrentThreadWin32Thread(); pKl = pti->KeyboardLayout; if (!pKl) goto cleanup; _SEH2_TRY { ProbeForWrite(pwszName, KL_NAMELENGTH*sizeof(WCHAR), 1); wcscpy(pwszName, pKl->spkf->awchKF); bRet = TRUE; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastNtError(_SEH2_GetExceptionCode()); } _SEH2_END; cleanup: UserLeave(); return bRet; }
BOOL APIENTRY NtUserGetCaretPos( LPPOINT lpPoint) { PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; NTSTATUS Status; DECLARE_RETURN(BOOL); TRACE("Enter NtUserGetCaretPos\n"); UserEnterShared(); pti = PsGetCurrentThreadWin32Thread(); ThreadQueue = pti->MessageQueue; Status = MmCopyToCaller(lpPoint, &(ThreadQueue->CaretInfo->Pos), sizeof(POINT)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); RETURN(FALSE); } RETURN(TRUE); CLEANUP: TRACE("Leave NtUserGetCaretPos, ret=%i\n",_ret_); UserLeave(); END_CLEANUP; }
BOOL APIENTRY NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi) { NTSTATUS Status; SCROLLBARINFO sbi; PWND Window; BOOL Ret; DECLARE_RETURN(BOOL); USER_REFERENCE_ENTRY Ref; TRACE("Enter NtUserGetScrollBarInfo\n"); UserEnterExclusive(); Status = MmCopyFromCaller(&sbi, psbi, sizeof(SCROLLBARINFO)); if(!NT_SUCCESS(Status) || (sbi.cbSize != sizeof(SCROLLBARINFO))) { SetLastNtError(Status); RETURN(FALSE); } if(!(Window = UserGetWindowObject(hWnd))) { RETURN(FALSE); } UserRefObjectCo(Window, &Ref); Ret = co_IntGetScrollBarInfo(Window, idObject, &sbi); UserDerefObjectCo(Window); Status = MmCopyToCaller(psbi, &sbi, sizeof(SCROLLBARINFO)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); Ret = FALSE; } RETURN( Ret); CLEANUP: TRACE("Leave NtUserGetScrollBarInfo, ret=%i\n",_ret_); UserLeave(); END_CLEANUP; }
ULONG APIENTRY NtUserCopyAcceleratorTable( HACCEL hAccel, LPACCEL Entries, ULONG EntriesCount) { PACCELERATOR_TABLE Accel; ULONG Ret; DECLARE_RETURN(int); TRACE("Enter NtUserCopyAcceleratorTable\n"); UserEnterShared(); Accel = UserGetAccelObject(hAccel); if (!Accel) { RETURN(0); } /* If Entries is NULL return table size */ if (!Entries) { RETURN(Accel->Count); } /* Don't overrun */ if (Accel->Count < EntriesCount) EntriesCount = Accel->Count; Ret = 0; _SEH2_TRY { ProbeForWrite(Entries, EntriesCount*sizeof(Entries[0]), 4); for (Ret = 0; Ret < EntriesCount; Ret++) { Entries[Ret].fVirt = Accel->Table[Ret].fVirt; Entries[Ret].key = Accel->Table[Ret].key; Entries[Ret].cmd = Accel->Table[Ret].cmd; } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastNtError(_SEH2_GetExceptionCode()); Ret = 0; } _SEH2_END; RETURN(Ret); CLEANUP: TRACE("Leave NtUserCopyAcceleratorTable, ret=%i\n", _ret_); UserLeave(); END_CLEANUP; }
BOOL APIENTRY NtGdiGetDeviceGammaRamp(HDC hDC, LPVOID Ramp) { BOOL Ret; PDC dc; NTSTATUS Status = STATUS_SUCCESS; PGAMMARAMP SafeRamp; if (!Ramp) return FALSE; dc = DC_LockDc(hDC); if (!dc) { EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } SafeRamp = ExAllocatePoolWithTag(PagedPool, sizeof(GAMMARAMP), GDITAG_ICM); if (!SafeRamp) { DC_UnlockDc(dc); EngSetLastError(STATUS_NO_MEMORY); return FALSE; } Ret = IntGetDeviceGammaRamp((HDEV)dc->ppdev, SafeRamp); if (!Ret) return Ret; _SEH2_TRY { ProbeForWrite( Ramp, sizeof(PVOID), 1); RtlCopyMemory( Ramp, SafeRamp, sizeof(GAMMARAMP)); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { Status = _SEH2_GetExceptionCode(); } _SEH2_END; DC_UnlockDc(dc); ExFreePoolWithTag(SafeRamp, GDITAG_ICM); if (!NT_SUCCESS(Status)) { SetLastNtError(Status); return FALSE; } return Ret; }
/* * NtUserGetKeyboardLayoutList * * Returns list of loaded keyboard layouts in system */ UINT APIENTRY NtUserGetKeyboardLayoutList( ULONG nBuff, HKL *pHklBuff) { UINT uRet = 0; PKL pKl; if (!pHklBuff) nBuff = 0; UserEnterShared(); if (!gspklBaseLayout) { UserLeave(); return 0; } pKl = gspklBaseLayout; if (nBuff == 0) { do { uRet++; pKl = pKl->pklNext; } while (pKl != gspklBaseLayout); } else { _SEH2_TRY { ProbeForWrite(pHklBuff, nBuff*sizeof(HKL), 4); while (uRet < nBuff) { pHklBuff[uRet] = pKl->hkl; uRet++; pKl = pKl->pklNext; if (pKl == gspklBaseLayout) break; } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastNtError(_SEH2_GetExceptionCode()); uRet = 0; } _SEH2_END; } UserLeave(); return uRet; }
HDC APIENTRY NtGdiOpenDCW( PUNICODE_STRING pustrDevice, DEVMODEW *pdmInit, PUNICODE_STRING pustrLogAddr, ULONG iType, BOOL bDisplay, HANDLE hspool, VOID *pDriverInfo2, VOID *pUMdhpdev) { UNICODE_STRING ustrDevice; WCHAR awcDevice[CCHDEVICENAME]; DEVMODEW dmInit; PVOID dhpdev; HDC hdc; /* Only if a devicename is given, we need any data */ if (pustrDevice) { /* Initialize destination string */ RtlInitEmptyUnicodeString(&ustrDevice, awcDevice, sizeof(awcDevice)); _SEH2_TRY { /* Probe the UNICODE_STRING and the buffer */ ProbeForRead(pustrDevice, sizeof(UNICODE_STRING), 1); ProbeForRead(pustrDevice->Buffer, pustrDevice->Length, 1); /* Copy the string */ RtlCopyUnicodeString(&ustrDevice, pustrDevice); if (pdmInit) { /* FIXME: could be larger */ ProbeForRead(pdmInit, sizeof(DEVMODEW), 1); RtlCopyMemory(&dmInit, pdmInit, sizeof(DEVMODEW)); } if (pUMdhpdev) { ProbeForWrite(pUMdhpdev, sizeof(HANDLE), 1); } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastNtError(_SEH2_GetExceptionCode()); _SEH2_YIELD(return NULL); } _SEH2_END } else {
/* * @implemented */ BOOL APIENTRY NtUserGetCursorInfo( PCURSORINFO pci) { CURSORINFO SafeCi; PSYSTEM_CURSORINFO CurInfo; NTSTATUS Status = STATUS_SUCCESS; PCURICON_OBJECT CurIcon; BOOL Ret = FALSE; DECLARE_RETURN(BOOL); TRACE("Enter NtUserGetCursorInfo\n"); UserEnterExclusive(); CurInfo = IntGetSysCursorInfo(); CurIcon = (PCURICON_OBJECT)CurInfo->CurrentCursorObject; SafeCi.cbSize = sizeof(CURSORINFO); SafeCi.flags = ((CurIcon && CurInfo->ShowingCursor >= 0) ? CURSOR_SHOWING : 0); SafeCi.hCursor = (CurIcon ? CurIcon->head.h : NULL); SafeCi.ptScreenPos = gpsi->ptCursor; _SEH2_TRY { if (pci->cbSize == sizeof(CURSORINFO)) { ProbeForWrite(pci, sizeof(CURSORINFO), 1); RtlCopyMemory(pci, &SafeCi, sizeof(CURSORINFO)); Ret = TRUE; } else { EngSetLastError(ERROR_INVALID_PARAMETER); } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { Status = _SEH2_GetExceptionCode(); } _SEH2_END; if (!NT_SUCCESS(Status)) { SetLastNtError(Status); } RETURN(Ret); CLEANUP: TRACE("Leave NtUserGetCursorInfo, ret=%i\n",_ret_); UserLeave(); END_CLEANUP; }
/* * @implemented */ BOOL APIENTRY NtUserGetIconSize( HANDLE hCurIcon, UINT istepIfAniCur, PLONG plcx, // &size.cx PLONG plcy) // &size.cy { PCURICON_OBJECT CurIcon; NTSTATUS Status = STATUS_SUCCESS; BOOL bRet = FALSE; TRACE("Enter NtUserGetIconSize\n"); UserEnterExclusive(); if (!(CurIcon = UserGetCurIconObject(hCurIcon))) { goto cleanup; } if(CurIcon->CURSORF_flags & CURSORF_ACON) { /* Use first frame for animated cursors */ PACON AniCurIcon = (PACON)CurIcon; CurIcon = AniCurIcon->aspcur[0]; UserDereferenceObject(AniCurIcon); UserReferenceObject(CurIcon); } _SEH2_TRY { ProbeForWrite(plcx, sizeof(LONG), 1); *plcx = CurIcon->cx; ProbeForWrite(plcy, sizeof(LONG), 1); *plcy = CurIcon->cy; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { Status = _SEH2_GetExceptionCode(); } _SEH2_END if (NT_SUCCESS(Status)) bRet = TRUE; else SetLastNtError(Status); // Maybe not, test this UserDereferenceObject(CurIcon); cleanup: TRACE("Leave NtUserGetIconSize, ret=%i\n", bRet); UserLeave(); return bRet; }
BOOL FASTCALL UserSetProcessWindowStation(HWINSTA hWindowStation) { PPROCESSINFO ppi; NTSTATUS Status; HWINSTA hwinstaOld; PWINSTATION_OBJECT NewWinSta = NULL, OldWinSta; ppi = PsGetCurrentProcessWin32Process(); /* Reference the new window station */ if(hWindowStation !=NULL) { Status = IntValidateWindowStationHandle( hWindowStation, KernelMode, 0, &NewWinSta); if (!NT_SUCCESS(Status)) { TRACE("Validation of window station handle (0x%X) failed\n", hWindowStation); SetLastNtError(Status); return FALSE; } } OldWinSta = ppi->prpwinsta; hwinstaOld = PsGetProcessWin32WindowStation(ppi->peProcess); /* Dereference the previous window station */ if(OldWinSta != NULL) { ObDereferenceObject(OldWinSta); } /* Check if we have a stale handle (it should happen for console apps) */ if(hwinstaOld != ppi->hwinsta) { ObCloseHandle(hwinstaOld, UserMode); } /* * FIXME: Don't allow changing the window station if there are threads that are attached to desktops and own GUI objects. */ PsSetProcessWindowStation(ppi->peProcess, hWindowStation); ppi->prpwinsta = NewWinSta; ppi->hwinsta = hWindowStation; return TRUE; }
BOOL APIENTRY NtUserSetObjectInformation( HANDLE hObject, DWORD nIndex, PVOID pvInformation, DWORD nLength) { /* FIXME: ZwQueryObject */ /* FIXME: ZwSetInformationObject */ SetLastNtError(STATUS_UNSUCCESSFUL); return FALSE; }
RTL_ATOM FASTCALL IntAddAtom(LPWSTR AtomName) { NTSTATUS Status = STATUS_SUCCESS; PTHREADINFO pti; RTL_ATOM Atom; pti = PsGetCurrentThreadWin32Thread(); if (pti->rpdesk == NULL) { SetLastNtError(Status); return (RTL_ATOM)0; } Status = RtlAddAtomToAtomTable(gAtomTable, AtomName, &Atom); if (!NT_SUCCESS(Status)) { SetLastNtError(Status); return (RTL_ATOM)0; } return Atom; }
INT APIENTRY NtUserGetPriorityClipboardFormat(UINT *paFormatPriorityList, INT cFormats) { INT i, iRet = 0; PWINSTATION_OBJECT pWinStaObj; UserEnterShared(); pWinStaObj = IntGetWinStaForCbAccess(); if (!pWinStaObj) goto cleanup; if (pWinStaObj->pClipBase == NULL) { iRet = 0; } else { _SEH2_TRY { ProbeForRead(paFormatPriorityList, cFormats * sizeof(UINT), sizeof(UINT)); iRet = -1; for (i = 0; i < cFormats; ++i) { if (IntIsFormatAvailable(pWinStaObj, paFormatPriorityList[i])) { iRet = paFormatPriorityList[i]; break; } } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastNtError(_SEH2_GetExceptionCode()); } _SEH2_END; } ObDereferenceObject(pWinStaObj); cleanup: UserLeave(); return iRet; }
BOOL APIENTRY NtGdiRectVisible(HDC hDC, LPRECT UnsafeRect) { NTSTATUS Status = STATUS_SUCCESS; PROSRGNDATA Rgn; PDC dc = DC_LockDc(hDC); BOOL Result = FALSE; RECTL Rect; if (!dc) { EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } _SEH2_TRY { ProbeForRead(UnsafeRect, sizeof(RECT), 1); Rect = *UnsafeRect; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { Status = _SEH2_GetExceptionCode(); } _SEH2_END; if(!NT_SUCCESS(Status)) { DC_UnlockDc(dc); SetLastNtError(Status); return FALSE; } if (dc->rosdc.hGCClipRgn) { if((Rgn = (PROSRGNDATA)RGNOBJAPI_Lock(dc->rosdc.hGCClipRgn, NULL))) { IntLPtoDP(dc, (LPPOINT)&Rect, 2); Result = REGION_RectInRegion(Rgn, &Rect); RGNOBJAPI_Unlock(Rgn); } } DC_UnlockDc(dc); return Result; }
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID) { HWINSTA hWinSta; PWINSTATION_OBJECT pWinStaObj; NTSTATUS Status; hWinSta = UserGetProcessWindowStation(); Status = IntValidateWindowStationHandle(hWinSta, KernelMode, WINSTA_ACCESSCLIPBOARD, &pWinStaObj, 0); if (!NT_SUCCESS(Status)) { ERR("Cannot open winsta\n"); SetLastNtError(Status); return NULL; } return pWinStaObj; }
/* * @implemented */ BOOL APIENTRY NtUserGetClipCursor( RECTL *lpRect) { /* FIXME: Check if process has WINSTA_READATTRIBUTES */ PSYSTEM_CURSORINFO CurInfo; RECTL Rect; NTSTATUS Status; DECLARE_RETURN(BOOL); TRACE("Enter NtUserGetClipCursor\n"); UserEnterExclusive(); if (!lpRect) RETURN(FALSE); CurInfo = IntGetSysCursorInfo(); if (CurInfo->bClipped) { Rect = CurInfo->rcClip; } else { Rect.left = 0; Rect.top = 0; Rect.right = UserGetSystemMetrics(SM_CXSCREEN); Rect.bottom = UserGetSystemMetrics(SM_CYSCREEN); } Status = MmCopyToCaller(lpRect, &Rect, sizeof(RECT)); if (!NT_SUCCESS(Status)) { SetLastNtError(Status); RETURN(FALSE); } RETURN(TRUE); CLEANUP: TRACE("Leave NtUserGetClipCursor, ret=%i\n",_ret_); UserLeave(); END_CLEANUP; }
BOOL APIENTRY NtGdiPolyPatBlt( HDC hDC, DWORD dwRop, IN PPOLYPATBLT pRects, IN DWORD cRects, IN DWORD Mode) { PPATRECT rb = NULL; NTSTATUS Status = STATUS_SUCCESS; BOOL Ret; if (cRects > 0) { rb = ExAllocatePoolWithTag(PagedPool, sizeof(PATRECT) * cRects, GDITAG_PLGBLT_DATA); if (!rb) { EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } _SEH2_TRY { ProbeForRead(pRects, cRects * sizeof(PATRECT), 1); RtlCopyMemory(rb, pRects, cRects * sizeof(PATRECT)); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { Status = _SEH2_GetExceptionCode(); } _SEH2_END; if (!NT_SUCCESS(Status)) { ExFreePoolWithTag(rb, GDITAG_PLGBLT_DATA); SetLastNtError(Status); return FALSE; } }
DWORD APIENTRY NtUserSetScrollInfo( HWND hWnd, int fnBar, LPCSCROLLINFO lpsi, BOOL bRedraw) { PWND Window = NULL; NTSTATUS Status; SCROLLINFO ScrollInfo; DECLARE_RETURN(DWORD); USER_REFERENCE_ENTRY Ref; TRACE("Enter NtUserSetScrollInfo\n"); UserEnterExclusive(); if(!(Window = UserGetWindowObject(hWnd)) || // FIXME: Window == UserGetDesktopWindow() || // pWnd->fnid == FNID_DESKTOP Window == UserGetMessageWindow() ) // pWnd->fnid == FNID_MESSAGEWND { RETURN( 0); } UserRefObjectCo(Window, &Ref); Status = MmCopyFromCaller(&ScrollInfo, lpsi, sizeof(SCROLLINFO) - sizeof(ScrollInfo.nTrackPos)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); RETURN( 0); } RETURN(co_IntSetScrollInfo(Window, fnBar, &ScrollInfo, bRedraw)); CLEANUP: if (Window) UserDerefObjectCo(Window); TRACE("Leave NtUserSetScrollInfo, ret=%lu\n", _ret_); UserLeave(); END_CLEANUP; }
ULONG APIENTRY NtUserGetAtomName( _In_ ATOM atom, _Inout_ PUNICODE_STRING pustrName) { WCHAR awcBuffer[256]; ULONG cjLength; /* Retrieve the atom name into a local buffer (max length is 255 chars) */ cjLength = IntGetAtomName((RTL_ATOM)atom, awcBuffer, sizeof(awcBuffer)); if (cjLength != 0) { _SEH2_TRY { /* Probe the unicode string and the buffer */ ProbeForRead(pustrName, sizeof(*pustrName), 1); ProbeForWrite(pustrName->Buffer, pustrName->MaximumLength, 1); /* Check if we have enough space to write the NULL termination */ if (pustrName->MaximumLength >= sizeof(UNICODE_NULL)) { /* Limit the length to the buffer size */ cjLength = min(pustrName->MaximumLength - sizeof(UNICODE_NULL), cjLength); /* Copy the string and NULL terminate it */ RtlCopyMemory(pustrName->Buffer, awcBuffer, cjLength); pustrName->Buffer[cjLength / sizeof(WCHAR)] = L'\0'; } else { cjLength = 0; } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { /* On exception, set last error and fail */ SetLastNtError(_SEH2_GetExceptionCode()); cjLength = 0; } _SEH2_END }
BOOL APIENTRY NtUserCloseWindowStation( HWINSTA hWinSta) { PWINSTATION_OBJECT Object; NTSTATUS Status; TRACE("NtUserCloseWindowStation called (%p)\n", hWinSta); if (hWinSta == UserGetProcessWindowStation()) { ERR("Attempted to close process window station\n"); return FALSE; } Status = IntValidateWindowStationHandle(hWinSta, UserMode, 0, &Object, 0); if (!NT_SUCCESS(Status)) { ERR("Validation of window station handle (%p) failed\n", hWinSta); return FALSE; } ObDereferenceObject(Object); TRACE("Closing window station handle (%p)\n", hWinSta); Status = ObCloseHandle(hWinSta, UserMode); if (!NT_SUCCESS(Status)) { SetLastNtError(Status); return FALSE; } return TRUE; }
INT APIENTRY NtUserGetClipboardFormatName(UINT fmt, LPWSTR lpszFormatName, INT cchMaxCount) { INT iRet = 0; UserEnterShared(); /* If the format is built-in we fail */ if (fmt < 0xc000) { /* Registetrated formats are >= 0xc000 */ goto cleanup; } if (cchMaxCount < 1 || !lpszFormatName) { EngSetLastError(ERROR_INVALID_PARAMETER); goto cleanup; } _SEH2_TRY { ProbeForWrite(lpszFormatName, cchMaxCount * sizeof(WCHAR), 1); iRet = IntGetAtomName((RTL_ATOM)fmt, lpszFormatName, cchMaxCount * sizeof(WCHAR)); iRet /= sizeof(WCHAR); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastNtError(_SEH2_GetExceptionCode()); } _SEH2_END; cleanup: UserLeave(); return iRet; }
BOOL APIENTRY NtGdiGetDeviceCapsAll( IN HDC hDC, OUT PDEVCAPS pDevCaps) { PDC pdc; DEVCAPS devcaps; BOOL bResult = TRUE; /* Lock the given DC */ pdc = DC_LockDc(hDC); if (!pdc) { EngSetLastError(ERROR_INVALID_HANDLE); return FALSE; } /* Get the data */ PDEVOBJ_vGetDeviceCaps(pdc->ppdev, &devcaps); /* Unlock the DC */ DC_UnlockDc(pdc); /* Copy data to caller */ _SEH2_TRY { ProbeForWrite(pDevCaps, sizeof(DEVCAPS), 1); RtlCopyMemory(pDevCaps, &devcaps, sizeof(DEVCAPS)); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastNtError(_SEH2_GetExceptionCode()); bResult = FALSE; } _SEH2_END; return bResult; }