ReactOS  0.4.15-dev-3187-ge372f2b
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
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
#define NULL
Definition: types.h:112
#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 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 TRUE
Definition: types.h:120
#define DATA_SYNTH_USER
Definition: clipboard.c:15
BYTE Data[0]
Definition: ntuser.h:241
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
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CF_UNICODETEXT
Definition: constants.h:408
#define CF_BITMAP
Definition: constants.h:397
#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:240
#define NULL
Definition: types.h:112
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:1255
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:683
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
#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
PCLIP pClipBase
Definition: winsta.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD cNumClipFormats
Definition: winsta.h:32
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 NULL
Definition: types.h:112
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
NTSTATUS FASTCALL IntValidateWindowStationHandle(HWINSTA WindowStation, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PWINSTATION_OBJECT *Object, POBJECT_HANDLE_INFORMATION pObjectHandleInfo)
Definition: winsta.c:230
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
HWINSTA FASTCALL UserGetProcessWindowStation(VOID)
Definition: winsta.c:1333
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
#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
#define NULL
Definition: types.h:112
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:2271
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1255
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1475
static PCLIP FASTCALL IntGetFormatElement(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
Definition: clipboard.c:41
BYTE Data[0]
Definition: ntuser.h:241
#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
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define CBM_INIT
Definition: wingdi.h:364
INT FASTCALL DIB_BitmapInfoSize(const BITMAPINFO *info, WORD coloruse, BOOL max)
Definition: bitmap.c:19
Definition: clipboard.h:3
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
#define ASSERT(a)
Definition: mode.c:44
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:1686
HDC hdc
Definition: main.c:9
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:462
DWORD cbData
Definition: ntuser.h:240
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
#define NULL
Definition: types.h:112
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:2207
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
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1475
#define TRUE
Definition: types.h:120
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
BYTE Data[0]
Definition: ntuser.h:241
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:58
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:19
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
_In_z_ PCWSTR _In_ ULONG _Post_z_ PVOID _In_ ULONG cjDataSize
Definition: ntuser.h:39
ULONG RGBQUAD
Definition: precomp.h:50
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:240
#define NULL
Definition: types.h:112
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:690
#define CF_DIB
Definition: constants.h:403

Referenced by IntAddSynthesizedFormats().

◆ NtUserChangeClipboardChain()

BOOL APIENTRY NtUserChangeClipboardChain ( HWND  hWndRemove,
HWND  hWndNewNext 
)

Definition at line 624 of file clipboard.c.

625 {
626  BOOL bRet = FALSE;
627  PWND pWindowRemove;
628  PWINSTATION_OBJECT pWinStaObj;
629 
630  TRACE("NtUserChangeClipboardChain(%p, %p)\n", hWndRemove, hWndNewNext);
631 
633 
634  pWinStaObj = IntGetWinStaForCbAccess();
635  if (!pWinStaObj)
636  goto cleanup;
637 
638  pWindowRemove = UserGetWindowObject(hWndRemove);
639 
640  if (pWindowRemove && pWinStaObj->spwndClipViewer)
641  {
642  if (pWindowRemove == pWinStaObj->spwndClipViewer)
643  pWinStaObj->spwndClipViewer = UserGetWindowObject(hWndNewNext);
644 
645  if (pWinStaObj->spwndClipViewer)
646  bRet = (BOOL)co_IntSendMessage(pWinStaObj->spwndClipViewer->head.h, WM_CHANGECBCHAIN, (WPARAM)hWndRemove, (LPARAM)hWndNewNext);
647  }
648 
649  ObDereferenceObject(pWinStaObj);
650 
651 cleanup:
652  UserLeave();
653 
654  return bRet;
655 }
#define WM_CHANGECBCHAIN
Definition: winuser.h:1857
static BOOL(WINAPI *pAddClipboardFormatListener)(HWND hwnd)
UINT_PTR WPARAM
Definition: windef.h:207
PWND spwndClipViewer
Definition: winsta.h:29
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
THRDESKHEAD head
Definition: ntuser.h:665
LONG_PTR LPARAM
Definition: windef.h:208
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245
#define TRACE(s)
Definition: solgame.cpp:4
#define ObDereferenceObject
Definition: obfuncs.h:203
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
Definition: ntuser.h:663
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
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 589 of file clipboard.c.

590 {
591  BOOL bRet;
592 
594  bRet = UserCloseClipboard();
595  UserLeave();
596 
597  return bRet;
598 }
BOOL NTAPI UserCloseClipboard(VOID)
Definition: clipboard.c:545
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253

Referenced by CloseClipboard().

◆ NtUserConvertMemHandle()

HANDLE APIENTRY NtUserConvertMemHandle ( PVOID  pData,
DWORD  cbData 
)

Definition at line 1187 of file clipboard.c.

1190 {
1191  HANDLE hMem = NULL;
1192  PCLIPBOARDDATA pMemObj;
1193 
1195 
1196  /* Create Clipboard data object */
1197  pMemObj = UserCreateObject(gHandleTable, NULL, NULL, &hMem, TYPE_CLIPDATA, sizeof(CLIPBOARDDATA) + cbData);
1198  if (!pMemObj)
1199  goto cleanup;
1200 
1201  pMemObj->cbData = cbData;
1202 
1203  /* Copy data */
1204  _SEH2_TRY
1205  {
1206  ProbeForRead(pData, cbData, 1);
1207  memcpy(pMemObj->Data, pData, cbData);
1208  }
1210  {
1211  pMemObj = NULL;
1212  }
1213  _SEH2_END;
1214 
1215  /* Release the extra reference (UserCreateObject added 2 references) */
1216  UserDereferenceObject(pMemObj);
1217 
1218  /* If we failed to copy data, remove handle */
1219  if (!pMemObj)
1220  {
1222  hMem = NULL;
1223  }
1224 
1225 cleanup:
1226  UserLeave();
1227 
1228  return hMem;
1229 }
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:683
BYTE Data[0]
Definition: ntuser.h:241
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:4226
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
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:253
_SEH2_END
Definition: create.c:4400
DWORD cbData
Definition: ntuser.h:240
#define NULL
Definition: types.h:112
char * cleanup(char *str)
Definition: wpickclick.c:99
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
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 658 of file clipboard.c.

659 {
660  DWORD cFormats = 0;
661  PWINSTATION_OBJECT pWinStaObj;
662 
663  UserEnterShared();
664 
665  pWinStaObj = IntGetWinStaForCbAccess();
666  if (!pWinStaObj)
667  goto cleanup;
668 
669  cFormats = pWinStaObj->cNumClipFormats;
670 
671  ObDereferenceObject(pWinStaObj);
672 
673 cleanup:
674  UserLeave();
675 
676  return cFormats;
677 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:239
#define ObDereferenceObject
Definition: obfuncs.h:203
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD cNumClipFormats
Definition: winsta.h:32
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
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 1232 of file clipboard.c.

1237 {
1238  PCLIPBOARDDATA pMemObj;
1240 
1241  UserEnterShared();
1242 
1243  /* Get Clipboard data object */
1245  if (!pMemObj)
1246  {
1248  goto cleanup;
1249  }
1250 
1251  /* Don't overrun */
1252  if (cbData > pMemObj->cbData)
1253  cbData = pMemObj->cbData;
1254 
1255  /* Copy data to usermode */
1256  _SEH2_TRY
1257  {
1258  if (pcbData)
1259  {
1260  ProbeForWrite(pcbData, sizeof(*pcbData), 1);
1261  *pcbData = pMemObj->cbData;
1262  }
1263 
1264  ProbeForWrite(pData, cbData, 1);
1265  memcpy(pData, pMemObj->Data, cbData);
1266  }
1268  {
1270  }
1271  _SEH2_END;
1272 
1273 cleanup:
1274  UserLeave();
1275 
1276  return Status;
1277 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:239
BYTE Data[0]
Definition: ntuser.h:241
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:245
_SEH2_TRY
Definition: create.c:4226
Status
Definition: gdiplustypes.h:24
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
_SEH2_END
Definition: create.c:4400
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:462
DWORD cbData
Definition: ntuser.h:240
struct tagCLIPBOARDDATA * PCLIPBOARDDATA
char * cleanup(char *str)
Definition: wpickclick.c:99
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4949

Referenced by GetClipboardData().

◆ NtUserEmptyClipboard()

BOOL APIENTRY NtUserEmptyClipboard ( VOID  )

Definition at line 722 of file clipboard.c.

723 {
724  BOOL bRet;
725 
726  TRACE("NtUserEmptyClipboard()\n");
727 
729  bRet = UserEmptyClipboard();
730  UserLeave();
731 
732  return bRet;
733 }
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245
#define TRACE(s)
Definition: solgame.cpp:4
BOOL NTAPI UserEmptyClipboard(VOID)
Definition: clipboard.c:680
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253

Referenced by EmptyClipboard().

◆ NtUserGetClipboardData()

HANDLE APIENTRY NtUserGetClipboardData ( UINT  fmt,
PGETCLIPBDATA  pgcd 
)

Definition at line 897 of file clipboard.c.

898 {
899  HANDLE hRet = NULL;
900  PCLIP pElement;
901  PWINSTATION_OBJECT pWinStaObj;
902  UINT uSourceFmt = fmt;
903 
904  TRACE("NtUserGetClipboardData(%x, %p)\n", fmt, pgcd);
905 
906  UserEnterShared();
907 
908  pWinStaObj = IntGetWinStaForCbAccess();
909  if (!pWinStaObj)
910  goto cleanup;
911 
912  /* Check if the clipboard has been opened */
913  if (!IntIsClipboardOpenByMe(pWinStaObj))
914  {
916  goto cleanup;
917  }
918 
919  pElement = IntGetFormatElement(pWinStaObj, fmt);
920  if (!pElement)
921  goto cleanup;
922 
923  if (IS_DATA_SYNTHESIZED(pElement))
924  {
925  /* Note: Data is synthesized in usermode */
926  /* TODO: Add more formats */
927  switch (fmt)
928  {
929  case CF_UNICODETEXT:
930  case CF_TEXT:
931  case CF_OEMTEXT:
932  uSourceFmt = CF_UNICODETEXT;
933  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
934  if (IS_DATA_SYNTHESIZED(pElement))
935  {
936  uSourceFmt = CF_TEXT;
937  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
938  }
939  if (IS_DATA_SYNTHESIZED(pElement))
940  {
941  uSourceFmt = CF_OEMTEXT;
942  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
943  }
944  break;
945 
946  case CF_BITMAP:
947  IntSynthesizeBitmap(pWinStaObj, pElement);
948  break;
949 
950  case CF_METAFILEPICT:
951  uSourceFmt = CF_ENHMETAFILE;
952  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
953  break;
954 
955  case CF_ENHMETAFILE:
956  uSourceFmt = CF_METAFILEPICT;
957  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
958  break;
959 
960  default:
961  ASSERT(FALSE);
962  }
963  }
964 
965  if (pElement && IS_DATA_DELAYED(pElement) && pWinStaObj->spwndClipOwner)
966  {
967  /* Send WM_RENDERFORMAT message */
968  pWinStaObj->fInDelayedRendering = TRUE;
969  co_IntSendMessage(pWinStaObj->spwndClipOwner->head.h, WM_RENDERFORMAT, (WPARAM)uSourceFmt, 0);
970  pWinStaObj->fInDelayedRendering = FALSE;
971 
972  /* Data should be in clipboard now */
973  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
974  }
975 
976  if (!pElement || IS_DATA_DELAYED(pElement))
977  goto cleanup;
978 
979  _SEH2_TRY
980  {
981  ProbeForWrite(pgcd, sizeof(*pgcd), 1);
982  pgcd->uFmtRet = pElement->fmt;
983  pgcd->fGlobalHandle = pElement->fGlobalHandle;
984 
985  /* Text and bitmap needs more data */
986  if (fmt == CF_TEXT)
987  {
988  PCLIP pLocaleEl;
989 
990  pLocaleEl = IntGetFormatElement(pWinStaObj, CF_LOCALE);
991  if (pLocaleEl && !IS_DATA_DELAYED(pLocaleEl))
992  pgcd->hLocale = pLocaleEl->hData;
993  }
994  else if (fmt == CF_BITMAP)
995  {
996  PCLIP pPaletteEl;
997 
998  pPaletteEl = IntGetFormatElement(pWinStaObj, CF_PALETTE);
999  if (pPaletteEl && !IS_DATA_DELAYED(pPaletteEl))
1000  pgcd->hPalette = pPaletteEl->hData;
1001  }
1002 
1003  hRet = pElement->hData;
1004  }
1006  {
1008  }
1009  _SEH2_END;
1010 
1011 cleanup:
1012  if (pWinStaObj)
1013  ObDereferenceObject(pWinStaObj);
1014 
1015  UserLeave();
1016 
1017  TRACE("NtUserGetClipboardData returns %p\n", hRet);
1018 
1019  return hRet;
1020 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:239
BOOL fGlobalHandle
Definition: clipboard.h:7
#define WM_RENDERFORMAT
Definition: winuser.h:1849
#define CF_ENHMETAFILE
Definition: constants.h:409
HANDLE hLocale
Definition: ntuser.h:1119
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
#define TRUE
Definition: types.h:120
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
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:4226
Definition: clipboard.h:3
#define FALSE
Definition: types.h:117
BOOL fGlobalHandle
Definition: ntuser.h:1116
THRDESKHEAD head
Definition: ntuser.h:665
#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
#define CF_TEXT
Definition: constants.h:396
#define TRACE(s)
Definition: solgame.cpp:4
#define ASSERT(a)
Definition: mode.c:44
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define ObDereferenceObject
Definition: obfuncs.h:203
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
#define CF_PALETTE
Definition: constants.h:404
HANDLE hPalette
Definition: ntuser.h:1120
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
#define CF_LOCALE
Definition: constants.h:411
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
_SEH2_END
Definition: create.c:4400
#define CF_OEMTEXT
Definition: constants.h:402
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
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:40
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
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 736 of file clipboard.c.

737 {
738  INT iRet = 0;
739 
740  UserEnterShared();
741 
742  /* If the format is built-in we fail */
743  if (fmt < 0xc000 || fmt > 0xffff)
744  {
745  /* Registetrated formats are >= 0xc000 */
746  goto cleanup;
747  }
748 
749  if (cchMaxCount < 1 || !lpszFormatName)
750  {
752  goto cleanup;
753  }
754 
755  _SEH2_TRY
756  {
757  ProbeForWrite(lpszFormatName, cchMaxCount * sizeof(WCHAR), 1);
758 
759  iRet = IntGetAtomName((RTL_ATOM)fmt,
760  lpszFormatName,
761  cchMaxCount * sizeof(WCHAR));
762  iRet /= sizeof(WCHAR);
763  }
765  {
767  }
768  _SEH2_END;
769 
770 cleanup:
771  UserLeave();
772 
773  return iRet;
774 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:239
unsigned short RTL_ATOM
Definition: atom.c:42
int32_t INT
Definition: typedefs.h:58
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4226
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
_SEH2_END
Definition: create.c:4400
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:40
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
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 777 of file clipboard.c.

778 {
779  HWND hWnd = NULL;
780  PWINSTATION_OBJECT pWinStaObj;
781 
782  UserEnterShared();
783 
784  pWinStaObj = IntGetWinStaForCbAccess();
785  if (!pWinStaObj)
786  goto cleanup;
787 
788  if (pWinStaObj->spwndClipOwner)
789  hWnd = pWinStaObj->spwndClipOwner->head.h;
790 
791  ObDereferenceObject(pWinStaObj);
792 
793 cleanup:
794  UserLeave();
795 
796  return hWnd;
797 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:239
HWND hWnd
Definition: settings.c:17
PWND spwndClipOwner
Definition: winsta.h:30
THRDESKHEAD head
Definition: ntuser.h:665
#define ObDereferenceObject
Definition: obfuncs.h:203
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
#define NULL
Definition: types.h:112
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 1164 of file clipboard.c.

1165 {
1166  DWORD dwRet = 0;
1167  PWINSTATION_OBJECT pWinStaObj;
1168 
1169  UserEnterShared();
1170 
1171  pWinStaObj = IntGetWinStaForCbAccess();
1172  if (!pWinStaObj)
1173  goto cleanup;
1174 
1175  /* Get windowstation sequence number */
1176  dwRet = (DWORD)pWinStaObj->iClipSequenceNumber;
1177 
1178  ObDereferenceObject(pWinStaObj);
1179 
1180 cleanup:
1181  UserLeave();
1182 
1183  return dwRet;
1184 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:239
#define DWORD
Definition: nt_native.h:44
#define ObDereferenceObject
Definition: obfuncs.h:203
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
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 800 of file clipboard.c.

801 {
802  HWND hWnd = NULL;
803  PWINSTATION_OBJECT pWinStaObj;
804 
805  UserEnterShared();
806 
807  pWinStaObj = IntGetWinStaForCbAccess();
808  if (!pWinStaObj)
809  goto cleanup;
810 
811  if (pWinStaObj->spwndClipViewer)
812  hWnd = pWinStaObj->spwndClipViewer->head.h;
813 
814  ObDereferenceObject(pWinStaObj);
815 
816 cleanup:
817  UserLeave();
818 
819  return hWnd;
820 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:239
HWND hWnd
Definition: settings.c:17
PWND spwndClipViewer
Definition: winsta.h:29
THRDESKHEAD head
Definition: ntuser.h:665
#define ObDereferenceObject
Definition: obfuncs.h:203
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
#define NULL
Definition: types.h:112
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 601 of file clipboard.c.

602 {
603  HWND hWnd = NULL;
604  PWINSTATION_OBJECT pWinStaObj;
605 
606  UserEnterShared();
607 
608  pWinStaObj = IntGetWinStaForCbAccess();
609  if (!pWinStaObj)
610  goto cleanup;
611 
612  if (pWinStaObj->spwndClipOpen)
613  hWnd = pWinStaObj->spwndClipOpen->head.h;
614 
615  ObDereferenceObject(pWinStaObj);
616 
617 cleanup:
618  UserLeave();
619 
620  return hWnd;
621 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:239
HWND hWnd
Definition: settings.c:17
PWND spwndClipOpen
Definition: winsta.h:28
THRDESKHEAD head
Definition: ntuser.h:665
#define ObDereferenceObject
Definition: obfuncs.h:203
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
#define NULL
Definition: types.h:112
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 823 of file clipboard.c.

824 {
825  INT i, iRet = 0;
826  PWINSTATION_OBJECT pWinStaObj;
827 
828  UserEnterShared();
829 
830  pWinStaObj = IntGetWinStaForCbAccess();
831  if (!pWinStaObj)
832  goto cleanup;
833 
834  if (pWinStaObj->pClipBase == NULL)
835  {
836  iRet = 0;
837  }
838  else
839  {
840  _SEH2_TRY
841  {
842  ProbeForRead(paFormatPriorityList, cFormats * sizeof(UINT), sizeof(UINT));
843 
844  iRet = -1;
845 
846  for (i = 0; i < cFormats; ++i)
847  {
848  if (IntIsFormatAvailable(pWinStaObj, paFormatPriorityList[i]))
849  {
850  iRet = paFormatPriorityList[i];
851  break;
852  }
853  }
854  }
856  {
858  }
859  _SEH2_END;
860  }
861 
862  ObDereferenceObject(pWinStaObj);
863 
864 cleanup:
865  UserLeave();
866 
867  return iRet;
868 
869 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:239
int32_t INT
Definition: typedefs.h:58
_SEH2_TRY
Definition: create.c:4226
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define ObDereferenceObject
Definition: obfuncs.h:203
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:253
_SEH2_END
Definition: create.c:4400
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
static BOOL FASTCALL IntIsFormatAvailable(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
Definition: clipboard.c:55
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
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:40
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165

Referenced by GetPriorityClipboardFormat().

◆ NtUserIsClipboardFormatAvailable()

BOOL APIENTRY NtUserIsClipboardFormatAvailable ( UINT  fmt)

Definition at line 872 of file clipboard.c.

873 {
874  BOOL bRet = FALSE;
875  PWINSTATION_OBJECT pWinStaObj;
876 
877  TRACE("NtUserIsClipboardFormatAvailable(%x)\n", fmt);
878 
879  UserEnterShared();
880 
881  pWinStaObj = IntGetWinStaForCbAccess();
882  if (!pWinStaObj)
883  goto cleanup;
884 
885  if (IntIsFormatAvailable(pWinStaObj, fmt))
886  bRet = TRUE;
887 
888  ObDereferenceObject(pWinStaObj);
889 
890 cleanup:
891  UserLeave();
892 
893  return bRet;
894 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:239
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
#define ObDereferenceObject
Definition: obfuncs.h:203
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
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 533 of file clipboard.c.

534 {
535  BOOL bRet;
536 
538  bRet = UserOpenClipboard(hWnd);
539  UserLeave();
540 
541  return bRet;
542 }
HWND hWnd
Definition: settings.c:17
BOOL NTAPI UserOpenClipboard(HWND hWnd)
Definition: clipboard.c:488
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253

Referenced by OpenClipboard().

◆ NtUserSetClipboardData()

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

Definition at line 1084 of file clipboard.c.

1085 {
1086  SETCLIPBDATA scd;
1087  HANDLE hRet;
1088 
1089  TRACE("NtUserSetClipboardData(%x %p %p)\n", fmt, hData, pUnsafeScd);
1090 
1091  _SEH2_TRY
1092  {
1093  ProbeForRead(pUnsafeScd, sizeof(*pUnsafeScd), 1);
1094  RtlCopyMemory(&scd, pUnsafeScd, sizeof(scd));
1095  }
1097  {
1099  _SEH2_YIELD(return NULL;)
1100  }
1101  _SEH2_END
1102 
1104 
1105  /* Call internal function */
1106  hRet = UserSetClipboardData(fmt, hData, &scd);
1107 
1108  UserLeave();
1109 
1110  return hRet;
1111 }
_SEH2_TRY
Definition: create.c:4226
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245
#define TRACE(s)
Definition: solgame.cpp:4
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
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:253
_SEH2_END
Definition: create.c:4400
#define NULL
Definition: types.h:112
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
Definition: dsound.c:943
HANDLE NTAPI UserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA scd)
Definition: clipboard.c:1023

Referenced by GetClipboardData(), and SetClipboardData().

◆ NtUserSetClipboardViewer()

HWND APIENTRY NtUserSetClipboardViewer ( HWND  hWndNewViewer)

Definition at line 1114 of file clipboard.c.

1115 {
1116  HWND hWndNext = NULL;
1117  PWINSTATION_OBJECT pWinStaObj;
1118  PWND pWindow;
1119 
1121 
1122  pWinStaObj = IntGetWinStaForCbAccess();
1123  if (!pWinStaObj)
1124  goto cleanup;
1125 
1126  pWindow = UserGetWindowObject(hWndNewViewer);
1127  if (!pWindow)
1128  {
1130  goto cleanup;
1131  }
1132 
1133  /* Return previous viewer. New viever window should
1134  send messages to rest of the chain */
1135  if (pWinStaObj->spwndClipViewer)
1136  hWndNext = pWinStaObj->spwndClipViewer->head.h;
1137 
1138  /* Set new viewer window */
1139  pWinStaObj->spwndClipViewer = pWindow;
1140 
1141  /* Notify viewer windows in chain */
1142  pWinStaObj->fClipboardChanged = FALSE;
1143  if (pWinStaObj->spwndClipViewer)
1144  {
1145  TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
1146  // For 32-bit applications this message is sent as a notification
1148  }
1149 
1150 cleanup:
1151  if (pWinStaObj)
1152  ObDereferenceObject(pWinStaObj);
1153 
1154  UserLeave();
1155 
1156  return hWndNext;
1157 }
INT fClipboardChanged
Definition: winsta.h:35
PWND spwndClipViewer
Definition: winsta.h:29
#define FALSE
Definition: types.h:117
THRDESKHEAD head
Definition: ntuser.h:665
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
#define ObDereferenceObject
Definition: obfuncs.h:203
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1852
Definition: ntuser.h:663
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1710
#define NULL
Definition: types.h:112
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 414 of file clipboard.c.

415 {
416  PWINSTATION_OBJECT pWinStaObj;
417 
418  pWinStaObj = IntGetWinStaForCbAccess();
419  if (!pWinStaObj)
420  return;
421 
422  if (pWindow == pWinStaObj->spwndClipOwner)
423  {
424  /* The owner window was destroyed */
425  pWinStaObj->spwndClipOwner = NULL;
426  }
427 
428  /* Check if clipboard is not locked by this window, if yes, unlock it */
429  if (pWindow == pWinStaObj->spwndClipOpen)
430  {
431  /* The window that opens the clipboard was destroyed */
432  pWinStaObj->spwndClipOpen = NULL;
433  pWinStaObj->ptiClipLock = NULL;
434  }
435  /* Remove window from window chain */
436  if (pWindow == pWinStaObj->spwndClipViewer)
437  pWinStaObj->spwndClipViewer = NULL;
438 
439  ObDereferenceObject(pWinStaObj);
440 }
PWND spwndClipOwner
Definition: winsta.h:30
PWND spwndClipViewer
Definition: winsta.h:29
PWND spwndClipOpen
Definition: winsta.h:28
PTHREADINFO ptiClipLock
Definition: winsta.h:26
#define ObDereferenceObject
Definition: obfuncs.h:203
#define NULL
Definition: types.h:112
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  if (!pWindow)
379  return;
380 
381  pWinStaObj = IntGetWinStaForCbAccess();
382  if (!pWinStaObj)
383  return;
384 
386 
387  /* If the window being destroyed is the current clipboard owner... */
388  if (pWindow == pWinStaObj->spwndClipOwner)
389  {
390  /* ... make it release the clipboard */
391  pWinStaObj->spwndClipOwner = NULL;
392  }
393 
394  if (pWinStaObj->fClipboardChanged)
395  {
396  /* Add synthesized formats - they are rendered later */
397  IntAddSynthesizedFormats(pWinStaObj);
398 
399  /* Notify viewer windows in chain */
400  pWinStaObj->fClipboardChanged = FALSE;
401  if (pWinStaObj->spwndClipViewer)
402  {
403  TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
404  // For 32-bit applications this message is sent as a notification
406  }
407  }
408 
409  ObDereferenceObject(pWinStaObj);
410 }
INT fClipboardChanged
Definition: winsta.h:35
static VOID NTAPI IntAddSynthesizedFormats(PWINSTATION_OBJECT pWinStaObj)
Definition: clipboard.c:291
#define WM_RENDERALLFORMATS
Definition: winuser.h:1850
PWND spwndClipOwner
Definition: winsta.h:30
PWND spwndClipViewer
Definition: winsta.h:29
#define FALSE
Definition: types.h:117
THRDESKHEAD head
Definition: ntuser.h:665
#define TRACE(s)
Definition: solgame.cpp:4
#define ObDereferenceObject
Definition: obfuncs.h:203
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1852
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1710
#define NULL
Definition: types.h:112
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21

Referenced by IntSendDestroyMsg().

◆ UserCloseClipboard()

BOOL NTAPI UserCloseClipboard ( VOID  )

Definition at line 545 of file clipboard.c.

546 {
547  BOOL bRet = FALSE;
548  PWINSTATION_OBJECT pWinStaObj;
549 
550  pWinStaObj = IntGetWinStaForCbAccess();
551  if (!pWinStaObj)
552  goto cleanup;
553 
554  /* Check if the clipboard has been opened */
555  if (!IntIsClipboardOpenByMe(pWinStaObj))
556  {
558  goto cleanup;
559  }
560 
561  /* Clipboard is no longer open */
562  pWinStaObj->spwndClipOpen = NULL;
563  pWinStaObj->ptiClipLock = NULL;
564  bRet = TRUE;
565 
566  if (pWinStaObj->fClipboardChanged)
567  {
568  /* Add synthesized formats - they are rendered later */
569  IntAddSynthesizedFormats(pWinStaObj);
570 
571  /* Notify viewer windows in chain */
572  pWinStaObj->fClipboardChanged = FALSE;
573  if (pWinStaObj->spwndClipViewer)
574  {
575  TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
576  // For 32-bit applications this message is sent as a notification
578  }
579  }
580 
581 cleanup:
582  if (pWinStaObj)
583  ObDereferenceObject(pWinStaObj);
584 
585  return bRet;
586 }
INT fClipboardChanged
Definition: winsta.h:35
static VOID NTAPI IntAddSynthesizedFormats(PWINSTATION_OBJECT pWinStaObj)
Definition: clipboard.c:291
#define TRUE
Definition: types.h:120
PWND spwndClipViewer
Definition: winsta.h:29
PWND spwndClipOpen
Definition: winsta.h:28
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
THRDESKHEAD head
Definition: ntuser.h:665
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:136
#define TRACE(s)
Definition: solgame.cpp:4
PTHREADINFO ptiClipLock
Definition: winsta.h:26
#define ObDereferenceObject
Definition: obfuncs.h:203
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1852
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1710
#define NULL
Definition: types.h:112
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 680 of file clipboard.c.

681 {
682  BOOL bRet = FALSE;
683  PWINSTATION_OBJECT pWinStaObj;
684 
685  pWinStaObj = IntGetWinStaForCbAccess();
686  if (!pWinStaObj)
687  return FALSE;
688 
689  /* Check if the clipboard has been opened */
690  if (!IntIsClipboardOpenByMe(pWinStaObj))
691  {
693  goto cleanup;
694  }
695 
696  UserEmptyClipboardData(pWinStaObj);
697 
698  if (pWinStaObj->spwndClipOwner)
699  {
700  TRACE("Clipboard: WM_DESTROYCLIPBOARD to %p\n", pWinStaObj->spwndClipOwner->head.h);
701  // For 32-bit applications this message is sent as a notification
703  }
704 
705  pWinStaObj->spwndClipOwner = pWinStaObj->spwndClipOpen;
706 
707  pWinStaObj->iClipSerialNumber++;
708  pWinStaObj->iClipSequenceNumber++;
709  pWinStaObj->fClipboardChanged = TRUE;
710  pWinStaObj->fInDelayedRendering = FALSE;
711 
712  bRet = TRUE;
713 
714 cleanup:
715  if (pWinStaObj)
716  ObDereferenceObject(pWinStaObj);
717 
718  return bRet;
719 }
INT fClipboardChanged
Definition: winsta.h:35
VOID NTAPI UserEmptyClipboardData(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:354
#define TRUE
Definition: types.h:120
INT fInDelayedRendering
Definition: winsta.h:36
PWND spwndClipOwner
Definition: winsta.h:30
PWND spwndClipOpen
Definition: winsta.h:28
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
INT iClipSerialNumber
Definition: winsta.h:33
THRDESKHEAD head
Definition: ntuser.h:665
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:136
#define TRACE(s)
Definition: solgame.cpp:4
#define ObDereferenceObject
Definition: obfuncs.h:203
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
#define WM_DESTROYCLIPBOARD
Definition: winuser.h:1851
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
Definition: clipboard.h:3
PCLIP pClipBase
Definition: winsta.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD cNumClipFormats
Definition: winsta.h:32
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 NULL
Definition: types.h:112
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by IntWinStaObjectDelete(), and UserEmptyClipboard().

◆ UserEnumClipboardFormats()

UINT APIENTRY UserEnumClipboardFormats ( UINT  fmt)

Definition at line 443 of file clipboard.c.

444 {
445  UINT Ret = 0;
446  PCLIP pElement;
447  PWINSTATION_OBJECT pWinStaObj;
448 
449  pWinStaObj = IntGetWinStaForCbAccess();
450  if (!pWinStaObj)
451  goto cleanup;
452 
453  /* Check if the clipboard has been opened */
454  if (!IntIsClipboardOpenByMe(pWinStaObj))
455  {
457  goto cleanup;
458  }
459 
460  if (fmt == 0)
461  {
462  /* Return first format */
463  if (pWinStaObj->pClipBase)
464  Ret = pWinStaObj->pClipBase[0].fmt;
465  }
466  else
467  {
468  /* Return next format */
469  pElement = IntGetFormatElement(pWinStaObj, fmt);
470  if (pElement != NULL)
471  {
472  ++pElement;
473  if (pElement < &pWinStaObj->pClipBase[pWinStaObj->cNumClipFormats])
474  {
475  Ret = pElement->fmt;
476  }
477  }
478  }
479 
480 cleanup:
481  if (pWinStaObj)
482  ObDereferenceObject(pWinStaObj);
483 
484  return Ret;
485 }
static PCLIP FASTCALL IntGetFormatElement(PWINSTATION_OBJECT pWinStaObj, UINT fmt)
Definition: clipboard.c:41
UINT fmt
Definition: clipboard.h:5
Definition: clipboard.h:3
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:136
#define ObDereferenceObject
Definition: obfuncs.h:203
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
#define NULL
Definition: types.h:112
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 488 of file clipboard.c.

489 {
490  PWND pWindow = NULL;
491  BOOL bRet = FALSE;
492  PWINSTATION_OBJECT pWinStaObj = NULL;
493 
494  if (hWnd)
495  {
496  pWindow = UserGetWindowObject(hWnd);
497  if (!pWindow)
498  goto cleanup;
499  }
500 
501  pWinStaObj = IntGetWinStaForCbAccess();
502  if (!pWinStaObj)
503  goto cleanup;
504 
505  /* Check if we already opened the clipboard */
506  if ((pWindow == pWinStaObj->spwndClipOpen) && IntIsClipboardOpenByMe(pWinStaObj))
507  {
508  bRet = TRUE;
509  goto cleanup;
510  }
511 
512  /* If the clipboard was already opened by somebody else, bail out */
513  if ((pWindow != pWinStaObj->spwndClipOpen) && pWinStaObj->ptiClipLock)
514  {
515  ERR("Access denied!\n");
517  goto cleanup;
518  }
519 
520  /* Open the clipboard */
521  pWinStaObj->spwndClipOpen = pWindow;
523  bRet = TRUE;
524 
525 cleanup:
526  if (pWinStaObj)
527  ObDereferenceObject(pWinStaObj);
528 
529  return bRet;
530 }
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
HWND hWnd
Definition: settings.c:17
PWND spwndClipOpen
Definition: winsta.h:28
#define FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL FASTCALL IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:136
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
PTHREADINFO ptiClipLock
Definition: winsta.h:26
#define ObDereferenceObject
Definition: obfuncs.h:203
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:663
#define NULL
Definition: types.h:112
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 1023 of file clipboard.c.

1024 {
1025  HANDLE hRet = NULL;
1026  PWINSTATION_OBJECT pWinStaObj;
1027 
1028  pWinStaObj = IntGetWinStaForCbAccess();
1029  if (!pWinStaObj)
1030  goto cleanup;
1031 
1032  if (!fmt || !pWinStaObj->ptiClipLock)
1033  {
1034  ERR("Access denied!\n");
1036  goto cleanup;
1037  }
1038 
1039  if (scd->fIncSerialNumber)
1040  pWinStaObj->iClipSerialNumber++;
1041 
1042  /* Is it a delayed rendering? */
1043  if (hData)
1044  {
1045  /* Is it a bitmap? */
1046  if (fmt == CF_BITMAP)
1047  {
1048  /* Make bitmap public */
1050  }
1051 
1052  /* Save data in the clipboard */
1053  IntAddFormatedData(pWinStaObj, fmt, hData, scd->fGlobalHandle, FALSE);
1054  TRACE("hData stored\n");
1055 
1056  /* If the serial number was increased, increase also the sequence number */
1057  if (scd->fIncSerialNumber)
1058  pWinStaObj->iClipSequenceNumber++;
1059 
1060  pWinStaObj->fClipboardChanged = TRUE;
1061 
1062  /* Note: Synthesized formats are added in NtUserCloseClipboard */
1063  }
1064  else
1065  {
1066  /* This is a delayed rendering */
1067  IntAddFormatedData(pWinStaObj, fmt, DATA_DELAYED, FALSE, FALSE);
1068  TRACE("SetClipboardData delayed format: %u\n", fmt);
1069  }
1070 
1071  /* Return hData on success */
1072  hRet = hData;
1073 
1074 cleanup:
1075  TRACE("NtUserSetClipboardData returns: %p\n", hRet);
1076 
1077  if (pWinStaObj)
1078  ObDereferenceObject(pWinStaObj);
1079 
1080  return hRet;
1081 }
INT fClipboardChanged
Definition: winsta.h:35
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1255
#define TRUE
Definition: types.h:120
#define DATA_DELAYED
Definition: clipboard.c:14
#define FALSE
Definition: types.h:117
INT iClipSerialNumber
Definition: winsta.h:33
BOOL fGlobalHandle
Definition: ntuser.h:1126
#define CF_BITMAP
Definition: constants.h:397
#define TRACE(s)
Definition: solgame.cpp:4
PTHREADINFO ptiClipLock
Definition: winsta.h:26
#define ObDereferenceObject
Definition: obfuncs.h:203
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:110
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
BOOL fIncSerialNumber
Definition: ntuser.h:1127
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
#define NULL
Definition: types.h:112
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().