ReactOS  0.4.12-dev-918-g6c6e7b8
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 79 of file clipboard.c.

80 {
81  PCLIP pElement = NULL;
82 
83  /* Use existing entry with specified format */
84  if (!bEnd)
85  pElement = IntGetFormatElement(pWinStaObj, fmt);
86 
87  /* Put new entry at the end if nothing was found */
88  if (!pElement)
89  {
90  /* Allocate bigger clipboard if needed. We could use lists but Windows uses array */
91  if (pWinStaObj->cNumClipFormats % 4 == 0)
92  {
93  PCLIP pNewClip;
94 
95  /* Allocate new clipboard */
97  (pWinStaObj->cNumClipFormats + 4) * sizeof(CLIP),
99  if (!pNewClip)
100  {
102  return NULL;
103  }
104 
105  /* Copy data */
106  memcpy(pNewClip, pWinStaObj->pClipBase, pWinStaObj->cNumClipFormats * sizeof(CLIP));
107 
108  /* Free old clipboard */
109  if (pWinStaObj->pClipBase)
111 
112  /* Update WinSta */
113  pWinStaObj->pClipBase = pNewClip;
114  }
115 
116  /* New element is at the end */
117  pElement = &pWinStaObj->pClipBase[pWinStaObj->cNumClipFormats];
118  pElement->fmt = fmt;
119  pWinStaObj->cNumClipFormats++;
120  }
121  else
122  IntFreeElementData(pElement);
123 
124  pElement->hData = hData;
125  pElement->fGlobalHandle = fGlobalHandle;
126 
127  return pElement;
128 }
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 286 of file clipboard.c.

287 {
288  BOOL bHaveText, bHaveUniText, bHaveOemText, bHaveLocale, bHaveBm, bHaveDib;
289 
290  bHaveText = IntIsFormatAvailable(pWinStaObj, CF_TEXT);
291  bHaveOemText = IntIsFormatAvailable(pWinStaObj, CF_OEMTEXT);
292  bHaveUniText = IntIsFormatAvailable(pWinStaObj, CF_UNICODETEXT);
293  bHaveLocale = IntIsFormatAvailable(pWinStaObj, CF_LOCALE);
294  bHaveBm = IntIsFormatAvailable(pWinStaObj, CF_BITMAP);
295  bHaveDib = IntIsFormatAvailable(pWinStaObj, CF_DIB);
296 
297  /* Add CF_LOCALE format if we have CF_TEXT, CF_OEMTEXT or CF_UNICODETEXT */
298  if (!bHaveLocale && (bHaveText || bHaveOemText || bHaveUniText))
299  {
300  PCLIPBOARDDATA pMemObj;
301  HANDLE hMem;
302 
304  sizeof(CLIPBOARDDATA) + sizeof(LCID));
305  if (pMemObj)
306  {
307  pMemObj->cbData = sizeof(LCID);
308  *((LCID*)pMemObj->Data) = NtCurrentTeb()->CurrentLocale;
309  IntAddFormatedData(pWinStaObj, CF_LOCALE, hMem, TRUE, TRUE);
310 
311  /* Release the extra reference (UserCreateObject added 2 references) */
312  UserDereferenceObject(pMemObj);
313  }
314  }
315 
316  /* Add CF_TEXT. Note: it is synthesized in user32.dll */
317  if (!bHaveText && (bHaveUniText || bHaveOemText))
319 
320  /* Add CF_OEMTEXT. Note: it is synthesized in user32.dll */
321  if (!bHaveOemText && (bHaveUniText || bHaveText))
323 
324  /* Add CF_UNICODETEXT. Note: it is synthesized in user32.dll */
325  if (!bHaveUniText && (bHaveText || bHaveOemText))
327 
328  /* Add CF_BITMAP. Note: it is synthesized on demand */
329  if (!bHaveBm && bHaveDib)
331 
332  /* Note: We need to render the DIB or DIBV5 format as soon as possible
333  because pallette information may change */
334  if (!bHaveDib && bHaveBm)
335  IntSynthesizeDib(pWinStaObj, IntGetFormatElement(pWinStaObj, CF_BITMAP)->hData);
336 }
#define TRUE
Definition: types.h:120
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
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:79
#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:139
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 || pElement->fmt == CF_PALETTE ||
69  pElement->fmt == CF_DSPBITMAP)
70  {
72  GreDeleteObject(pElement->hData);
73  }
74  }
75 }
BOOL fGlobalHandle
Definition: clipboard.h:7
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1250
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:683
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1153
#define IS_DATA_SYNTHESIZED(ce)
Definition: clipboard.c:18
HANDLE hData
Definition: clipboard.h:6
UINT fmt
Definition: clipboard.h:5
#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 131 of file clipboard.c.

