Author: rharabien Date: Thu Oct 13 20:49:03 2011 New Revision: 54118 URL: http://svn.reactos.org/svn/reactos?rev=54118&view=rev Log: [WIN32K] - Add more clipboard internal functions for use by Print Screen support
Modified: trunk/reactos/subsystems/win32/win32k/include/clipboard.h trunk/reactos/subsystems/win32/win32k/ntuser/clipboard.c Modified: trunk/reactos/subsystems/win32/win32k/include/clipboard.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/clipboard.h?rev=54118&r1=54117&r2=54118&view=diff ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/clipboard.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/clipboard.h [iso-8859-1] Thu Oct 13 20:49:03 2011 @@ -13,5 +13,17 @@ VOID FASTCALL UserClipboardFreeWindow(PWND pWindow); +BOOL NTAPI +UserOpenClipboard(HWND hWnd); + +BOOL NTAPI +UserCloseClipboard(VOID); + +BOOL NTAPI +UserEmptyClipboard(VOID); + VOID NTAPI UserEmptyClipboardData(struct _WINSTATION_OBJECT *pWinSta); + +HANDLE NTAPI +UserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA scd); Modified: trunk/reactos/subsystems/win32/win32k/ntuser/clipboard.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/clipboard.c?rev=54118&r1=54117&r2=54118&view=diff ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/clipboard.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/clipboard.c [iso-8859-1] Thu Oct 13 20:49:03 2011 @@ -377,23 +377,18 @@ return Ret; } -BOOL APIENTRY -NtUserOpenClipboard(HWND hWnd, DWORD Unknown1) +BOOL NTAPI +UserOpenClipboard(HWND hWnd) { PWND pWindow = NULL; BOOL bRet = FALSE; PWINSTATION_OBJECT pWinStaObj = NULL; - UserEnterExclusive(); - if (hWnd) { pWindow = UserGetWindowObject(hWnd); if (!pWindow) - { - EngSetLastError(ERROR_INVALID_WINDOW_HANDLE); goto cleanup; - } } pWinStaObj = IntGetWinStaForCbAccess(); @@ -406,6 +401,7 @@ if (pWinStaObj->spwndClipOpen != pWindow) { EngSetLastError(ERROR_ACCESS_DENIED); + ERR("Access denied!\n"); goto cleanup; } } @@ -419,18 +415,26 @@ if (pWinStaObj) ObDereferenceObject(pWinStaObj); - UserLeave(); - return bRet; } BOOL APIENTRY -NtUserCloseClipboard(VOID) +NtUserOpenClipboard(HWND hWnd, DWORD Unknown1) +{ + BOOL bRet; + + UserEnterExclusive(); + bRet = UserOpenClipboard(hWnd); + UserLeave(); + + return bRet; +} + +BOOL NTAPI +UserCloseClipboard(VOID) { BOOL bRet = FALSE; PWINSTATION_OBJECT pWinStaObj = NULL; - - UserEnterExclusive(); pWinStaObj = IntGetWinStaForCbAccess(); if (!pWinStaObj) @@ -466,6 +470,16 @@ if (pWinStaObj) ObDereferenceObject(pWinStaObj); + return bRet; +} + +BOOL APIENTRY +NtUserCloseClipboard(VOID) +{ + BOOL bRet; + + UserEnterExclusive(); + bRet = UserCloseClipboard(); UserLeave(); return bRet; @@ -550,45 +564,52 @@ return cFormats; } +BOOL NTAPI +UserEmptyClipboard(VOID) +{ + BOOL bRet = FALSE; + PWINSTATION_OBJECT pWinStaObj; + + pWinStaObj = IntGetWinStaForCbAccess(); + if (!pWinStaObj) + return FALSE; + + if (IntIsClipboardOpenByMe(pWinStaObj)) + { + UserEmptyClipboardData(pWinStaObj); + + if (pWinStaObj->spwndClipOwner) + { + TRACE("Clipboard: WM_DESTROYCLIPBOARD to %p", pWinStaObj->spwndClipOwner->head.h); + co_IntSendMessageNoWait(pWinStaObj->spwndClipOwner->head.h, WM_DESTROYCLIPBOARD, 0, 0); + } + + pWinStaObj->spwndClipOwner = pWinStaObj->spwndClipOpen; + + pWinStaObj->iClipSequenceNumber++; + + bRet = TRUE; + } + else + { + EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN); + ERR("Access denied!\n"); + } + + ObDereferenceObject(pWinStaObj); + + return bRet; +} + BOOL APIENTRY NtUserEmptyClipboard(VOID) { - BOOL bRet = FALSE; - PWINSTATION_OBJECT pWinStaObj; + BOOL bRet; TRACE("NtUserEmptyClipboard()\n"); UserEnterExclusive(); - - pWinStaObj = IntGetWinStaForCbAccess(); - if (!pWinStaObj) - goto cleanup; - - if (IntIsClipboardOpenByMe(pWinStaObj)) - { - UserEmptyClipboardData(pWinStaObj); - - if (pWinStaObj->spwndClipOwner) - { - TRACE("Clipboard: WM_DESTROYCLIPBOARD to %p", pWinStaObj->spwndClipOwner->head.h); - co_IntSendMessageNoWait(pWinStaObj->spwndClipOwner->head.h, WM_DESTROYCLIPBOARD, 0, 0); - } - - pWinStaObj->spwndClipOwner = pWinStaObj->spwndClipOpen; - - pWinStaObj->iClipSequenceNumber++; - - bRet = TRUE; - } - else - { - EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN); - ERR("Access denied!\n"); - } - - ObDereferenceObject(pWinStaObj); - -cleanup: + bRet = UserEmptyClipboard(); UserLeave(); return bRet; @@ -865,17 +886,11 @@ return hRet; } -HANDLE APIENTRY -NtUserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA scd) +HANDLE NTAPI +UserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA scd) { HANDLE hRet = NULL; - NTSTATUS Status = STATUS_SUCCESS; PWINSTATION_OBJECT pWinStaObj = NULL; - BOOLEAN fGlobalHandle = FALSE; - - TRACE("NtUserSetClipboardData(%x %p %p)\n", fmt, hData, scd); - - UserEnterExclusive(); pWinStaObj = IntGetWinStaForCbAccess(); if (!pWinStaObj) @@ -891,24 +906,8 @@ goto cleanup; } - _SEH2_TRY - { - ProbeForRead(scd, sizeof(*scd), 1); - fGlobalHandle = scd->fGlobalHandle; - if (scd->fIncSerialNumber) - pWinStaObj->iClipSerialNumber++; - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Status = _SEH2_GetExceptionCode(); - } - _SEH2_END - - if (!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - goto cleanup; - } + if (scd->fIncSerialNumber) + pWinStaObj->iClipSerialNumber++; /* Is it a delayed render? */ if (hData) @@ -921,7 +920,7 @@ } /* Save data in the clipboard */ - IntAddFormatedData(pWinStaObj, fmt, hData, fGlobalHandle, FALSE); + IntAddFormatedData(pWinStaObj, fmt, hData, scd->fGlobalHandle, FALSE); TRACE("hData stored\n"); pWinStaObj->iClipSequenceNumber++; @@ -945,6 +944,41 @@ if(pWinStaObj) ObDereferenceObject(pWinStaObj); + return hRet; +} + +HANDLE APIENTRY +NtUserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA pUnsafeScd) +{ + SETCLIPBDATA scd; + NTSTATUS Status = STATUS_SUCCESS; + HANDLE hRet = NULL; + + TRACE("NtUserSetClipboardData(%x %p %p)\n", fmt, hData, scd); + + UserEnterExclusive(); + + _SEH2_TRY + { + ProbeForRead(pUnsafeScd, sizeof(*pUnsafeScd), 1); + RtlCopyMemory(&scd, pUnsafeScd, sizeof(scd)); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END + + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + goto cleanup; + } + + /* Call internal function */ + hRet = UserSetClipboardData(fmt, hData, &scd); + +cleanup: UserLeave(); return hRet;