/****************************************************************************** * IMalloc16_Constructor [VTABLE] */ static LPMALLOC16 IMalloc16_Constructor(void) { static IMalloc16Vtbl vt16; static SEGPTR msegvt16; IMalloc16Impl* This; HMODULE16 hcomp = GetModuleHandle16("COMPOBJ"); This = HeapAlloc( GetProcessHeap(), 0, sizeof(IMalloc16Impl) ); if (!msegvt16) { #define VTENT(x) vt16.x = (void*)GetProcAddress16(hcomp,"IMalloc16_"#x);assert(vt16.x) VTENT(QueryInterface); VTENT(AddRef); VTENT(Release); VTENT(Alloc); VTENT(Realloc); VTENT(Free); VTENT(GetSize); VTENT(DidAlloc); VTENT(HeapMinimize); #undef VTENT msegvt16 = MapLS( &vt16 ); } This->IMalloc16_iface.lpVtbl = (const IMalloc16Vtbl*)msegvt16; This->ref = 1; return (LPMALLOC16)MapLS( This ); }
/****************************************************************************** * This is the constructor for the HGLOBALLockBytesImpl16 class. * * Params: * hGlobal - Handle that will support the stream. can be NULL. * fDeleteOnRelease - Flag set to TRUE if the HGLOBAL16 will be released * when the IStream object is destroyed. */ static HGLOBALLockBytesImpl16* HGLOBALLockBytesImpl16_Construct(HGLOBAL16 hGlobal, BOOL16 fDeleteOnRelease) { HGLOBALLockBytesImpl16* newLockBytes; static ILockBytes16Vtbl vt16; static SEGPTR msegvt16; HMODULE16 hcomp = GetModuleHandle16("OLE2"); TRACE("(%x,%d)\n",hGlobal,fDeleteOnRelease); newLockBytes = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALLockBytesImpl16)); if (newLockBytes == NULL) return NULL; /* * Set up the virtual function table and reference count. */ if (!msegvt16) { #define VTENT(x) vt16.x = (void*)GetProcAddress16(hcomp,"HGLOBALLockBytesImpl16_"#x);assert(vt16.x) VTENT(QueryInterface); VTENT(AddRef); VTENT(Release); VTENT(ReadAt); VTENT(WriteAt); VTENT(Flush); VTENT(SetSize); VTENT(LockRegion); VTENT(UnlockRegion); #undef VTENT msegvt16 = MapLS( &vt16 ); } newLockBytes->lpVtbl = (const ILockBytes16Vtbl*)msegvt16; newLockBytes->ref = 0; /* * Initialize the support. */ newLockBytes->supportHandle = hGlobal; newLockBytes->deleteOnRelease = fDeleteOnRelease; /* * This method will allocate a handle if one is not supplied. */ if (newLockBytes->supportHandle == 0) newLockBytes->supportHandle = GlobalAlloc16(GMEM_MOVEABLE | GMEM_NODISCARD, 0); /* * Initialize the size of the array to the size of the handle. */ newLockBytes->byteArraySize.u.HighPart = 0; newLockBytes->byteArraySize.u.LowPart = GlobalSize16( newLockBytes->supportHandle); return (HGLOBALLockBytesImpl16*)MapLS(newLockBytes); }