132 {
133  /* Check if the current thread has opened the clipboard */
134  return (pWinSta->ptiClipLock &&
136 }
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 225 of file clipboard.c.

226 {
227  HDC hdc = NULL;
228  PBITMAPINFO pBmi, pConvertedBmi = NULL;
229  HBITMAP hBm = NULL;
230  PCLIPBOARDDATA pMemObj;
231  PCLIP pDibEl;
232  ULONG Offset;
233 
234  TRACE("IntSynthesizeBitmap(%p, %p)\n", pWinStaObj, pBmEl);
235 
236  pDibEl = IntGetFormatElement(pWinStaObj, CF_DIB);
237  ASSERT(pDibEl && !IS_DATA_SYNTHESIZED(pDibEl));
238  if (!pDibEl->fGlobalHandle)
239  return;
240 
242  if (!pMemObj)
243  return;
244 
245  pBmi = (BITMAPINFO*)pMemObj->Data;
246 
247  if (pMemObj->cbData < sizeof(DWORD) && pMemObj->cbData < pBmi->bmiHeader.biSize)
248  goto cleanup;
249 
250  pConvertedBmi = DIB_ConvertBitmapInfo(pBmi, DIB_RGB_COLORS);
251  if (!pConvertedBmi)
252  goto cleanup;
253 
255 
257  if (!hdc)
258  goto cleanup;
259 
261  pConvertedBmi->bmiHeader.biWidth,
262  pConvertedBmi->bmiHeader.biHeight,
263  CBM_INIT,
264  pMemObj->Data + Offset,
265  pConvertedBmi,
267  0,
268  pMemObj->cbData - Offset,
269  0);
270 
271  if (hBm)
272  {
274  pBmEl->hData = hBm;
275  }
276 
277 cleanup:
278  if (hdc)
280 
281  if (pConvertedBmi)
282  DIB_FreeConvertedBitmapInfo(pConvertedBmi, pBmi, -1);
283 }
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:1250
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1454
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 139 of file clipboard.c.

142 {
143  HDC hdc;
144  ULONG cjInfoSize, cjDataSize;
145  PCLIPBOARDDATA pClipboardData;
146  HANDLE hMem;
147  INT iResult;
148  struct
149  {
150  BITMAPINFOHEADER bmih;
151  RGBQUAD rgbColors[256];
152  } bmiBuffer;
153  PBITMAPINFO pbmi = (PBITMAPINFO)&bmiBuffer;
154 
155  /* Get the display DC */
157  if (!hdc)
158  {
159  return;
160  }
161 
162  /* Get information about the bitmap format */
163  memset(&bmiBuffer, 0, sizeof(bmiBuffer));
164  pbmi->bmiHeader.biSize = sizeof(bmiBuffer.bmih);
165  iResult = GreGetDIBitsInternal(hdc,
166  hbm,
167  0,
168  0,
169  NULL,
170  pbmi,
172  0,
173  sizeof(bmiBuffer));
174  if (iResult == 0)
175  {
176  goto cleanup;
177  }
178 
179  /* Get the size for a full BITMAPINFO */
180  cjInfoSize = DIB_BitmapInfoSize(pbmi, DIB_RGB_COLORS);
181 
182  /* Calculate the size of the clipboard data, which is a packed DIB */
183  cjDataSize = cjInfoSize + pbmi->bmiHeader.biSizeImage;
184 
185  /* Create the clipboard data */
186  pClipboardData = (PCLIPBOARDDATA)UserCreateObject(gHandleTable,
187  NULL,
188  NULL,
189  &hMem,
191  sizeof(CLIPBOARDDATA) + cjDataSize);
192  if (!pClipboardData)
193  {
194  goto cleanup;
195  }
196 
197  /* Set the data size */
198  pClipboardData->cbData = cjDataSize;
199 
200  /* Copy the BITMAPINFOHEADER */
201  memcpy(pClipboardData->Data, pbmi, sizeof(BITMAPINFOHEADER));
202 
203  /* Get the bitmap bits and the color table */
204  iResult = GreGetDIBitsInternal(hdc,
205  hbm,
206  0,
208  (LPBYTE)pClipboardData->Data + cjInfoSize,
209  (LPBITMAPINFO)pClipboardData->Data,
212  cjInfoSize);
213 
214  /* Add the clipboard data */
215  IntAddFormatedData(pWinStaObj, CF_DIB, hMem, TRUE, TRUE);
216 
217  /* Release the extra reference (UserCreateObject added 2 references) */
218  UserDereferenceObject(pClipboardData);
219 
220 cleanup:
222 }
#define abs(i)
Definition: fconv.c:206
#define TRUE
Definition: types.h:120
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1454
_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:79
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 606 of file clipboard.c.

