Skip to content

Commit de6c514

Browse files
authored
[WIN32SS] Fix CF_DIB format not being saved to clipboard on Print Screen key (reactos#3265)
Use pool to allocate (potentially huge) clipboard data buffers. CORE-17318
1 parent cc0e2a3 commit de6c514

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

win32ss/user/ntuser/object.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,45 @@ static PVOID AllocSysObject(
207207
return Object;
208208
}
209209

210+
_Success_(return!=NULL)
211+
static PVOID AllocSysObjectCB(
212+
_In_ PDESKTOP pDesk,
213+
_In_ PTHREADINFO pti,
214+
_In_ SIZE_T Size,
215+
_Out_ PVOID* ObjectOwner)
216+
{
217+
PVOID Object;
218+
219+
UNREFERENCED_PARAMETER(pDesk);
220+
UNREFERENCED_PARAMETER(pti);
221+
ASSERT(Size > sizeof(HEAD));
222+
223+
/* Allocate the clipboard data */
224+
// FIXME: This allocation should be done on the current session pool;
225+
// however ReactOS' MM doesn't support session pool yet.
226+
Object = ExAllocatePoolZero(/* SESSION_POOL_MASK | */ PagedPool, Size, USERTAG_CLIPBOARD);
227+
if (!Object)
228+
{
229+
ERR("ExAllocatePoolZero failed. No object created.\n");
230+
return NULL;
231+
}
232+
233+
*ObjectOwner = NULL;
234+
return Object;
235+
}
236+
210237
static void FreeSysObject(
211238
_In_ PVOID Object)
212239
{
213240
UserHeapFree(Object);
214241
}
215242

243+
static void FreeSysObjectCB(
244+
_In_ PVOID Object)
245+
{
246+
ExFreePoolWithTag(Object, USERTAG_CLIPBOARD);
247+
}
248+
216249
static const struct
217250
{
218251
PVOID (*ObjectAlloc)(PDESKTOP, PTHREADINFO, SIZE_T, PVOID*);
@@ -226,7 +259,7 @@ static const struct
226259
{ AllocProcMarkObject, IntDestroyCurIconObject, FreeCurIconObject }, /* TYPE_CURSOR */
227260
{ AllocSysObject, /*UserSetWindowPosCleanup*/NULL, FreeSysObject }, /* TYPE_SETWINDOWPOS */
228261
{ AllocDeskThreadObject, IntRemoveHook, FreeDeskThreadObject }, /* TYPE_HOOK */
229-
{ AllocSysObject, /*UserClipDataCleanup*/NULL,FreeSysObject }, /* TYPE_CLIPDATA */
262+
{ AllocSysObjectCB, /*UserClipDataCleanup*/NULL,FreeSysObjectCB }, /* TYPE_CLIPDATA */
230263
{ AllocDeskProcObject, DestroyCallProc, FreeDeskProcObject }, /* TYPE_CALLPROC */
231264
{ AllocProcMarkObject, UserDestroyAccelTable, FreeProcMarkObject }, /* TYPE_ACCELTABLE */
232265
{ NULL, NULL, NULL }, /* TYPE_DDEACCESS */

0 commit comments

Comments
 (0)