Huw Davies : ole32: Don' t allocate the ole clipboard object in global memory - we' re not going to directly expose it to other processes.
Alexandre Julliard
julliard at winehq.org
Mon Mar 23 12:34:56 CDT 2009
Module: wine
Branch: master
Commit: e7ffa2aeb5f633536cf4881ebbadc3da6461af98
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e7ffa2aeb5f633536cf4881ebbadc3da6461af98
Author: Huw Davies <huw at codeweavers.com>
Date: Tue Mar 17 12:20:55 2009 +0000
ole32: Don't allocate the ole clipboard object in global memory - we're not going to directly expose it to other processes.
---
dlls/ole32/clipboard.c | 77 ++++++++++--------------------------------------
1 files changed, 16 insertions(+), 61 deletions(-)
diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c
index 5bdd80a..a1fed82 100644
--- a/dlls/ole32/clipboard.c
+++ b/dlls/ole32/clipboard.c
@@ -108,16 +108,6 @@ struct OLEClipbrd
IDataObject* pIDataObjectSrc;
/*
- * The registered DataObject clipboard format
- */
- UINT cfDataObj;
-
- /*
- * The handle to ourself
- */
- HGLOBAL hSelf;
-
- /*
* Reference count of this object
*/
LONG ref;
@@ -647,68 +637,33 @@ void OLEClipbrd_UnInitialize(void)
*/
static OLEClipbrd* OLEClipbrd_Construct(void)
{
- OLEClipbrd* newObject = NULL;
- HGLOBAL hNewObject = 0;
-
- /*
- * Allocate space for the object. We use GlobalAlloc since we need
- * an HGLOBAL to expose our DataObject as a registered clipboard type.
- */
- hNewObject = GlobalAlloc( GMEM_DDESHARE|GMEM_MOVEABLE|GMEM_ZEROINIT,
- sizeof(OLEClipbrd));
- if (hNewObject==0)
- return NULL;
-
- /*
- * Lock the handle for the entire lifetime of the clipboard.
- */
- newObject = GlobalLock(hNewObject);
-
- /*
- * Initialize the virtual function table.
- */
- newObject->lpvtbl1 = &OLEClipbrd_IDataObject_VTable;
+ OLEClipbrd* This;
- /*
- * Start with one reference count. The caller of this function
- * must release the interface pointer when it is done.
- */
- newObject->ref = 1;
+ This = HeapAlloc( GetProcessHeap(), 0, sizeof(*This) );
+ if (!This) return NULL;
- newObject->hSelf = hNewObject;
+ This->lpvtbl1 = &OLEClipbrd_IDataObject_VTable;
+ This->ref = 1;
- /*
- * The Ole clipboard is a singleton - save the global handle and pointer
- */
- theOleClipboard = newObject;
+ This->hWndClipboard = NULL;
+ This->pIDataObjectSrc = NULL;
- return theOleClipboard;
+ theOleClipboard = This;
+ return This;
}
-static void OLEClipbrd_Destroy(OLEClipbrd* ptrToDestroy)
+static void OLEClipbrd_Destroy(OLEClipbrd* This)
{
- TRACE("()\n");
+ TRACE("()\n");
- if ( !ptrToDestroy )
- return;
+ if (!This) return;
- /*
- * Destroy the Ole clipboard window
- */
- if ( ptrToDestroy->hWndClipboard )
- OLEClipbrd_DestroyWindow(ptrToDestroy->hWndClipboard);
+ theOleClipboard = NULL;
- /*
- * Free the actual OLE Clipboard structure.
- */
- TRACE("() - Destroying clipboard data object.\n");
- GlobalUnlock(ptrToDestroy->hSelf);
- GlobalFree(ptrToDestroy->hSelf);
+ if ( This->hWndClipboard )
+ OLEClipbrd_DestroyWindow(This->hWndClipboard);
- /*
- * The Ole clipboard is a singleton (ptrToDestroy == theOleClipboard)
- */
- theOleClipboard = NULL;
+ HeapFree(GetProcessHeap(), 0, This);
}
More information about the wine-cvs
mailing list