607 {
608  BOOL bRet = FALSE;
609  PWND pWindowRemove;
610  PWINSTATION_OBJECT pWinStaObj;
611 
612  TRACE("NtUserChangeClipboardChain(%p, %p)\n", hWndRemove, hWndNewNext);
613 
615 
616  pWinStaObj = IntGetWinStaForCbAccess();
617  if (!pWinStaObj)
618  goto cleanup;
619 
620  pWindowRemove = UserGetWindowObject(hWndRemove);
621 
622  if (pWindowRemove && pWinStaObj->spwndClipViewer)
623  {
624  if (pWindowRemove == pWinStaObj->spwndClipViewer)
625  pWinStaObj->spwndClipViewer = UserGetWindowObject(hWndNewNext);
626 
627  if (pWinStaObj->spwndClipViewer)
628  bRet = (BOOL)co_IntSendMessage(pWinStaObj->spwndClipViewer->head.h, WM_CHANGECBCHAIN, (WPARAM)hWndRemove, (LPARAM)hWndNewNext);
629  }
630 
631  ObDereferenceObject(pWinStaObj);
632 
633 cleanup:
634  UserLeave();
635 
636  return bRet;
637 }
#define WM_CHANGECBCHAIN
Definition: winuser.h:1835
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:1291
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 571 of file clipboard.c.

572 {
573  BOOL bRet;
574 
576  bRet = UserCloseClipboard();
577  UserLeave();
578 
579  return bRet;
580 }
BOOL NTAPI UserCloseClipboard(VOID)
Definition: clipboard.c:527
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 1159 of file clipboard.c.

1162 {
1163  HANDLE hMem = NULL;
1164  PCLIPBOARDDATA pMemObj;
1165 
1167 
1168  /* Create Clipboard data object */
1169  pMemObj = UserCreateObject(gHandleTable, NULL, NULL, &hMem, TYPE_CLIPDATA, sizeof(CLIPBOARDDATA) + cbData);
1170  if (!pMemObj)
1171  goto cleanup;
1172 
1173  pMemObj->cbData = cbData;
1174 
1175  /* Copy data */
1176  _SEH2_TRY
1177  {
1178  ProbeForRead(pData, cbData, 1);
1179  memcpy(pMemObj->Data, pData, cbData);
1180  }
1182  {
1183  pMemObj = NULL;
1184  }
1185  _SEH2_END;
1186 
1187  /* Release the extra reference (UserCreateObject added 2 references) */
1188  UserDereferenceObject(pMemObj);
1189 
1190  /* If we failed to copy data, remove handle */
1191  if (!pMemObj)
1192  {
1194  hMem = NULL;
1195  }
1196 
1197 cleanup:
1198  UserLeave();
1199 
1200  return hMem;
1201 }
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 640 of file clipboard.c.

641 {
642  DWORD cFormats = 0;
643  PWINSTATION_OBJECT pWinStaObj;
644 
645  UserEnterShared();
646 
647  pWinStaObj = IntGetWinStaForCbAccess();
648  if (!pWinStaObj)
649  goto cleanup;
650 
651  cFormats = pWinStaObj->cNumClipFormats;
652 
653  ObDereferenceObject(pWinStaObj);
654 
655 cleanup:
656  UserLeave();
657 
658  return cFormats;
659 }
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 1204 of file clipboard.c.

1209 {
1210  PCLIPBOARDDATA pMemObj;
1212 
1213  UserEnterShared();
1214 
1215  /* Get Clipboard data object */
1217  if (!pMemObj)
1218  {
1220  goto cleanup;
1221  }
1222 
1223  /* Don't overrun */
1224  if (cbData > pMemObj->cbData)
1225  cbData = pMemObj->cbData;
1226 
1227  /* Copy data to usermode */
1228  _SEH2_TRY
1229  {
1230  if (pcbData)
1231  {
1232  ProbeForWrite(pcbData, sizeof(*pcbData), 1);
1233  *pcbData = pMemObj->cbData;
1234  }
1235 
1236  ProbeForWrite(pData, cbData, 1);
1237  memcpy(pData, pMemObj->Data, cbData);
1238  }
1240  {
1242  }
1243  _SEH2_END;
1244 
1245 cleanup:
1246  UserLeave();
1247 
1248  return Status;
1249 }
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:2725
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 704 of file clipboard.c.

