Commit c1f9d386 authored by Juergen Schmied's avatar Juergen Schmied Committed by Alexandre Julliard

- Implemented IMallocSpy hooks in IMalloc.

- Moved memory related functions into ifs.c. - Implemented stubs for the MallocSpy.
parent 22780c81
......@@ -126,9 +126,6 @@ HINSTANCE16 COMPOBJ_hInstance = 0;
HINSTANCE COMPOBJ_hInstance32 = 0;
static int COMPOBJ_Attach = 0;
LPMALLOC16 currentMalloc16=NULL;
LPMALLOC currentMalloc32=NULL;
HTASK16 hETask = 0;
WORD Table_ETask[62];
......@@ -212,6 +209,35 @@ DWORD WINAPI CoBuildVersion(void)
return (rmm<<16)+rup;
}
LPMALLOC16 currentMalloc16=NULL;
/***********************************************************************
* CoGetMalloc [COMPOBJ.4]
* RETURNS
* The current win16 IMalloc
*/
HRESULT WINAPI CoGetMalloc16(
DWORD dwMemContext, /* [in] unknown */
LPMALLOC16 * lpMalloc /* [out] current win16 malloc interface */
) {
if(!currentMalloc16)
currentMalloc16 = IMalloc16_Constructor();
*lpMalloc = currentMalloc16;
return S_OK;
}
/***********************************************************************
* CoCreateStandardMalloc [COMPOBJ.71]
*/
HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext,
LPMALLOC16 *lpMalloc)
{
/* FIXME: docu says we shouldn't return the same allocator as in
* CoGetMalloc16 */
*lpMalloc = IMalloc16_Constructor();
return S_OK;
}
/******************************************************************************
* CoInitialize [COMPOBJ.2]
* Set the win16 IMalloc used for memory management
......@@ -367,49 +393,6 @@ void WINAPI CoUninitialize(void)
}
}
/***********************************************************************
* CoGetMalloc [COMPOBJ.4]
* RETURNS
* The current win16 IMalloc
*/
HRESULT WINAPI CoGetMalloc16(
DWORD dwMemContext, /* [in] unknown */
LPMALLOC16 * lpMalloc /* [out] current win16 malloc interface */
) {
if(!currentMalloc16)
currentMalloc16 = IMalloc16_Constructor();
*lpMalloc = currentMalloc16;
return S_OK;
}
/******************************************************************************
* CoGetMalloc [OLE32.20]
*
* RETURNS
* The current win32 IMalloc
*/
HRESULT WINAPI CoGetMalloc(
DWORD dwMemContext, /* [in] unknown */
LPMALLOC *lpMalloc /* [out] current win32 malloc interface */
) {
if(!currentMalloc32)
currentMalloc32 = IMalloc_Constructor();
*lpMalloc = currentMalloc32;
return S_OK;
}
/***********************************************************************
* CoCreateStandardMalloc [COMPOBJ.71]
*/
HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext,
LPMALLOC16 *lpMalloc)
{
/* FIXME: docu says we shouldn't return the same allocator as in
* CoGetMalloc16 */
*lpMalloc = IMalloc16_Constructor();
return S_OK;
}
/******************************************************************************
* CoDisconnectObject [COMPOBJ.15]
* CoDisconnectObject [OLE32.8]
......@@ -1782,55 +1765,6 @@ HRESULT WINAPI CoFileTimeNow( FILETIME *lpFileTime ) /* [out] the current time *
}
/***********************************************************************
* CoTaskMemAlloc (OLE32.43)
* RETURNS
* pointer to newly allocated block
*/
LPVOID WINAPI CoTaskMemAlloc(
ULONG size /* [in] size of memoryblock to be allocated */
) {
LPMALLOC lpmalloc;
HRESULT ret = CoGetMalloc(0,&lpmalloc);
if (FAILED(ret))
return NULL;
return IMalloc_Alloc(lpmalloc,size);
}
/***********************************************************************
* CoTaskMemFree (OLE32.44)
*/
VOID WINAPI CoTaskMemFree(
LPVOID ptr /* [in] pointer to be freed */
) {
LPMALLOC lpmalloc;
HRESULT ret = CoGetMalloc(0,&lpmalloc);
if (FAILED(ret))
return;
IMalloc_Free(lpmalloc, ptr);
}
/***********************************************************************
* CoTaskMemRealloc (OLE32.45)
* RETURNS
* pointer to newly allocated block
*/
LPVOID WINAPI CoTaskMemRealloc(
LPVOID pvOld,
ULONG size) /* [in] size of memoryblock to be allocated */
{
LPMALLOC lpmalloc;
HRESULT ret = CoGetMalloc(0,&lpmalloc);
if (FAILED(ret))
return NULL;
return IMalloc_Realloc(lpmalloc, pvOld, size);
}
/***********************************************************************
* CoLoadLibrary (OLE32.30)
*/
HINSTANCE WINAPI CoLoadLibrary(LPOLESTR lpszLibName, BOOL bAutoFree)
......
......@@ -56,6 +56,5 @@ ICOM_DEFINE(IMalloc16,IUnknown)
/**********************************************************************/
extern LPMALLOC16 IMalloc16_Constructor();
extern LPMALLOC IMalloc_Constructor();
#endif /* __WINE_OLE_IFS_H */
......@@ -36,11 +36,11 @@ init OLE32_DllEntryPoint
34 stdcall CoMarshalInterface(ptr ptr ptr long ptr long) CoMarshalInterface
35 stub CoQueryReleaseObject
36 stdcall CoRegisterClassObject(ptr ptr long long ptr) CoRegisterClassObject
37 stub CoRegisterMallocSpy # stdcall (ptr) return 0,ERR_NOTIMPLEMENTED
37 stdcall CoRegisterMallocSpy (ptr) CoRegisterMallocSpy
38 stdcall CoRegisterMessageFilter(ptr ptr) CoRegisterMessageFilter
39 stub CoReleaseMarshalData # stdcall (ptr) return 0,ERR_NOTIMPLEMENTED
40 stdcall CoRevokeClassObject(long) CoRevokeClassObject
41 stub CoRevokeMallocSpy # stdcall () return 0,ERR_NOTIMPLEMENTED
41 stdcall CoRevokeMallocSpy() CoRevokeMallocSpy
42 stdcall CoSetState(ptr) CoSetState
43 stdcall CoTaskMemAlloc(long) CoTaskMemAlloc
44 stdcall CoTaskMemFree(ptr) CoTaskMemFree
......
......@@ -22,6 +22,7 @@
#include "winerror.h"
#include "ole32_main.h"
#include "wine/debug.h"
#include "wine/obj_misc.h" /* FIXME: CoRegisterMallocSpy */
WINE_DEFAULT_DEBUG_CHANNEL(ole);
......@@ -39,9 +40,11 @@ BOOL WINAPI OLE32_DllEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImp
case DLL_PROCESS_ATTACH:
OLE32_hInstance = hinstDLL;
COMPOBJ_InitProcess();
if (TRACE_ON(ole)) CoRegisterMallocSpy((LPVOID)-1);
break;
case DLL_PROCESS_DETACH:
if (TRACE_ON(ole)) CoRevokeMallocSpy();
COMPOBJ_UninitProcess();
OLE32_hInstance = 0;
break;
......
......@@ -24,6 +24,8 @@
#ifndef __WINE_WINE_OBJ_MISC_H
#define __WINE_WINE_OBJ_MISC_H
#include "wine/obj_base.h"
#ifdef __cplusplus
extern "C" {
#endif /* defined(__cplusplus) */
......@@ -103,7 +105,7 @@ ICOM_DEFINE(IEnumUnknown,IUnknown)
#define ICOM_INTERFACE IMallocSpy
#define IMallocSpy_METHODS \
ICOM_METHOD1 (ULONG,PreAlloc, ULONG,cbRequest) \
ICOM_VMETHOD1( PostAlloc, void*,pActual) \
ICOM_METHOD1 (PVOID,PostAlloc, void*,pActual) \
ICOM_METHOD2 (PVOID,PreFree, void*,pRequest, BOOL,fSpyed) \
ICOM_VMETHOD1( PostFree, BOOL,fSpyed) \
ICOM_METHOD4 (ULONG,PreRealloc, void*,pRequest, ULONG,cbRequest, void**,ppNewRequest, BOOL,fSpyed) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment