https://git.reactos.org/?p=reactos.git;a=commitdiff;h=de6c514c3e6e9fa047be3…
commit de6c514c3e6e9fa047be391410f7834d94ccd488
Author: Doug Lyons <douglyons(a)douglyons.com>
AuthorDate: Thu May 5 10:54:15 2022 -0500
Commit: GitHub <noreply(a)github.com>
CommitDate: Thu May 5 17:54:15 2022 +0200
[WIN32SS] Fix CF_DIB format not being saved to clipboard on Print Screen key (#3265)
Use pool to allocate (potentially huge) clipboard data buffers.
CORE-17318
---
win32ss/user/ntuser/object.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/win32ss/user/ntuser/object.c b/win32ss/user/ntuser/object.c
index 26c407f0b56..d0b4b4cf364 100644
--- a/win32ss/user/ntuser/object.c
+++ b/win32ss/user/ntuser/object.c
@@ -207,12 +207,45 @@ static PVOID AllocSysObject(
return Object;
}
+_Success_(return!=NULL)
+static PVOID AllocSysObjectCB(
+ _In_ PDESKTOP pDesk,
+ _In_ PTHREADINFO pti,
+ _In_ SIZE_T Size,
+ _Out_ PVOID* ObjectOwner)
+{
+ PVOID Object;
+
+ UNREFERENCED_PARAMETER(pDesk);
+ UNREFERENCED_PARAMETER(pti);
+ ASSERT(Size > sizeof(HEAD));
+
+ /* Allocate the clipboard data */
+ // FIXME: This allocation should be done on the current session pool;
+ // however ReactOS' MM doesn't support session pool yet.
+ Object = ExAllocatePoolZero(/* SESSION_POOL_MASK | */ PagedPool, Size,
USERTAG_CLIPBOARD);
+ if (!Object)
+ {
+ ERR("ExAllocatePoolZero failed. No object created.\n");
+ return NULL;
+ }
+
+ *ObjectOwner = NULL;
+ return Object;
+}
+
static void FreeSysObject(
_In_ PVOID Object)
{
UserHeapFree(Object);
}
+static void FreeSysObjectCB(
+ _In_ PVOID Object)
+{
+ ExFreePoolWithTag(Object, USERTAG_CLIPBOARD);
+}
+
static const struct
{
PVOID (*ObjectAlloc)(PDESKTOP, PTHREADINFO, SIZE_T, PVOID*);
@@ -226,7 +259,7 @@ static const struct
{ AllocProcMarkObject, IntDestroyCurIconObject, FreeCurIconObject }, /*
TYPE_CURSOR */
{ AllocSysObject, /*UserSetWindowPosCleanup*/NULL, FreeSysObject }, /*
TYPE_SETWINDOWPOS */
{ AllocDeskThreadObject, IntRemoveHook, FreeDeskThreadObject }, /*
TYPE_HOOK */
- { AllocSysObject, /*UserClipDataCleanup*/NULL,FreeSysObject }, /*
TYPE_CLIPDATA */
+ { AllocSysObjectCB, /*UserClipDataCleanup*/NULL,FreeSysObjectCB }, /*
TYPE_CLIPDATA */
{ AllocDeskProcObject, DestroyCallProc, FreeDeskProcObject }, /*
TYPE_CALLPROC */
{ AllocProcMarkObject, UserDestroyAccelTable, FreeProcMarkObject }, /*
TYPE_ACCELTABLE */
{ NULL, NULL, NULL }, /*
TYPE_DDEACCESS */