705 {
706  BOOL bRet;
707 
708  TRACE("NtUserEmptyClipboard()\n");
709 
711  bRet = UserEmptyClipboard();
712  UserLeave();
713 
714  return bRet;
715 }
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:662
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255

Referenced by EmptyClipboard().

◆ NtUserGetClipboardData()

HANDLE APIENTRY NtUserGetClipboardData ( UINT  fmt,
PGETCLIPBDATA  pgcd 
)

Definition at line 879 of file clipboard.c.

880 {
881  HANDLE hRet = NULL;
882  PCLIP pElement;
883  PWINSTATION_OBJECT pWinStaObj;
884  UINT uSourceFmt = fmt;
885 
886  TRACE("NtUserGetClipboardData(%x, %p)\n", fmt, pgcd);
887 
888  UserEnterShared();
889 
890  pWinStaObj = IntGetWinStaForCbAccess();
891  if (!pWinStaObj)
892  goto cleanup;
893 
894  /* Check if the clipboard has been opened */
895  if (!IntIsClipboardOpenByMe(pWinStaObj))
896  {
898  goto cleanup;
899  }
900 
901  pElement = IntGetFormatElement(pWinStaObj, fmt);
902  if (!pElement)
903  goto cleanup;
904 
905  if (IS_DATA_SYNTHESIZED(pElement))
906  {
907  /* Note: Data is synthesized in usermode */
908  /* TODO: Add more formats */
909  switch (fmt)
910  {
911  case CF_UNICODETEXT:
912  case CF_TEXT:
913  case CF_OEMTEXT:
914  uSourceFmt = CF_UNICODETEXT;
915  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
916  if (IS_DATA_SYNTHESIZED(pElement))
917  {
918  uSourceFmt = CF_TEXT;
919  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
920  }
921  if (IS_DATA_SYNTHESIZED(pElement))
922  {
923  uSourceFmt = CF_OEMTEXT;
924  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
925  }
926  break;
927 
928  case CF_BITMAP:
929  IntSynthesizeBitmap(pWinStaObj, pElement);
930  break;
931 
932  default:
933  ASSERT(FALSE);
934  }
935  }
936 
937  if (pElement && IS_DATA_DELAYED(pElement) && pWinStaObj->spwndClipOwner)
938  {
939  /* Send WM_RENDERFORMAT message */
940  pWinStaObj->fInDelayedRendering = TRUE;
941  co_IntSendMessage(pWinStaObj->spwndClipOwner->head.h, WM_RENDERFORMAT, (WPARAM)uSourceFmt, 0);
942  pWinStaObj->fInDelayedRendering = FALSE;
943 
944  /* Data should be in clipboard now */
945  pElement = IntGetFormatElement(pWinStaObj, uSourceFmt);
946  }
947 
948  if (!pElement || IS_DATA_DELAYED(pElement))
949  goto cleanup;
950 
951  _SEH2_TRY
952  {
953  ProbeForWrite(pgcd, sizeof(*pgcd), 1);
954  pgcd->uFmtRet = pElement->fmt;
955  pgcd->fGlobalHandle = pElement->fGlobalHandle;
956 
957  /* Text and bitmap needs more data */
958  if (fmt == CF_TEXT)
959  {
960  PCLIP pLocaleEl;
961 
962  pLocaleEl = IntGetFormatElement(pWinStaObj, CF_LOCALE);
963  if (pLocaleEl && !IS_DATA_DELAYED(pLocaleEl))
964  pgcd->hLocale = pLocaleEl->hData;
965  }
966  else if (fmt == CF_BITMAP)
967  {
968  PCLIP pPaletteEl;
969 
970  pPaletteEl = IntGetFormatElement(pWinStaObj, CF_PALETTE);
971  if (pPaletteEl && !IS_DATA_DELAYED(pPaletteEl))
972  pgcd->hPalette = pPaletteEl->hData;
973  }
974 
975  hRet = pElement->hData;
976  }
978  {
980  }
981  _SEH2_END;
982 
983 cleanup:
984  if (pWinStaObj)
985  ObDereferenceObject(pWinStaObj);
986 
987  UserLeave();
988 
989  TRACE("NtUserGetClipboardData returns %p\n", hRet);
990 
991  return hRet;
992 }
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:1827
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:225
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
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:131
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:1291
#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 718 of file clipboard.c.

