ReactOS  0.4.14-dev-50-g13bb5e2
clipboard.c File Reference
#include <win32k.h>
Include dependency graph for clipboard.c:

Go to the source code of this file.

Macros

#define DATA_DELAYED   (HANDLE)0
 
#define DATA_SYNTH_USER   (HANDLE)1
 
#define DATA_SYNTH_KRNL   (HANDLE)2
 
#define IS_DATA_DELAYED(ce)   ((ce)->hData == DATA_DELAYED)
 
#define IS_DATA_SYNTHESIZED(ce)   ((ce)->hData == DATA_SYNTH_USER || (ce)->hData == DATA_SYNTH_KRNL)
 

Functions

 DBG_DEFAULT_CHANNEL (UserClipbrd)
 
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess (VOID)
 
static PCLIP FASTCALL IntGetFormatElement (PWINSTATION_OBJECT pWinStaObj, UINT fmt)
 
static BOOL FASTCALL IntIsFormatAvailable (PWINSTATION_OBJECT pWinStaObj, UINT fmt)
 
static VOID FASTCALL IntFreeElementData (PCLIP pElement)
 
static PCLIP NTAPI IntAddFormatedData (PWINSTATION_OBJECT pWinStaObj, UINT fmt, HANDLE hData, BOOLEAN fGlobalHandle, BOOL bEnd)
 
static BOOL FASTCALL IntIsClipboardOpenByMe (PWINSTATION_OBJECT pWinSta)
 
static VOID NTAPI IntSynthesizeDib (PWINSTATION_OBJECT pWinStaObj, HBITMAP hbm)
 
static VOID WINAPI IntSynthesizeBitmap (PWINSTATION_OBJECT pWinStaObj, PCLIP pBmEl)
 
static VOID NTAPI IntAddSynthesizedFormats (PWINSTATION_OBJECT pWinStaObj)
 
VOID NTAPI UserEmptyClipboardData (PWINSTATION_OBJECT pWinSta)
 
VOID FASTCALL UserClipboardRelease (PWND pWindow)
 
VOID FASTCALL UserClipboardFreeWindow (PWND pWindow)
 
UINT APIENTRY UserEnumClipboardFormats (UINT fmt)
 
BOOL NTAPI UserOpenClipboard (HWND hWnd)
 
BOOL APIENTRY NtUserOpenClipboard (HWND hWnd, DWORD Unknown1)
 
BOOL NTAPI UserCloseClipboard (VOID)
 
BOOL APIENTRY NtUserCloseClipboard (VOID)
 
HWND APIENTRY NtUserGetOpenClipboardWindow (VOID)
 
BOOL APIENTRY NtUserChangeClipboardChain (HWND hWndRemove, HWND hWndNewNext)
 
DWORD APIENTRY NtUserCountClipboardFormats (VOID)
 
BOOL NTAPI UserEmptyClipboard (VOID)
 
BOOL APIENTRY NtUserEmptyClipboard (VOID)
 
INT APIENTRY NtUserGetClipboardFormatName (UINT fmt, LPWSTR lpszFormatName, INT cchMaxCount)
 
HWND APIENTRY NtUserGetClipboardOwner (VOID)
 
HWND APIENTRY NtUserGetClipboardViewer (VOID)
 
INT APIENTRY NtUserGetPriorityClipboardFormat (UINT *paFormatPriorityList, INT cFormats)
 
BOOL APIENTRY NtUserIsClipboardFormatAvailable (UINT fmt)
 
HANDLE APIENTRY NtUserGetClipboardData (UINT fmt, PGETCLIPBDATA pgcd)
 
HANDLE NTAPI UserSetClipboardData (UINT fmt, HANDLE hData, PSETCLIPBDATA scd)
 
HANDLE APIENTRY NtUserSetClipboardData (UINT fmt, HANDLE hData, PSETCLIPBDATA pUnsafeScd)
 
HWND APIENTRY NtUserSetClipboardViewer (HWND hWndNewViewer)
 
DWORD APIENTRY NtUserGetClipboardSequenceNumber (VOID)
 
HANDLE APIENTRY NtUserConvertMemHandle (PVOID pData, DWORD cbData)
 
NTSTATUS APIENTRY NtUserCreateLocalMemHandle (HANDLE hMem, PVOID pData, DWORD cbData, DWORD *pcbData)
 

Macro Definition Documentation

◆ DATA_DELAYED

#define DATA_DELAYED   (HANDLE)0

Definition at line 14 of file clipboard.c.

◆ DATA_SYNTH_KRNL

#define DATA_SYNTH_KRNL   (HANDLE)2

Definition at line 16 of file clipboard.c.

◆ DATA_SYNTH_USER

#define DATA_SYNTH_USER   (HANDLE)1

Definition at line 15 of file clipboard.c.

◆ IS_DATA_DELAYED

#define IS_DATA_DELAYED (   ce)    ((ce)->hData == DATA_DELAYED)

Definition at line 17 of file clipboard.c.

◆ IS_DATA_SYNTHESIZED

#define IS_DATA_SYNTHESIZED (   ce)    ((ce)->hData == DATA_SYNTH_USER || (ce)->hData == DATA_SYNTH_KRNL)

Definition at line 18 of file clipboard.c.

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserClipbrd  )

◆ IntAddFormatedData()

static PCLIP NTAPI IntAddFormatedData ( PWINSTATION_OBJECT  pWinStaObj,
UINT  fmt,
HANDLE  hData,
BOOLEAN  fGlobalHandle,
BOOL  bEnd 
)
static

Definition at line 84 of file clipboard.c.