719 {
720  INT iRet = 0;
721 
722  UserEnterShared();
723 
724  /* If the format is built-in we fail */
725  if (fmt < 0xc000 || fmt > 0xffff)
726  {
727  /* Registetrated formats are >= 0xc000 */
728  goto cleanup;
729  }
730 
731  if (cchMaxCount < 1 || !lpszFormatName)
732  {
734  goto cleanup;
735  }
736 
737  _SEH2_TRY
738  {
739  ProbeForWrite(lpszFormatName, cchMaxCount * sizeof(WCHAR), 1);
740 
741  iRet = IntGetAtomName((RTL_ATOM)fmt,
742  lpszFormatName,
743  cchMaxCount * sizeof(WCHAR));
744  iRet /= sizeof(WCHAR);
745  }
747  {
749  }
750  _SEH2_END;
751 
752 cleanup:
753  UserLeave();
754 
755  return iRet;
756 }
#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 759 of file clipboard.c.

760 {
761  HWND hWnd = NULL;
762  PWINSTATION_OBJECT pWinStaObj;
763 
764  UserEnterShared();
765 
766  pWinStaObj = IntGetWinStaForCbAccess();
767  if (!pWinStaObj)
768  goto cleanup;
769 
770  if (pWinStaObj->spwndClipOwner)
771  hWnd = pWinStaObj->spwndClipOwner->head.h;
772 
773  ObDereferenceObject(pWinStaObj);
774 
775 cleanup:
776  UserLeave();
777 
778  return hWnd;
779 }
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 1136 of file clipboard.c.

1137 {
1138  DWORD dwRet = 0;
1139  PWINSTATION_OBJECT pWinStaObj;
1140 
1141  UserEnterShared();
1142 
1143  pWinStaObj = IntGetWinStaForCbAccess();
1144  if (!pWinStaObj)
1145  goto cleanup;
1146 
1147  /* Get windowstation sequence number */
1148  dwRet = (DWORD)pWinStaObj->iClipSequenceNumber;
1149 
1150  ObDereferenceObject(pWinStaObj);
1151 
1152 cleanup:
1153  UserLeave();
1154 
1155  return dwRet;
1156 }
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 782 of file clipboard.c.

783 {
784  HWND hWnd = NULL;
785  PWINSTATION_OBJECT pWinStaObj;
786 
787  UserEnterShared();
788 
789  pWinStaObj = IntGetWinStaForCbAccess();
790  if (!pWinStaObj)
791  goto cleanup;
792 
793  if (pWinStaObj->spwndClipViewer)
794  hWnd = pWinStaObj->spwndClipViewer->head.h;
795 
796  ObDereferenceObject(pWinStaObj);
797 
798 cleanup:
799  UserLeave();
800 
801  return hWnd;
802 }
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 583 of file clipboard.c.

584 {
585  HWND hWnd = NULL;
586  PWINSTATION_OBJECT pWinStaObj;
587 
588  UserEnterShared();
589 
590  pWinStaObj = IntGetWinStaForCbAccess();
591  if (!pWinStaObj)
592  goto cleanup;
593 
594  if (pWinStaObj->spwndClipOpen)
595  hWnd = pWinStaObj->spwndClipOpen->head.h;
596 
597  ObDereferenceObject(pWinStaObj);
598 
599 cleanup:
600  UserLeave();
601 
602  return hWnd;
603 }
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 805 of file clipboard.c.

806 {
807  INT i, iRet = 0;
808  PWINSTATION_OBJECT pWinStaObj;
809 
810  UserEnterShared();
811 
812  pWinStaObj = IntGetWinStaForCbAccess();
813  if (!pWinStaObj)
814  goto cleanup;
815 
816  if (pWinStaObj->pClipBase == NULL)
817  {
818  iRet = 0;
819  }
820  else
821  {
822  _SEH2_TRY
823  {
824  ProbeForRead(paFormatPriorityList, cFormats * sizeof(UINT), sizeof(UINT));
825 
826  iRet = -1;
827 
828  for (i = 0; i < cFormats; ++i)
829  {
830  if (IntIsFormatAvailable(pWinStaObj, paFormatPriorityList[i]))
831  {
832  iRet = paFormatPriorityList[i];
833  break;
834  }
835  }
836  }
838  {
840  }
841  _SEH2_END;
842  }
843 
844  ObDereferenceObject(pWinStaObj);
845 
846 cleanup:
847  UserLeave();
848 
849  return iRet;
850 
851 }
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 854 of file clipboard.c.

855 {
856  BOOL bRet = FALSE;
857  PWINSTATION_OBJECT pWinStaObj;
858 
859  TRACE("NtUserIsClipboardFormatAvailable(%x)\n", fmt);
860 
861  UserEnterShared();
862 
863  pWinStaObj = IntGetWinStaForCbAccess();
864  if (!pWinStaObj)
865  goto cleanup;
866 
867  if (IntIsFormatAvailable(pWinStaObj, fmt))
868  bRet = TRUE;
869 
870  ObDereferenceObject(pWinStaObj);
871 
872 cleanup:
873  UserLeave();
874 
875  return bRet;
876 }
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 515 of file clipboard.c.

516 {
517  BOOL bRet;
518 
520  bRet = UserOpenClipboard(hWnd);
521  UserLeave();
522 
523  return bRet;
524 }
HWND hWnd
Definition: settings.c:17
BOOL NTAPI UserOpenClipboard(HWND hWnd)
Definition: clipboard.c:470
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 1056 of file clipboard.c.

1057 {
1058  SETCLIPBDATA scd;
1059  HANDLE hRet;
1060 
1061  TRACE("NtUserSetClipboardData(%x %p %p)\n", fmt, hData, pUnsafeScd);
1062 
1063  _SEH2_TRY
1064  {
1065  ProbeForRead(pUnsafeScd, sizeof(*pUnsafeScd), 1);
1066  RtlCopyMemory(&scd, pUnsafeScd, sizeof(scd));
1067  }
1069  {
1071  _SEH2_YIELD(return NULL;)
1072  }
1073  _SEH2_END
1074 
1076 
1077  /* Call internal function */
1078  hRet = UserSetClipboardData(fmt, hData, &scd);
1079 
1080  UserLeave();
1081 
1082  return hRet;
1083 }
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:995

Referenced by GetClipboardData(), and SetClipboardData().

◆ NtUserSetClipboardViewer()

HWND APIENTRY NtUserSetClipboardViewer ( HWND  hWndNewViewer)

Definition at line 1086 of file clipboard.c.

1087 {
1088  HWND hWndNext = NULL;
1089  PWINSTATION_OBJECT pWinStaObj;
1090  PWND pWindow;
1091 
1093 
1094  pWinStaObj = IntGetWinStaForCbAccess();
1095  if (!pWinStaObj)
1096  goto cleanup;
1097 
1098  pWindow = UserGetWindowObject(hWndNewViewer);
1099  if (!pWindow)
1100  {
1102  goto cleanup;
1103  }
1104 
1105  /* Return previous viewer. New viever window should
1106  send messages to rest of the chain */
1107  if (pWinStaObj->spwndClipViewer)
1108  hWndNext = pWinStaObj->spwndClipViewer->head.h;
1109 
1110  /* Set new viewer window */
1111  pWinStaObj->spwndClipViewer = pWindow;
1112 
1113  /* Notify viewer windows in chain */
1114  pWinStaObj->fClipboardChanged = FALSE;
1115  if (pWinStaObj->spwndClipViewer)
1116  {
1117  TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
1118  // For 32-bit applications this message is sent as a notification
1120  }
1121 
1122 cleanup:
1123  if (pWinStaObj)
1124  ObDereferenceObject(pWinStaObj);
1125 
1126  UserLeave();
1127 
1128  return hWndNext;
1129 }
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:1830
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:1557
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 396 of file clipboard.c.

397 {
398  PWINSTATION_OBJECT pWinStaObj;
399 
400  pWinStaObj = IntGetWinStaForCbAccess();
401  if (!pWinStaObj)
402  return;
403 
404  if (pWindow == pWinStaObj->spwndClipOwner)
405  {
406  /* The owner window was destroyed */
407  pWinStaObj->spwndClipOwner = NULL;
408  }
409 
410  /* Check if clipboard is not locked by this window, if yes, unlock it */
411  if (pWindow == pWinStaObj->spwndClipOpen)
412  {
413  /* The window that opens the clipboard was destroyed */
414  pWinStaObj->spwndClipOpen = NULL;
415  pWinStaObj->ptiClipLock = NULL;
416  }
417  /* Remove window from window chain */
418  if (pWindow == pWinStaObj->spwndClipViewer)
419  pWinStaObj->spwndClipViewer = NULL;
420 
421  ObDereferenceObject(pWinStaObj);
422 }
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 359 of file clipboard.c.

360 {
361  PWINSTATION_OBJECT pWinStaObj;
362 
363  pWinStaObj = IntGetWinStaForCbAccess();
364  if (!pWinStaObj)
365  return;
366 
368 
369  /* If the window being destroyed is the current clipboard owner... */
370  if (pWindow == pWinStaObj->spwndClipOwner)
371  {
372  /* ... make it release the clipboard */
373  pWinStaObj->spwndClipOwner = NULL;
374  }
375 
376  if (pWinStaObj->fClipboardChanged)
377  {
378  /* Add synthesized formats - they are rendered later */
379  IntAddSynthesizedFormats(pWinStaObj);
380 
381  /* Notify viewer windows in chain */
382  pWinStaObj->fClipboardChanged = FALSE;
383  if (pWinStaObj->spwndClipViewer)
384  {
385  TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
386  // For 32-bit applications this message is sent as a notification
388  }
389  }
390 
391  ObDereferenceObject(pWinStaObj);
392 }
INT fClipboardChanged
Definition: winsta.h:35
static VOID NTAPI IntAddSynthesizedFormats(PWINSTATION_OBJECT pWinStaObj)
Definition: clipboard.c:286
#define WM_RENDERALLFORMATS
Definition: winuser.h:1828
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:1291
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1830
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1557
static PWINSTATION_OBJECT FASTCALL IntGetWinStaForCbAccess(VOID)
Definition: clipboard.c:21