85 {
86  PCLIP pElement = NULL;
87 
88  /* Use existing entry with specified format */
89  if (!bEnd)
90  pElement = IntGetFormatElement(pWinStaObj, fmt);
91 
92  /* Put new entry at the end if nothing was found */
93  if (!pElement)
94  {
95  /* Allocate bigger clipboard if needed. We could use lists but Windows uses array */
96  if (pWinStaObj->cNumClipFormats % 4 == 0)
97  {
98  PCLIP pNewClip;
99 
100  /* Allocate new clipboard */
101  pNewClip = ExAllocatePoolWithTag(PagedPool,
102  (pWinStaObj->cNumClipFormats + 4) * sizeof(CLIP),
104  if (!pNewClip)
105  {
107  return NULL;
108  }
109 
110  /* Copy data */
111  memcpy(pNewClip, pWinStaObj->pClipBase, pWinStaObj->cNumClipFormats * sizeof(CLIP));
112 
113  /* Free old clipboard */
114  if (pWinStaObj->pClipBase)
116 
117  /* Update WinSta */
118  pWinStaObj->pClipBase = pNewClip;
119  }
120 
121  /* New element is at the end */
122  pElement = &pWinStaObj->pClipBase[pWinStaObj->cNumClipFormats];
123  pElement->fmt = fmt;
124  pWinStaObj->cNumClipFormats++;
125  }
126  else
127  IntFreeElementData(pElement);
128 
129  pElement->hData = hData;
130  pElement->fGlobalHandle = fGlobalHandle;
131 
132  return pElement;
133 }
BOOL fGlobalHandle
Definition: clipboard.h:7
static PCLIP FASTCALL IntGetFormatElement(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
Definition: clipboard.c:41
const char * fmt
Definition: wsprintf.c:30
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
HANDLE hData
Definition: clipboard.h:6
static VOID FASTCALL IntFreeElementData(PCLIP pElement)
Definition: clipboard.c:61
#define USERTAG_CLIPBOARD
Definition: tags.h:199
UINT fmt
Definition: clipboard.h:5
Definition: clipboard.h:3
smooth NULL
Definition: ftsmooth.c:416
PCLIP pClipBase
Definition: winsta.h:31
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
DWORD cNumClipFormats
Definition: winsta.h:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
MaybeUInt64 bEnd[BZ_MAX_HANDLED_BLOCKS]
Definition: bzip2recover.c:297
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
Definition: dsound.c:943
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by IntAddSynthesizedFormats(), IntSynthesizeDib(), and UserSetClipboardData().

◆ IntAddSynthesizedFormats()

static VOID NTAPI IntAddSynthesizedFormats ( PWINSTATION_OBJECT  pWinStaObj)
static

Definition at line 291 of file clipboard.c.

292 {
293  BOOL bHaveText, bHaveUniText, bHaveOemText, bHaveLocale, bHaveBm, bHaveDib, bHaveMFP, bHaveEMF;
294 
295  bHaveText = IntIsFormatAvailable(pWinStaObj, CF_TEXT);
296  bHaveOemText = IntIsFormatAvailable(pWinStaObj, CF_OEMTEXT);
297  bHaveUniText = IntIsFormatAvailable(pWinStaObj, CF_UNICODETEXT);
298  bHaveLocale = IntIsFormatAvailable(pWinStaObj, CF_LOCALE);
299  bHaveBm = IntIsFormatAvailable(pWinStaObj, CF_BITMAP);
300  bHaveDib = IntIsFormatAvailable(pWinStaObj, CF_DIB);
301  bHaveMFP = IntIsFormatAvailable(pWinStaObj, CF_METAFILEPICT);
302  bHaveEMF = IntIsFormatAvailable(pWinStaObj, CF_ENHMETAFILE);
303 
304  /* Add CF_LOCALE format if we have CF_TEXT, CF_OEMTEXT or CF_UNICODETEXT */
305  if (!bHaveLocale && (bHaveText || bHaveOemText || bHaveUniText))
306  {
307  PCLIPBOARDDATA pMemObj;
308  HANDLE hMem;
309 
311  sizeof(CLIPBOARDDATA) + sizeof(LCID));
312  if (pMemObj)
313  {
314  pMemObj->cbData = sizeof(LCID);
315  *((LCID*)pMemObj->Data) = NtCurrentTeb()->CurrentLocale;
316  IntAddFormatedData(pWinStaObj, CF_LOCALE, hMem, TRUE, TRUE);
317 
318  /* Release the extra reference (UserCreateObject added 2 references) */
319  UserDereferenceObject(pMemObj);
320  }
321  }
322 
323  /* Add CF_TEXT. Note: it is synthesized in user32.dll */
324  if (!bHaveText && (bHaveUniText || bHaveOemText))
326 
327  /* Add CF_OEMTEXT. Note: it is synthesized in user32.dll */
328  if (!bHaveOemText && (bHaveUniText || bHaveText))
330 
331  /* Add CF_UNICODETEXT. Note: it is synthesized in user32.dll */
332  if (!bHaveUniText && (bHaveText || bHaveOemText))
334 
335  /* Add CF_BITMAP. Note: it is synthesized on demand */
336  if (!bHaveBm && bHaveDib)
338 
339  /* Add CF_ENHMETAFILE. Note: it is synthesized in gdi32.dll */
340  if (bHaveMFP && !bHaveEMF)
342 
343  /* Add CF_METAFILEPICT. Note: it is synthesized in gdi32.dll */
344  if (bHaveEMF && !bHaveMFP)
346 
347  /* Note: We need to render the DIB or DIBV5 format as soon as possible
348  because palette information may change */
349  if (!bHaveDib && bHaveBm)
350  IntSynthesizeDib(pWinStaObj, IntGetFormatElement(pWinStaObj, CF_BITMAP)->hData);
351 }
#define TRUE
Definition: types.h:120
#define CF_ENHMETAFILE
Definition: constants.h:409
static PCLIP FASTCALL IntGetFormatElement(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
Definition: clipboard.c:41
#define DATA_SYNTH_KRNL
Definition: clipboard.c:16
#define DATA_SYNTH_USER
Definition: clipboard.c:15
BYTE Data[0]
Definition: ntuser.h:236
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
DWORD LCID
Definition: nls.h:13
#define CF_METAFILEPICT
Definition: constants.h:398
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:535
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CF_UNICODETEXT
Definition: constants.h:408
#define CF_BITMAP
Definition: constants.h:397
smooth NULL
Definition: ftsmooth.c:416
#define CF_TEXT
Definition: constants.h:396
static PCLIP NTAPI IntAddFormatedData(PWINSTATION_OBJECT pWinStaObj, UINT fmt, HANDLE hData, BOOLEAN fGlobalHandle, BOOL bEnd)
Definition: clipboard.c:84
#define CF_LOCALE
Definition: constants.h:411
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define CF_OEMTEXT
Definition: constants.h:402
static VOID NTAPI IntSynthesizeDib(PWINSTATION_OBJECT pWinStaObj, HBITMAP hbm)
Definition: clipboard.c:144
static BOOL FASTCALL IntIsFormatAvailable(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
Definition: clipboard.c:55
DWORD cbData
Definition: ntuser.h:235
struct tagCLIPBOARDDATA * PCLIPBOARDDATA
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
#define CF_DIB
Definition: constants.h:403

Referenced by UserClipboardRelease(), and UserCloseClipboard().

◆ IntFreeElementData()

static VOID FASTCALL IntFreeElementData ( PCLIP  pElement)
static

Definition at line 61 of file clipboard.c.

62 {
63  if (!IS_DATA_DELAYED(pElement) &&
64  !IS_DATA_SYNTHESIZED(pElement))
65  {
66  if (pElement->fGlobalHandle)
68  else if (pElement->fmt == CF_BITMAP ||
69  pElement->fmt == CF_PALETTE ||
70  pElement->fmt == CF_DSPBITMAP ||
71  pElement->fmt == CF_METAFILEPICT ||
72  pElement->fmt == CF_DSPMETAFILEPICT ||
73  pElement->fmt == CF_DSPENHMETAFILE ||
74  pElement->fmt == CF_ENHMETAFILE )
75  {
77  GreDeleteObject(pElement->hData);
78  }
79  }
80 }
BOOL fGlobalHandle
Definition: clipboard.h:7
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1252
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:683
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1155
#define CF_ENHMETAFILE
Definition: constants.h:409
#define IS_DATA_SYNTHESIZED(ce)
Definition: clipboard.c:18
#define CF_DSPMETAFILEPICT
Definition: constants.h:416
#define CF_METAFILEPICT
Definition: constants.h:398
HANDLE hData
Definition: clipboard.h:6
UINT fmt
Definition: clipboard.h:5
#define CF_DSPENHMETAFILE
Definition: constants.h:417
#define CF_BITMAP
Definition: constants.h:397
#define CF_DSPBITMAP
Definition: constants.h:415
#define CF_PALETTE
Definition: constants.h:404
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
#define IS_DATA_DELAYED(ce)
Definition: clipboard.c:17

Referenced by IntAddFormatedData(), and UserEmptyClipboardData().

◆ IntGetFormatElement()

static PCLIP FASTCALL IntGetFormatElement ( PWINSTATION_OBJECT  pWinStaObj,
UINT  fmt 
)
static

Definition at line 41 of file clipboard.c.

42 {
43  DWORD i;
44 
45  for (i = 0; i < pWinStaObj->cNumClipFormats; ++i)
46  {
47  if (pWinStaObj->pClipBase[i].fmt == fmt)
48  return &pWinStaObj->pClipBase[i];
49  }
50 
51  return NULL;
52 }
UINT fmt
Definition: clipboard.h:5
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
PCLIP pClipBase
Definition: winsta.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD cNumClipFormats
Definition: winsta.h:32
Definition: dsound.c:943

Referenced by IntAddFormatedData(), IntAddSynthesizedFormats(), IntIsFormatAvailable(), IntSynthesizeBitmap(), NtUserGetClipboardData(), and UserEnumClipboardFormats().

◆ IntGetWinStaForCbAccess()

static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess ( VOID  )
static

Definition at line 21 of file clipboard.c.

22 {
23  HWINSTA hWinSta;
24  PWINSTATION_OBJECT pWinStaObj;
26 
27  hWinSta = UserGetProcessWindowStation();
29  if (!NT_SUCCESS(Status))
30  {
31  ERR("Cannot open winsta\n");
33  return NULL;
34  }
35 
36  return pWinStaObj;
37 }
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS FASTCALL IntValidateWindowStationHandle(HWINSTA WindowStation, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PWINSTATION_OBJECT *Object, POBJECT_HANDLE_INFORMATION pObjectHandleInfo)
Definition: winsta.c:230
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
HWINSTA FASTCALL UserGetProcessWindowStation(VOID)
Definition: winsta.c:1317
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
#define WINSTA_ACCESSCLIPBOARD
Definition: winuser.h:408

Referenced by NtUserChangeClipboardChain(), NtUserCountClipboardFormats(), NtUserGetClipboardData(), NtUserGetClipboardOwner(), NtUserGetClipboardSequenceNumber(), NtUserGetClipboardViewer(), NtUserGetOpenClipboardWindow(), NtUserGetPriorityClipboardFormat(), NtUserIsClipboardFormatAvailable(), NtUserSetClipboardViewer(), UserClipboardFreeWindow(), UserClipboardRelease(), UserCloseClipboard(), UserEmptyClipboard(), UserEnumClipboardFormats(), UserOpenClipboard(), and UserSetClipboardData().

◆ IntIsClipboardOpenByMe()

static BOOL FASTCALL IntIsClipboardOpenByMe ( PWINSTATION_OBJECT  pWinSta)
static

Definition at line 136 of file clipboard.c.

137 {
138  /* Check if the current thread has opened the clipboard */
139  return (pWinSta->ptiClipLock &&
141 }
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
PTHREADINFO ptiClipLock
Definition: winsta.h:26

Referenced by NtUserGetClipboardData(), UserCloseClipboard(), UserEmptyClipboard(), UserEnumClipboardFormats(), and UserOpenClipboard().

◆ IntIsFormatAvailable()

static BOOL FASTCALL IntIsFormatAvailable ( PWINSTATION_OBJECT  pWinStaObj,
UINT  fmt 
)
static

Definition at line 55 of file clipboard.c.

56 {
57  return IntGetFormatElement(pWinStaObj, fmt) != NULL;
58 }
static PCLIP FASTCALL IntGetFormatElement(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
Definition: clipboard.c:41
smooth NULL
Definition: ftsmooth.c:416
Definition: dsound.c:943

Referenced by IntAddSynthesizedFormats(), NtUserGetPriorityClipboardFormat(), and NtUserIsClipboardFormatAvailable().

◆ IntSynthesizeBitmap()

static VOID WINAPI IntSynthesizeBitmap ( PWINSTATION_OBJECT  pWinStaObj,
PCLIP  pBmEl 
)
static

Definition at line 230 of file clipboard.c.

231 {
232  HDC hdc = NULL;
233  PBITMAPINFO pBmi, pConvertedBmi = NULL;
234  HBITMAP hBm = NULL;
235  PCLIPBOARDDATA pMemObj;
236  PCLIP pDibEl;
237  ULONG Offset;
238 
239  TRACE("IntSynthesizeBitmap(%p, %p)\n", pWinStaObj, pBmEl);
240 
241  pDibEl = IntGetFormatElement(pWinStaObj, CF_DIB);
242  ASSERT(pDibEl && !IS_DATA_SYNTHESIZED(pDibEl));
243  if (!pDibEl->fGlobalHandle)
244  return;
245 
247  if (!pMemObj)
248  return;
249 
250  pBmi = (BITMAPINFO*)pMemObj->Data;
251 
252  if (pMemObj->cbData < sizeof(DWORD) && pMemObj->cbData < pBmi->bmiHeader.biSize)
253  goto cleanup;
254 
255  pConvertedBmi = DIB_ConvertBitmapInfo(pBmi, DIB_RGB_COLORS);
256  if (!pConvertedBmi)
257  goto cleanup;
258 
260 
262  if (!hdc)
263  goto cleanup;
264 
266  pConvertedBmi->bmiHeader.biWidth,
267  pConvertedBmi->bmiHeader.biHeight,
268  CBM_INIT,
269  pMemObj->Data + Offset,
270  pConvertedBmi,
272  0,
273  pMemObj->cbData - Offset,
274  0);
275 
276  if (hBm)
277  {
279  pBmEl->hData = hBm;
280  }
281 
282 cleanup:
283  if (hdc)
285 
286  if (pConvertedBmi)
287  DIB_FreeConvertedBitmapInfo(pConvertedBmi, pBmi, -1);
288 }
BOOL fGlobalHandle
Definition: clipboard.h:7
VOID FASTCALL DIB_FreeConvertedBitmapInfo(BITMAPINFO *converted, BITMAPINFO *orig, DWORD Usage)
Definition: dibobj.c:2116
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1252
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1471
static PCLIP FASTCALL IntGetFormatElement(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
Definition: clipboard.c:41
BYTE Data[0]
Definition: ntuser.h:236
#define IS_DATA_SYNTHESIZED(ce)
Definition: clipboard.c:18
static HDC
Definition: imagelist.c:92
#define DCX_USESTYLE
Definition: GetDCEx.c:10
HDC FASTCALL UserGetDCEx(PWND Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
HANDLE hData
Definition: clipboard.h:6
#define CBM_INIT
Definition: wingdi.h:364
INT FASTCALL DIB_BitmapInfoSize(const BITMAPINFO *info, WORD coloruse, BOOL max)
Definition: bitmap.c:17
Definition: clipboard.h:3
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned long DWORD
Definition: ntddk_ex.h:95
HBITMAP NTAPI GreCreateDIBitmapInternal(IN HDC hDc, IN INT cx, IN INT cy, IN DWORD fInit, IN OPTIONAL LPBYTE pjInit, IN OPTIONAL PBITMAPINFO pbmi, IN DWORD iUsage, IN FLONG fl, IN UINT cjMaxBits, IN HANDLE hcmXform)
Definition: dibobj.c:1531
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
HDC hdc
Definition: main.c:9
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:462
DWORD cbData
Definition: ntuser.h:235
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
INT FASTCALL UserReleaseDC(PWND Window, HDC hDc, BOOL EndPaint)
Definition: windc.c:917
struct tagCLIPBOARDDATA * PCLIPBOARDDATA
BITMAPINFO *FASTCALL DIB_ConvertBitmapInfo(CONST BITMAPINFO *bmi, DWORD Usage)
Definition: dibobj.c:2052
unsigned int ULONG
Definition: retypes.h:1
char * cleanup(char *str)
Definition: wpickclick.c:99
static HBITMAP
Definition: button.c:44
#define DIB_RGB_COLORS
Definition: wingdi.h:366
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
#define CF_DIB
Definition: constants.h:403

Referenced by NtUserGetClipboardData().

◆ IntSynthesizeDib()

static VOID NTAPI IntSynthesizeDib ( PWINSTATION_OBJECT  pWinStaObj,
HBITMAP  hbm 
)
static

Definition at line 144 of file clipboard.c.

147 {
148  HDC hdc;
149  ULONG cjInfoSize, cjDataSize;
150  PCLIPBOARDDATA pClipboardData;
151  HANDLE hMem;
152  INT iResult;
153  struct
154  {
155  BITMAPINFOHEADER bmih;
156  RGBQUAD rgbColors[256];
157  } bmiBuffer;
158  PBITMAPINFO pbmi = (PBITMAPINFO)&bmiBuffer;
159 
160  /* Get the display DC */
162  if (!hdc)
163  {
164  return;
165  }
166 
167  /* Get information about the bitmap format */
168  memset(&bmiBuffer, 0, sizeof(bmiBuffer));
169  pbmi->bmiHeader.biSize = sizeof(bmiBuffer.bmih);
170  iResult = GreGetDIBitsInternal(hdc,
171  hbm,
172  0,
173  0,
174  NULL,
175  pbmi,
177  0,
178  sizeof(bmiBuffer));
179  if (iResult == 0)
180  {
181  goto cleanup;
182  }
183 
184  /* Get the size for a full BITMAPINFO */
185  cjInfoSize = DIB_BitmapInfoSize(pbmi, DIB_RGB_COLORS);
186 
187  /* Calculate the size of the clipboard data, which is a packed DIB */
188  cjDataSize = cjInfoSize + pbmi->bmiHeader.biSizeImage;
189 
190  /* Create the clipboard data */
191  pClipboardData = (PCLIPBOARDDATA)UserCreateObject(gHandleTable,
192  NULL,
193  NULL,
194  &hMem,
196  sizeof(CLIPBOARDDATA) + cjDataSize);
197  if (!pClipboardData)
198  {
199  goto cleanup;
200  }
201 
202  /* Set the data size */
203  pClipboardData->cbData = cjDataSize;
204 
205  /* Copy the BITMAPINFOHEADER */
206  memcpy(pClipboardData->Data, pbmi, sizeof(BITMAPINFOHEADER));
207 
208  /* Get the bitmap bits and the color table */
209  iResult = GreGetDIBitsInternal(hdc,
210  hbm,
211  0,
213  (LPBYTE)pClipboardData->Data + cjInfoSize,
214  (LPBITMAPINFO)pClipboardData->Data,
217  cjInfoSize);
218 
219  /* Add the clipboard data */
220  IntAddFormatedData(pWinStaObj, CF_DIB, hMem, TRUE, TRUE);
221 
222  /* Release the extra reference (UserCreateObject added 2 references) */
223  UserDereferenceObject(pClipboardData);
224 
225 cleanup:
227 }
#define abs(i)
Definition: fconv.c:206
#define TRUE
Definition: types.h:120
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1471
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
BYTE Data[0]
Definition: ntuser.h:236
static HDC
Definition: imagelist.c:92
#define DCX_USESTYLE
Definition: GetDCEx.c:10
HDC FASTCALL UserGetDCEx(PWND Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
int32_t INT
Definition: typedefs.h:56
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:535
INT FASTCALL DIB_BitmapInfoSize(const BITMAPINFO *info, WORD coloruse, BOOL max)
Definition: bitmap.c:17
unsigned char * LPBYTE
Definition: typedefs.h:52
_In_z_ PCWSTR _In_ ULONG _Post_z_ PVOID _In_ ULONG cjDataSize
Definition: ntuser.h:38
smooth NULL
Definition: ftsmooth.c:416
static PCLIP NTAPI IntAddFormatedData(PWINSTATION_OBJECT pWinStaObj, UINT fmt, HANDLE hData, BOOLEAN fGlobalHandle, BOOL bEnd)
Definition: clipboard.c:84
DWORD biSizeImage
Definition: amvideo.idl:36
HDC hdc
Definition: main.c:9
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
DWORD cbData
Definition: ntuser.h:235
INT FASTCALL UserReleaseDC(PWND Window, HDC hDc, BOOL EndPaint)
Definition: windc.c:917
struct tagCLIPBOARDDATA * PCLIPBOARDDATA
unsigned int ULONG
Definition: retypes.h:1
char * cleanup(char *str)
Definition: wpickclick.c:99
struct tagBITMAPINFO * PBITMAPINFO
#define DIB_RGB_COLORS
Definition: wingdi.h:366
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
#define memset(x, y, z)
Definition: compat.h:39
INT APIENTRY GreGetDIBitsInternal(HDC hDC, HBITMAP hBitmap, UINT StartScan, UINT ScanLines, LPBYTE Bits, LPBITMAPINFO Info, UINT Usage, UINT MaxBits, UINT MaxInfo)
Definition: dibobj.c:671
#define CF_DIB
Definition: constants.h:403

Referenced by IntAddSynthesizedFormats().

◆ NtUserChangeClipboardChain()

BOOL APIENTRY NtUserChangeClipboardChain ( HWND  hWndRemove,
HWND  hWndNewNext 
)

Definition at line 621 of file clipboard.c.

622 {
623  BOOL bRet = FALSE;
624  PWND pWindowRemove;
625  PWINSTATION_OBJECT pWinStaObj;
626 
627  TRACE("NtUserChangeClipboardChain(%p, %p)\n", hWndRemove, hWndNewNext);
628 
630 
631  pWinStaObj = IntGetWinStaForCbAccess();
632  if (!pWinStaObj)
633  goto cleanup;
634 
635  pWindowRemove = UserGetWindowObject(hWndRemove);
636 
637  if (pWindowRemove && pWinStaObj->spwndClipViewer)
638  {
639  if (pWindowRemove == pWinStaObj->spwndClipViewer)
640  pWinStaObj->spwndClipViewer = UserGetWindowObject(hWndNewNext);
641 
642  if (pWinStaObj->spwndClipViewer)
643  bRet = (BOOL)co_IntSendMessage(pWinStaObj->spwndClipViewer->head.h, WM_CHANGECBCHAIN, (WPARAM)hWndRemove, (LPARAM)hWndNewNext);
644  }
645 
646  ObDereferenceObject(pWinStaObj);
647 
648 cleanup:
649  UserLeave();
650 
651  return bRet;
652 }
#define WM_CHANGECBCHAIN
Definition: winuser.h:1856
static BOOL(WINAPI *pAddClipboardFormatListener)(HWND hwnd)
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
UINT_PTR WPARAM
Definition: windef.h:207
PWND spwndClipViewer
Definition: winsta.h:29
unsigned int BOOL
Definition: ntddk_ex.h:94
THRDESKHEAD head
Definition: ntuser.h:659
LONG_PTR LPARAM
Definition: windef.h:208
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define TRACE(s)
Definition: solgame.cpp:4
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1281
Definition: ntuser.h:657
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99

Referenced by ChangeClipboardChain().

◆ NtUserCloseClipboard()

BOOL APIENTRY NtUserCloseClipboard ( VOID  )

Definition at line 586 of file clipboard.c.

587 {
588  BOOL bRet;
589 
591  bRet = UserCloseClipboard();
592  UserLeave();
593 
594  return bRet;
595 }
BOOL NTAPI UserCloseClipboard(VOID)
Definition: clipboard.c:542
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255

Referenced by CloseClipboard().

◆ NtUserConvertMemHandle()

HANDLE APIENTRY NtUserConvertMemHandle ( PVOID  pData,
DWORD  cbData 
)

Definition at line 1184 of file clipboard.c.

1187 {
1188  HANDLE hMem = NULL;
1189  PCLIPBOARDDATA pMemObj;
1190 
1192 
1193  /* Create Clipboard data object */
1194  pMemObj = UserCreateObject(gHandleTable, NULL, NULL, &hMem, TYPE_CLIPDATA, sizeof(CLIPBOARDDATA) + cbData);
1195  if (!pMemObj)
1196  goto cleanup;
1197 
1198  pMemObj->cbData = cbData;
1199 
1200  /* Copy data */
1201  _SEH2_TRY
1202  {
1203  ProbeForRead(pData, cbData, 1);
1204  memcpy(pMemObj->Data, pData, cbData);
1205  }
1207  {
1208  pMemObj = NULL;
1209  }
1210  _SEH2_END;
1211 
1212  /* Release the extra reference (UserCreateObject added 2 references) */
1213  UserDereferenceObject(pMemObj);
1214 
1215  /* If we failed to copy data, remove handle */
1216  if (!pMemObj)
1217  {
1219  hMem = NULL;
1220  }
1221 
1222 cleanup:
1223  UserLeave();
1224 
1225  return hMem;
1226 }
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:683
BYTE Data[0]
Definition: ntuser.h:236
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:535
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
_SEH2_END
Definition: create.c:4424
DWORD cbData
Definition: ntuser.h:235
char * cleanup(char *str)
Definition: wpickclick.c:99
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13

Referenced by GetClipboardData(), and SetClipboardData().

◆ NtUserCountClipboardFormats()

DWORD APIENTRY NtUserCountClipboardFormats ( VOID  )

Definition at line 655 of file clipboard.c.

656 {
657  DWORD cFormats = 0;
658  PWINSTATION_OBJECT pWinStaObj;
659 
660  UserEnterShared();
661 
662  pWinStaObj = IntGetWinStaForCbAccess();
663  if (!pWinStaObj)
664  goto cleanup;
665 
666  cFormats = pWinStaObj->cNumClipFormats;
667 
668  ObDereferenceObject(pWinStaObj);
669 
670 cleanup:
671  UserLeave();
672 
673  return cFormats;
674 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:241
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD cNumClipFormats
Definition: winsta.h:32
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99

Referenced by CountClipboardFormats(), and START_TEST().

◆ NtUserCreateLocalMemHandle()

NTSTATUS APIENTRY NtUserCreateLocalMemHandle ( HANDLE  hMem,
PVOID  pData,
DWORD  cbData,
DWORD pcbData 
)

Definition at line 1229 of file clipboard.c.

1234 {
1235  PCLIPBOARDDATA pMemObj;
1237 
1238  UserEnterShared();
1239 
1240  /* Get Clipboard data object */
1242  if (!pMemObj)
1243  {
1245  goto cleanup;
1246  }
1247 
1248  /* Don't overrun */
1249  if (cbData > pMemObj->cbData)
1250  cbData = pMemObj->cbData;
1251 
1252  /* Copy data to usermode */
1253  _SEH2_TRY
1254  {
1255  if (pcbData)
1256  {
1257  ProbeForWrite(pcbData, sizeof(*pcbData), 1);
1258  *pcbData = pMemObj->cbData;
1259  }
1260 
1261  ProbeForWrite(pData, cbData, 1);
1262  memcpy(pData, pMemObj->Data, cbData);
1263  }
1265  {
1267  }
1268  _SEH2_END;
1269 
1270 cleanup:
1271  UserLeave();
1272 
1273  return Status;
1274 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:241
BYTE Data[0]
Definition: ntuser.h:236
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Status
Definition: gdiplustypes.h:24
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
_SEH2_END
Definition: create.c:4424
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:462
DWORD cbData
Definition: ntuser.h:235
struct tagCLIPBOARDDATA * PCLIPBOARDDATA
char * cleanup(char *str)
Definition: wpickclick.c:99
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
return STATUS_SUCCESS
Definition: btrfs.c:2966
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4953

Referenced by GetClipboardData().

◆ NtUserEmptyClipboard()

BOOL APIENTRY NtUserEmptyClipboard ( VOID  )

Definition at line 719 of file clipboard.c.

720 {
721  BOOL bRet;
722 
723  TRACE("NtUserEmptyClipboard()\n");
724 
726  bRet = UserEmptyClipboard();
727  UserLeave();
728 
729  return bRet;
730 }
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define TRACE(s)
Definition: solgame.cpp:4
BOOL NTAPI UserEmptyClipboard(VOID)
Definition: clipboard.c:677
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255

Referenced by EmptyClipboard().

◆ NtUserGetClipboardData()

HANDLE APIENTRY NtUserGetClipboardData ( UINT  fmt,
PGETCLIPBDATA  pgcd 
)

Definition at line 894 of file clipboard.c.

895 {
896  HANDLE hRet = NULL;
897  PCLIP pElement;
898  PWINSTATION_OBJECT pWinStaObj;
899  UINT uSourceFmt = fmt;
900 
901  TRACE("NtUserGetClipboardData(%x, %p)\n", fmt, pgcd);
902 
903  UserEnterShared();
904 
905  pWinStaObj = IntGetWinStaForCbAccess();
906  if (!pWinStaObj)
907  goto cleanup;
908 
909  /* Check if the clipboard has been opened */
910  if (!IntIsClipboardOpenByMe(pWinStaObj))
911  {
913  goto cleanup;
914  }
915 
916  pElement = IntGetFormatElement(pWinStaObj, fmt);
917  if (!pElement)
918  goto cleanup;
919 
920  if (IS_DATA_SYNTHESIZED(pElement))
921  {
922  /* Note: Data is synthesized in usermode */
923  /* TODO: Add more formats */
924  switch (fmt)
925  {
926  case CF_UNICODETEXT:
927  case CF_TEXT:
928  case CF_OEMTEXT:
929  uSourceFmt = CF_UNICODETEXT;
930  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
931  if (IS_DATA_SYNTHESIZED(pElement))
932  {
933  uSourceFmt = CF_TEXT;
934  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
935  }
936  if (IS_DATA_SYNTHESIZED(pElement))
937  {
938  uSourceFmt = CF_OEMTEXT;
939  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
940  }
941  break;
942 
943  case CF_BITMAP:
944  IntSynthesizeBitmap(pWinStaObj, pElement);
945  break;
946 
947  case CF_METAFILEPICT:
948  uSourceFmt = CF_ENHMETAFILE;
949  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
950  break;
951 
952  case CF_ENHMETAFILE:
953  uSourceFmt = CF_METAFILEPICT;
954  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
955  break;
956 
957  default:
958  ASSERT(FALSE);
959  }
960  }
961 
962  if (pElement && IS_DATA_DELAYED(pElement) && pWinStaObj->spwndClipOwner)
963  {
964  /* Send WM_RENDERFORMAT message */
965  pWinStaObj->fInDelayedRendering = TRUE;
966  co_IntSendMessage(pWinStaObj->spwndClipOwner->head.h, WM_RENDERFORMAT, (WPARAM)uSourceFmt, 0);
967  pWinStaObj->fInDelayedRendering = FALSE;
968 
969  /* Data should be in clipboard now */
970  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
971  }
972 
973  if (!pElement || IS_DATA_DELAYED(pElement))
974  goto cleanup;
975 
976  _SEH2_TRY
977  {
978  ProbeForWrite(pgcd, sizeof(*pgcd), 1);
979  pgcd->uFmtRet = pElement->fmt;
980  pgcd->fGlobalHandle = pElement->fGlobalHandle;
981 
982  /* Text and bitmap needs more data */
983  if (fmt == CF_TEXT)
984  {
985  PCLIP pLocaleEl;
986 
987  pLocaleEl = IntGetFormatElement(pWinStaObj, CF_LOCALE);
988  if (pLocaleEl && !IS_DATA_DELAYED(pLocaleEl))
989  pgcd->hLocale = pLocaleEl->hData;
990  }
991  else if (fmt == CF_BITMAP)
992  {
993  PCLIP pPaletteEl;
994 
995  pPaletteEl = IntGetFormatElement(pWinStaObj, CF_PALETTE);
996  if (pPaletteEl && !IS_DATA_DELAYED(pPaletteEl))
997  pgcd->hPalette = pPaletteEl->hData;
998  }
999 
1000  hRet = pElement->hData;
1001  }
1003  {
1005  }
1006  _SEH2_END;
1007 
1008 cleanup:
1009  if (pWinStaObj)
1010  ObDereferenceObject(pWinStaObj);
1011 
1012  UserLeave();
1013 
1014  TRACE("NtUserGetClipboardData returns %p\n", hRet);
1015 
1016  return hRet;
1017 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:241
BOOL fGlobalHandle
Definition: clipboard.h:7
#define TRUE
Definition: types.h:120
#define WM_RENDERFORMAT
Definition: winuser.h:1848
#define CF_ENHMETAFILE
Definition: constants.h:409
HANDLE hLocale
Definition: ntuser.h:1110
static PCLIP FASTCALL IntGetFormatElement(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
Definition: clipboard.c:41
static VOID WINAPI IntSynthesizeBitmap(PWINSTATION_OBJECT pWinStaObj, PCLIP pBmEl)
Definition: clipboard.c:230
INT fInDelayedRendering
Definition: winsta.h:36
#define IS_DATA_SYNTHESIZED(ce)
Definition: clipboard.c:18
const char * fmt
Definition: wsprintf.c:30
PWND spwndClipOwner
Definition: winsta.h:30
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
UINT_PTR WPARAM
Definition: windef.h:207
#define CF_METAFILEPICT
Definition: constants.h:398
HANDLE hData
Definition: clipboard.h:6
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
UINT fmt
Definition: clipboard.h:5
_SEH2_TRY
Definition: create.c:4250
Definition: clipboard.h:3
BOOL fGlobalHandle
Definition: ntuser.h:1107
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
THRDESKHEAD head
Definition: ntuser.h:659
#define CF_UNICODETEXT
Definition: constants.h:408
#define CF_BITMAP
Definition: constants.h:397
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:136
smooth NULL
Definition: ftsmooth.c:416
#define CF_TEXT
Definition: constants.h:396
#define TRACE(s)
Definition: solgame.cpp:4
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1281
#define CF_PALETTE
Definition: constants.h:404
HANDLE hPalette
Definition: ntuser.h:1111
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
#define CF_LOCALE
Definition: constants.h:411
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
_SEH2_END
Definition: create.c:4424
#define CF_OEMTEXT
Definition: constants.h:402
unsigned int UINT
Definition: ndis.h:50
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99
#define IS_DATA_DELAYED(ce)
Definition: clipboard.c:17
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
Definition: dsound.c:943
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by GetClipboardData().

◆ NtUserGetClipboardFormatName()

INT APIENTRY NtUserGetClipboardFormatName ( UINT  fmt,
LPWSTR  lpszFormatName,
INT  cchMaxCount 
)

Definition at line 733 of file clipboard.c.

734 {
735  INT iRet = 0;
736 
737  UserEnterShared();
738 
739  /* If the format is built-in we fail */
740  if (fmt < 0xc000 || fmt > 0xffff)
741  {
742  /* Registetrated formats are >= 0xc000 */
743  goto cleanup;
744  }
745 
746  if (cchMaxCount < 1 || !lpszFormatName)
747  {
749  goto cleanup;
750  }
751 
752  _SEH2_TRY
753  {
754  ProbeForWrite(lpszFormatName, cchMaxCount * sizeof(WCHAR), 1);
755 
756  iRet = IntGetAtomName((RTL_ATOM)fmt,
757  lpszFormatName,
758  cchMaxCount * sizeof(WCHAR));
759  iRet /= sizeof(WCHAR);
760  }
762  {
764  }
765  _SEH2_END;
766 
767 cleanup:
768  UserLeave();
769 
770  return iRet;
771 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:241
unsigned short RTL_ATOM
Definition: atom.c:42
int32_t INT
Definition: typedefs.h:56
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
__wchar_t WCHAR
Definition: xmlstorage.h:180
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
_SEH2_END
Definition: create.c:4424
ULONG FASTCALL IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG cjBufSize)
Definition: useratom.c:37
char * cleanup(char *str)
Definition: wpickclick.c:99
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
Definition: dsound.c:943
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by GetClipboardFormatNameA(), and GetClipboardFormatNameW().

◆ NtUserGetClipboardOwner()

HWND APIENTRY NtUserGetClipboardOwner ( VOID  )

Definition at line 774 of file clipboard.c.

775 {
776  HWND hWnd = NULL;
777  PWINSTATION_OBJECT pWinStaObj;
778 
779  UserEnterShared();
780 
781  pWinStaObj = IntGetWinStaForCbAccess();
782  if (!pWinStaObj)
783  goto cleanup;
784 
785  if (pWinStaObj->spwndClipOwner)
786  hWnd = pWinStaObj->spwndClipOwner->head.h;
787 
788  ObDereferenceObject(pWinStaObj);
789 
790 cleanup:
791  UserLeave();
792 
793  return hWnd;
794 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:241
HWND hWnd
Definition: settings.c:17
PWND spwndClipOwner
Definition: winsta.h:30
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
THRDESKHEAD head
Definition: ntuser.h:659
smooth NULL
Definition: ftsmooth.c:416
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99

Referenced by GetClipboardOwner().

◆ NtUserGetClipboardSequenceNumber()

DWORD APIENTRY NtUserGetClipboardSequenceNumber ( VOID  )

Definition at line 1161 of file clipboard.c.

1162 {
1163  DWORD dwRet = 0;
1164  PWINSTATION_OBJECT pWinStaObj;
1165 
1166  UserEnterShared();
1167 
1168  pWinStaObj = IntGetWinStaForCbAccess();
1169  if (!pWinStaObj)
1170  goto cleanup;
1171 
1172  /* Get windowstation sequence number */
1173  dwRet = (DWORD)pWinStaObj->iClipSequenceNumber;
1174 
1175  ObDereferenceObject(pWinStaObj);
1176 
1177 cleanup:
1178  UserLeave();
1179 
1180  return dwRet;
1181 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:241
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define DWORD
Definition: nt_native.h:44
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99
INT iClipSequenceNumber
Definition: winsta.h:34

Referenced by GetClipboardSequenceNumber().

◆ NtUserGetClipboardViewer()

HWND APIENTRY NtUserGetClipboardViewer ( VOID  )

Definition at line 797 of file clipboard.c.

798 {
799  HWND hWnd = NULL;
800  PWINSTATION_OBJECT pWinStaObj;
801 
802  UserEnterShared();
803 
804  pWinStaObj = IntGetWinStaForCbAccess();
805  if (!pWinStaObj)
806  goto cleanup;
807 
808  if (pWinStaObj->spwndClipViewer)
809  hWnd = pWinStaObj->spwndClipViewer->head.h;
810 
811  ObDereferenceObject(pWinStaObj);
812 
813 cleanup:
814  UserLeave();
815 
816  return hWnd;
817 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:241
HWND hWnd
Definition: settings.c:17
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PWND spwndClipViewer
Definition: winsta.h:29
THRDESKHEAD head
Definition: ntuser.h:659
smooth NULL
Definition: ftsmooth.c:416
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99

Referenced by GetClipboardViewer().

◆ NtUserGetOpenClipboardWindow()

HWND APIENTRY NtUserGetOpenClipboardWindow ( VOID  )

Definition at line 598 of file clipboard.c.

599 {
600  HWND hWnd = NULL;
601  PWINSTATION_OBJECT pWinStaObj;
602 
603  UserEnterShared();
604 
605  pWinStaObj = IntGetWinStaForCbAccess();
606  if (!pWinStaObj)
607  goto cleanup;
608 
609  if (pWinStaObj->spwndClipOpen)
610  hWnd = pWinStaObj->spwndClipOpen->head.h;
611 
612  ObDereferenceObject(pWinStaObj);
613 
614 cleanup:
615  UserLeave();
616 
617  return hWnd;
618 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:241
HWND hWnd
Definition: settings.c:17
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PWND spwndClipOpen
Definition: winsta.h:28
THRDESKHEAD head
Definition: ntuser.h:659
smooth NULL
Definition: ftsmooth.c:416
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99

Referenced by GetOpenClipboardWindow().

◆ NtUserGetPriorityClipboardFormat()

INT APIENTRY NtUserGetPriorityClipboardFormat ( UINT paFormatPriorityList,
INT  cFormats 
)

Definition at line 820 of file clipboard.c.

821 {
822  INT i, iRet = 0;
823  PWINSTATION_OBJECT pWinStaObj;
824 
825  UserEnterShared();
826 
827  pWinStaObj = IntGetWinStaForCbAccess();
828  if (!pWinStaObj)
829  goto cleanup;
830 
831  if (pWinStaObj->pClipBase == NULL)
832  {
833  iRet = 0;
834  }
835  else
836  {
837  _SEH2_TRY
838  {
839  ProbeForRead(paFormatPriorityList, cFormats * sizeof(UINT), sizeof(UINT));
840 
841  iRet = -1;
842 
843  for (i = 0; i < cFormats; ++i)
844  {
845  if (IntIsFormatAvailable(pWinStaObj, paFormatPriorityList[i]))
846  {
847  iRet = paFormatPriorityList[i];
848  break;
849  }
850  }
851  }
853  {
855  }
856  _SEH2_END;
857  }
858 
859  ObDereferenceObject(pWinStaObj);
860 
861 cleanup:
862  UserLeave();
863 
864  return iRet;
865 
866 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:241
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
int32_t INT
Definition: typedefs.h:56
_SEH2_TRY
Definition: create.c:4250
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
PCLIP pClipBase
Definition: winsta.h:31
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
_SEH2_END
Definition: create.c:4424
static BOOL FASTCALL IntIsFormatAvailable(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
Definition: clipboard.c:55
unsigned int UINT
Definition: ndis.h:50
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12

Referenced by GetPriorityClipboardFormat().

◆ NtUserIsClipboardFormatAvailable()

BOOL APIENTRY NtUserIsClipboardFormatAvailable ( UINT  fmt)

Definition at line 869 of file clipboard.c.

870 {
871  BOOL bRet = FALSE;
872  PWINSTATION_OBJECT pWinStaObj;
873 
874  TRACE("NtUserIsClipboardFormatAvailable(%x)\n", fmt);
875 
876  UserEnterShared();
877 
878  pWinStaObj = IntGetWinStaForCbAccess();
879  if (!pWinStaObj)
880  goto cleanup;
881 
882  if (IntIsFormatAvailable(pWinStaObj, fmt))
883  bRet = TRUE;
884 
885  ObDereferenceObject(pWinStaObj);
886 
887 cleanup:
888  UserLeave();
889 
890  return bRet;
891 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:241
#define TRUE
Definition: types.h:120
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
static BOOL FASTCALL IntIsFormatAvailable(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
Definition: clipboard.c:55
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99
Definition: dsound.c:943

Referenced by IsClipboardFormatAvailable().

◆ NtUserOpenClipboard()

BOOL APIENTRY NtUserOpenClipboard ( HWND  hWnd,
DWORD  Unknown1 
)

Definition at line 530 of file clipboard.c.

531 {
532  BOOL bRet;
533 
535  bRet = UserOpenClipboard(hWnd);
536  UserLeave();
537 
538  return bRet;
539 }
HWND hWnd
Definition: settings.c:17
BOOL NTAPI UserOpenClipboard(HWND hWnd)
Definition: clipboard.c:485
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255

Referenced by OpenClipboard().

◆ NtUserSetClipboardData()

HANDLE APIENTRY NtUserSetClipboardData ( UINT  fmt,
HANDLE  hData,
PSETCLIPBDATA  pUnsafeScd 
)

Definition at line 1081 of file clipboard.c.

1082 {
1083  SETCLIPBDATA scd;
1084  HANDLE hRet;
1085 
1086  TRACE("NtUserSetClipboardData(%x %p %p)\n", fmt, hData, pUnsafeScd);
1087 
1088  _SEH2_TRY
1089  {
1090  ProbeForRead(pUnsafeScd, sizeof(*pUnsafeScd), 1);
1091  RtlCopyMemory(&scd, pUnsafeScd, sizeof(scd));
1092  }
1094  {
1096  _SEH2_YIELD(return NULL;)
1097  }
1098  _SEH2_END
1099 
1101 
1102  /* Call internal function */
1103  hRet = UserSetClipboardData(fmt, hData, &scd);
1104 
1105  UserLeave();
1106 
1107  return hRet;
1108 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define TRACE(s)
Definition: solgame.cpp:4
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
_SEH2_END
Definition: create.c:4424
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
Definition: dsound.c:943
HANDLE NTAPI UserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA scd)
Definition: clipboard.c:1020

Referenced by GetClipboardData(), and SetClipboardData().

◆ NtUserSetClipboardViewer()

HWND APIENTRY NtUserSetClipboardViewer ( HWND  hWndNewViewer)

Definition at line 1111 of file clipboard.c.

1112 {
1113  HWND hWndNext = NULL;
1114  PWINSTATION_OBJECT pWinStaObj;
1115  PWND pWindow;
1116 
1118 
1119  pWinStaObj = IntGetWinStaForCbAccess();
1120  if (!pWinStaObj)
1121  goto cleanup;
1122 
1123  pWindow = UserGetWindowObject(hWndNewViewer);
1124  if (!pWindow)
1125  {
1127  goto cleanup;
1128  }
1129 
1130  /* Return previous viewer. New viever window should
1131  send messages to rest of the chain */
1132  if (pWinStaObj->spwndClipViewer)
1133  hWndNext = pWinStaObj->spwndClipViewer->head.h;
1134 
1135  /* Set new viewer window */
1136  pWinStaObj->spwndClipViewer = pWindow;
1137 
1138  /* Notify viewer windows in chain */
1139  pWinStaObj->fClipboardChanged = FALSE;
1140  if (pWinStaObj->spwndClipViewer)
1141  {
1142  TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
1143  // For 32-bit applications this message is sent as a notification
1145  }
1146 
1147 cleanup:
1148  if (pWinStaObj)
1149  ObDereferenceObject(pWinStaObj);
1150 
1151  UserLeave();
1152 
1153  return hWndNext;
1154 }
INT fClipboardChanged
Definition: winsta.h:35
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PWND spwndClipViewer
Definition: winsta.h:29
THRDESKHEAD head
Definition: ntuser.h:659
smooth NULL
Definition: ftsmooth.c:416
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1851
Definition: ntuser.h:657
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1547
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by SetClipboardViewer().

◆ UserClipboardFreeWindow()

VOID FASTCALL UserClipboardFreeWindow ( PWND  pWindow)

Definition at line 411 of file clipboard.c.

412 {
413  PWINSTATION_OBJECT pWinStaObj;
414 
415  pWinStaObj = IntGetWinStaForCbAccess();
416  if (!pWinStaObj)
417  return;
418 
419  if (pWindow == pWinStaObj->spwndClipOwner)
420  {
421  /* The owner window was destroyed */
422  pWinStaObj->spwndClipOwner = NULL;
423  }
424 
425  /* Check if clipboard is not locked by this window, if yes, unlock it */
426  if (pWindow == pWinStaObj->spwndClipOpen)
427  {
428  /* The window that opens the clipboard was destroyed */
429  pWinStaObj->spwndClipOpen = NULL;
430  pWinStaObj->ptiClipLock = NULL;
431  }
432  /* Remove window from window chain */
433  if (pWindow == pWinStaObj->spwndClipViewer)
434  pWinStaObj->spwndClipViewer = NULL;
435 
436  ObDereferenceObject(pWinStaObj);
437 }
PWND spwndClipOwner
Definition: winsta.h:30
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PWND spwndClipViewer
Definition: winsta.h:29
PWND spwndClipOpen
Definition: winsta.h:28
smooth NULL
Definition: ftsmooth.c:416
PTHREADINFO ptiClipLock
Definition: winsta.h:26
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21

Referenced by co_UserFreeWindow().

◆ UserClipboardRelease()

VOID FASTCALL UserClipboardRelease ( PWND  pWindow)

Definition at line 374 of file clipboard.c.

375 {
376  PWINSTATION_OBJECT pWinStaObj;
377 
378  pWinStaObj = IntGetWinStaForCbAccess();
379  if (!pWinStaObj)
380  return;
381 
383 
384  /* If the window being destroyed is the current clipboard owner... */
385  if (pWindow == pWinStaObj->spwndClipOwner)
386  {
387  /* ... make it release the clipboard */
388  pWinStaObj->spwndClipOwner = NULL;
389  }
390 
391  if (pWinStaObj->fClipboardChanged)
392  {
393  /* Add synthesized formats - they are rendered later */
394  IntAddSynthesizedFormats(pWinStaObj);
395 
396  /* Notify viewer windows in chain */
397  pWinStaObj->fClipboardChanged = FALSE;
398  if (pWinStaObj->spwndClipViewer)
399  {
400  TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
401  // For 32-bit applications this message is sent as a notification
403  }
404  }
405 
406  ObDereferenceObject(pWinStaObj);
407 }
INT fClipboardChanged
Definition: winsta.h:35
static VOID NTAPI IntAddSynthesizedFormats(PWINSTATION_OBJECT pWinStaObj)
Definition: clipboard.c:291
#define WM_RENDERALLFORMATS
Definition: winuser.h:1849
PWND spwndClipOwner
Definition: winsta.h:30
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PWND spwndClipViewer
Definition: winsta.h:29
THRDESKHEAD head
Definition: ntuser.h:659
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1281
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1851
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1547
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21

Referenced by IntSendDestroyMsg().

◆ UserCloseClipboard()

BOOL NTAPI UserCloseClipboard ( VOID  )

Definition at line 542 of file clipboard.c.

543 {
544  BOOL bRet = FALSE;
545  PWINSTATION_OBJECT pWinStaObj;
546 
547  pWinStaObj = IntGetWinStaForCbAccess();
548  if (!pWinStaObj)
549  goto cleanup;
550 
551  /* Check if the clipboard has been opened */
552  if (!IntIsClipboardOpenByMe(pWinStaObj))
553  {
555  goto cleanup;
556  }
557 
558  /* Clipboard is no longer open */
559  pWinStaObj->spwndClipOpen = NULL;
560  pWinStaObj->ptiClipLock = NULL;
561  bRet = TRUE;
562 
563  if (pWinStaObj->fClipboardChanged)
564  {
565  /* Add synthesized formats - they are rendered later */
566  IntAddSynthesizedFormats(pWinStaObj);
567 
568  /* Notify viewer windows in chain */
569  pWinStaObj->fClipboardChanged = FALSE;
570  if (pWinStaObj->spwndClipViewer)
571  {
572  TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
573  // For 32-bit applications this message is sent as a notification
575  }
576  }
577 
578 cleanup:
579  if (pWinStaObj)
580  ObDereferenceObject(pWinStaObj);
581 
582  return bRet;
583 }
INT fClipboardChanged
Definition: winsta.h:35
#define TRUE
Definition: types.h:120
static VOID NTAPI IntAddSynthesizedFormats(PWINSTATION_OBJECT pWinStaObj)
Definition: clipboard.c:291
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PWND spwndClipViewer
Definition: winsta.h:29
PWND spwndClipOpen
Definition: winsta.h:28
unsigned int BOOL
Definition: ntddk_ex.h:94
THRDESKHEAD head
Definition: ntuser.h:659
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:136
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
PTHREADINFO ptiClipLock
Definition: winsta.h:26
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1851
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1547
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by DefWndScreenshot(), ExitThreadCallback(), NtUserCloseClipboard(), and SnapWindow().

◆ UserEmptyClipboard()

BOOL NTAPI UserEmptyClipboard ( VOID  )

Definition at line 677 of file clipboard.c.

678 {
679  BOOL bRet = FALSE;
680  PWINSTATION_OBJECT pWinStaObj;
681 
682  pWinStaObj = IntGetWinStaForCbAccess();
683  if (!pWinStaObj)
684  return FALSE;
685 
686  /* Check if the clipboard has been opened */
687  if (!IntIsClipboardOpenByMe(pWinStaObj))
688  {
690  goto cleanup;
691  }
692 
693  UserEmptyClipboardData(pWinStaObj);
694 
695  if (pWinStaObj->spwndClipOwner)
696  {
697  TRACE("Clipboard: WM_DESTROYCLIPBOARD to %p\n", pWinStaObj->spwndClipOwner->head.h);
698  // For 32-bit applications this message is sent as a notification
700  }
701 
702  pWinStaObj->spwndClipOwner = pWinStaObj->spwndClipOpen;
703 
704  pWinStaObj->iClipSerialNumber++;
705  pWinStaObj->iClipSequenceNumber++;
706  pWinStaObj->fClipboardChanged = TRUE;
707  pWinStaObj->fInDelayedRendering = FALSE;
708 
709  bRet = TRUE;
710 
711 cleanup:
712  if (pWinStaObj)
713  ObDereferenceObject(pWinStaObj);
714 
715  return bRet;
716 }
INT fClipboardChanged
Definition: winsta.h:35
#define TRUE
Definition: types.h:120
VOID NTAPI UserEmptyClipboardData(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:354
INT fInDelayedRendering
Definition: winsta.h:36
PWND spwndClipOwner
Definition: winsta.h:30
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PWND spwndClipOpen
Definition: winsta.h:28
unsigned int BOOL
Definition: ntddk_ex.h:94
INT iClipSerialNumber
Definition: winsta.h:33
THRDESKHEAD head
Definition: ntuser.h:659
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:136
#define TRACE(s)
Definition: solgame.cpp:4
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1281
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
#define WM_DESTROYCLIPBOARD
Definition: winuser.h:1850
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99
INT iClipSequenceNumber
Definition: winsta.h:34
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by DefWndScreenshot(), NtUserEmptyClipboard(), and SnapWindow().

◆ UserEmptyClipboardData()

VOID NTAPI UserEmptyClipboardData ( PWINSTATION_OBJECT  pWinSta)

Definition at line 354 of file clipboard.c.

355 {
356  DWORD i;
357  PCLIP pElement;
358 
359  for (i = 0; i < pWinSta->cNumClipFormats; ++i)
360  {
361  pElement = &pWinSta->pClipBase[i];
362  IntFreeElementData(pElement);
363  }
364 
365  if (pWinSta->pClipBase)
367 
368  pWinSta->pClipBase = NULL;
369  pWinSta->cNumClipFormats = 0;
370 }
static VOID FASTCALL IntFreeElementData(PCLIP pElement)
Definition: clipboard.c:61
#define USERTAG_CLIPBOARD
Definition: tags.h:199
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: clipboard.h:3
smooth NULL
Definition: ftsmooth.c:416
PCLIP pClipBase
Definition: winsta.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD cNumClipFormats
Definition: winsta.h:32
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by IntWinStaObjectDelete(), and UserEmptyClipboard().

◆ UserEnumClipboardFormats()

UINT APIENTRY UserEnumClipboardFormats ( UINT  fmt)

Definition at line 440 of file clipboard.c.

441 {
442  UINT Ret = 0;
443  PCLIP pElement;
444  PWINSTATION_OBJECT pWinStaObj;
445 
446  pWinStaObj = IntGetWinStaForCbAccess();
447  if (!pWinStaObj)
448  goto cleanup;
449 
450  /* Check if the clipboard has been opened */
451  if (!IntIsClipboardOpenByMe(pWinStaObj))
452  {
454  goto cleanup;
455  }
456 
457  if (fmt == 0)
458  {
459  /* Return first format */
460  if (pWinStaObj->pClipBase)
461  Ret = pWinStaObj->pClipBase[0].fmt;
462  }
463  else
464  {
465  /* Return next format */
466  pElement = IntGetFormatElement(pWinStaObj, fmt);
467  if (pElement != NULL)
468  {
469  ++pElement;
470  if (pElement < &pWinStaObj->pClipBase[pWinStaObj->cNumClipFormats])
471  {
472  Ret = pElement->fmt;
473  }
474  }
475  }
476 
477 cleanup:
478  if (pWinStaObj)
479  ObDereferenceObject(pWinStaObj);
480 
481  return Ret;
482 }
static PCLIP FASTCALL IntGetFormatElement(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
Definition: clipboard.c:41
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
UINT fmt
Definition: clipboard.h:5
Definition: clipboard.h:3
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:136
smooth NULL
Definition: ftsmooth.c:416
PCLIP pClipBase
Definition: winsta.h:31
DWORD cNumClipFormats
Definition: winsta.h:32
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
unsigned int UINT
Definition: ndis.h:50
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99
Definition: dsound.c:943
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by NtUserCallOneParam().

◆ UserOpenClipboard()

BOOL NTAPI UserOpenClipboard ( HWND  hWnd)

Definition at line 485 of file clipboard.c.

486 {
487  PWND pWindow = NULL;
488  BOOL bRet = FALSE;
489  PWINSTATION_OBJECT pWinStaObj = NULL;
490 
491  if (hWnd)
492  {
493  pWindow = UserGetWindowObject(hWnd);
494  if (!pWindow)
495  goto cleanup;
496  }
497 
498  pWinStaObj = IntGetWinStaForCbAccess();
499  if (!pWinStaObj)
500  goto cleanup;
501 
502  /* Check if we already opened the clipboard */
503  if ((pWindow == pWinStaObj->spwndClipOpen) && IntIsClipboardOpenByMe(pWinStaObj))
504  {
505  bRet = TRUE;
506  goto cleanup;
507  }
508 
509  /* If the clipboard was already opened by somebody else, bail out */
510  if ((pWindow != pWinStaObj->spwndClipOpen) && pWinStaObj->ptiClipLock)
511  {
512  ERR("Access denied!\n");
514  goto cleanup;
515  }
516 
517  /* Open the clipboard */
518  pWinStaObj->spwndClipOpen = pWindow;
520  bRet = TRUE;
521 
522 cleanup:
523  if (pWinStaObj)
524  ObDereferenceObject(pWinStaObj);
525 
526  return bRet;
527 }
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
HWND hWnd
Definition: settings.c:17
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PWND spwndClipOpen
Definition: winsta.h:28
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:136
smooth NULL
Definition: ftsmooth.c:416
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
PTHREADINFO ptiClipLock
Definition: winsta.h:26
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by DefWndScreenshot(), NtUserOpenClipboard(), and SnapWindow().

◆ UserSetClipboardData()

HANDLE NTAPI UserSetClipboardData ( UINT  fmt,
HANDLE  hData,
PSETCLIPBDATA  scd 
)

Definition at line 1020 of file clipboard.c.

1021 {
1022  HANDLE hRet = NULL;
1023  PWINSTATION_OBJECT pWinStaObj;
1024 
1025  pWinStaObj = IntGetWinStaForCbAccess();
1026  if (!pWinStaObj)
1027  goto cleanup;
1028 
1029  if (!fmt || !pWinStaObj->ptiClipLock)
1030  {
1031  ERR("Access denied!\n");
1033  goto cleanup;
1034  }
1035 
1036  if (scd->fIncSerialNumber)
1037  pWinStaObj->iClipSerialNumber++;
1038 
1039  /* Is it a delayed rendering? */
1040  if (hData)
1041  {
1042  /* Is it a bitmap? */
1043  if (fmt == CF_BITMAP)
1044  {
1045  /* Make bitmap public */
1047  }
1048 
1049  /* Save data in the clipboard */
1050  IntAddFormatedData(pWinStaObj, fmt, hData, scd->fGlobalHandle, FALSE);
1051  TRACE("hData stored\n");
1052 
1053  /* If the serial number was increased, increase also the sequence number */
1054  if (scd->fIncSerialNumber)
1055  pWinStaObj->iClipSequenceNumber++;
1056 
1057  pWinStaObj->fClipboardChanged = TRUE;
1058 
1059  /* Note: Synthesized formats are added in NtUserCloseClipboard */
1060  }
1061  else
1062  {
1063  /* This is a delayed rendering */
1064  IntAddFormatedData(pWinStaObj, fmt, DATA_DELAYED, FALSE, FALSE);
1065  TRACE("SetClipboardData delayed format: %u\n", fmt);
1066  }
1067 
1068  /* Return hData on success */
1069  hRet = hData;
1070 
1071 cleanup:
1072  TRACE("NtUserSetClipboardData returns: %p\n", hRet);
1073 
1074  if (pWinStaObj)
1075  ObDereferenceObject(pWinStaObj);
1076 
1077  return hRet;
1078 }
INT fClipboardChanged
Definition: winsta.h:35
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1252
#define TRUE
Definition: types.h:120
#define DATA_DELAYED
Definition: clipboard.c:14
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
INT iClipSerialNumber
Definition: winsta.h:33
BOOL fGlobalHandle
Definition: ntuser.h:1117
#define CF_BITMAP
Definition: constants.h:397
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
PTHREADINFO ptiClipLock
Definition: winsta.h:26
static PCLIP NTAPI IntAddFormatedData(PWINSTATION_OBJECT pWinStaObj, UINT fmt, HANDLE hData, BOOLEAN fGlobalHandle, BOOL bEnd)
Definition: clipboard.c:84
#define ERR(fmt,...)
Definition: debug.h:109
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
BOOL fIncSerialNumber
Definition: ntuser.h:1118
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21
char * cleanup(char *str)
Definition: wpickclick.c:99
INT iClipSequenceNumber
Definition: winsta.h:34
Definition: dsound.c:943
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by DefWndScreenshot(), NtUserSetClipboardData(), and SnapWindow().