Referenced by IntSendDestroyMsg().

◆ UserCloseClipboard()

BOOL NTAPI UserCloseClipboard ( VOID  )

Definition at line 527 of file clipboard.c.

528 {
529  BOOL bRet = FALSE;
530  PWINSTATION_OBJECT pWinStaObj;
531 
532  pWinStaObj = IntGetWinStaForCbAccess();
533  if (!pWinStaObj)
534  goto cleanup;
535 
536  /* Check if the clipboard has been opened */
537  if (!IntIsClipboardOpenByMe(pWinStaObj))
538  {
540  goto cleanup;
541  }
542 
543  /* Clipboard is no longer open */
544  pWinStaObj->spwndClipOpen = NULL;
545  pWinStaObj->ptiClipLock = NULL;
546  bRet = TRUE;
547 
548  if (pWinStaObj->fClipboardChanged)
549  {
550  /* Add synthesized formats - they are rendered later */
551  IntAddSynthesizedFormats(pWinStaObj);
552 
553  /* Notify viewer windows in chain */
554  pWinStaObj->fClipboardChanged = FALSE;
555  if (pWinStaObj->spwndClipViewer)
556  {
557  TRACE("Clipboard: sending WM_DRAWCLIPBOARD to %p\n", pWinStaObj->spwndClipViewer->head.h);
558  // For 32-bit applications this message is sent as a notification
560  }
561  }
562 
563 cleanup:
564  if (pWinStaObj)
565  ObDereferenceObject(pWinStaObj);
566 
567  return bRet;
568 }
INT fClipboardChanged
Definition: winsta.h:35
#define TRUE
Definition: types.h:120
static VOID NTAPI IntAddSynthesizedFormats(PWINSTATION_OBJECT pWinStaObj)
Definition: clipboard.c:286
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:131
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:1830
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1557
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 662 of file clipboard.c.

663 {
664  BOOL bRet = FALSE;
665  PWINSTATION_OBJECT pWinStaObj;
666 
667  pWinStaObj = IntGetWinStaForCbAccess();
668  if (!pWinStaObj)
669  return FALSE;
670 
671  /* Check if the clipboard has been opened */
672  if (!IntIsClipboardOpenByMe(pWinStaObj))
673  {
675  goto cleanup;
676  }
677 
678  UserEmptyClipboardData(pWinStaObj);
679 
680  if (pWinStaObj->spwndClipOwner)
681  {
682  TRACE("Clipboard: WM_DESTROYCLIPBOARD to %p\n", pWinStaObj->spwndClipOwner->head.h);
683  // For 32-bit applications this message is sent as a notification
685  }
686 
687  pWinStaObj->spwndClipOwner = pWinStaObj->spwndClipOpen;
688 
689  pWinStaObj->iClipSerialNumber++;
690  pWinStaObj->iClipSequenceNumber++;
691  pWinStaObj->fClipboardChanged = TRUE;
692  pWinStaObj->fInDelayedRendering = FALSE;
693 
694  bRet = TRUE;
695 
696 cleanup:
697  if (pWinStaObj)
698  ObDereferenceObject(pWinStaObj);
699 
700  return bRet;
701 }
INT fClipboardChanged
Definition: winsta.h:35
#define TRUE
Definition: types.h:120
VOID NTAPI UserEmptyClipboardData(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:339
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:131
#define TRACE(s)
Definition: solgame.cpp:4
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1291
#define ERROR_CLIPBOARD_NOT_OPEN
Definition: winerror.h:899
#define WM_DESTROYCLIPBOARD
Definition: winuser.h:1829
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 339 of file clipboard.c.

340 {
341  DWORD i;
342  PCLIP pElement;
343 
344  for (i = 0; i < pWinSta->cNumClipFormats; ++i)
345  {
346  pElement = &pWinSta->pClipBase[i];
347  IntFreeElementData(pElement);
348  }
349 
350  if (pWinSta->pClipBase)
352 
353  pWinSta->pClipBase = NULL;
354  pWinSta->cNumClipFormats = 0;
355 }
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 425 of file clipboard.c.

426 {
427  UINT Ret = 0;
428  PCLIP pElement;
429  PWINSTATION_OBJECT pWinStaObj;
430 
431  pWinStaObj = IntGetWinStaForCbAccess();
432  if (!pWinStaObj)
433  goto cleanup;
434 
435  /* Check if the clipboard has been opened */
436  if (!IntIsClipboardOpenByMe(pWinStaObj))
437  {
439  goto cleanup;
440  }
441 
442  if (fmt == 0)
443  {
444  /* Return first format */
445  if (pWinStaObj->pClipBase)
446  Ret = pWinStaObj->pClipBase[0].fmt;
447  }
448  else
449  {
450  /* Return next format */
451  pElement = IntGetFormatElement(pWinStaObj, fmt);
452  if (pElement != NULL)
453  {
454  ++pElement;
455  if (pElement < &pWinStaObj->pClipBase[pWinStaObj->cNumClipFormats])
456  {
457  Ret = pElement->fmt;
458  }
459  }
460  }
461 
462 cleanup:
463  if (pWinStaObj)
464  ObDereferenceObject(pWinStaObj);
465 
466  return Ret;
467 }
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:131
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 470 of file clipboard.c.

471 {
472  PWND pWindow = NULL;
473  BOOL bRet = FALSE;
474  PWINSTATION_OBJECT pWinStaObj = NULL;
475 
476  if (hWnd)
477  {
478  pWindow = UserGetWindowObject(hWnd);
479  if (!pWindow)
480  goto cleanup;
481  }
482 
483  pWinStaObj = IntGetWinStaForCbAccess();
484  if (!pWinStaObj)
485  goto cleanup;
486 
487  /* Check if we already opened the clipboard */
488  if ((pWindow == pWinStaObj->spwndClipOpen) && IntIsClipboardOpenByMe(pWinStaObj))
489  {
490  bRet = TRUE;
491  goto cleanup;
492  }
493 
494  /* If the clipboard was already opened by somebody else, bail out */
495  if ((pWindow != pWinStaObj->spwndClipOpen) && pWinStaObj->ptiClipLock)
496  {
497  ERR("Access denied!\n");
499  goto cleanup;
500  }
501 
502  /* Open the clipboard */
503  pWinStaObj->spwndClipOpen = pWindow;
505  bRet = TRUE;
506 
507 cleanup:
508  if (pWinStaObj)
509  ObDereferenceObject(pWinStaObj);
510 
511  return bRet;
512 }
#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:131
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 995 of file clipboard.c.

996 {
997  HANDLE hRet = NULL;
998  PWINSTATION_OBJECT pWinStaObj;
999 
1000  pWinStaObj = IntGetWinStaForCbAccess();
1001  if (!pWinStaObj)
1002  goto cleanup;
1003 
1004  if (!fmt || !pWinStaObj->ptiClipLock)
1005  {
1006  ERR("Access denied!\n");
1008  goto cleanup;
1009  }
1010 
1011  if (scd->fIncSerialNumber)
1012  pWinStaObj->iClipSerialNumber++;
1013 
1014  /* Is it a delayed rendering? */
1015  if (hData)
1016  {
1017  /* Is it a bitmap? */
1018  if (fmt == CF_BITMAP)
1019  {
1020  /* Make bitmap public */
1022  }
1023 
1024  /* Save data in the clipboard */
1025  IntAddFormatedData(pWinStaObj, fmt, hData, scd->fGlobalHandle, FALSE);
1026  TRACE("hData stored\n");
1027 
1028  /* If the serial number was increased, increase also the sequence number */
1029  if (scd->fIncSerialNumber)
1030  pWinStaObj->iClipSequenceNumber++;
1031 
1032  pWinStaObj->fClipboardChanged = TRUE;
1033 
1034  /* Note: Synthesized formats are added in NtUserCloseClipboard */
1035  }
1036  else
1037  {
1038  /* This is a delayed rendering */
1039  IntAddFormatedData(pWinStaObj, fmt, DATA_DELAYED, FALSE, FALSE);
1040  TRACE("SetClipboardData delayed format: %u\n", fmt);
1041  }
1042 
1043  /* Return hData on success */
1044  hRet = hData;
1045 
1046 cleanup:
1047  TRACE("NtUserSetClipboardData returns: %p\n", hRet);
1048 
1049  if (pWinStaObj)
1050  ObDereferenceObject(pWinStaObj);
1051 
1052  return hRet;
1053 }
INT fClipboardChanged
Definition: winsta.h:35
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1250
#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:79
#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().