Commit 85129791 authored by Alexandre Julliard's avatar Alexandre Julliard

Use MapLS/UnMapLS instead of SEGPTR_* macros.

parent b3a3a8f3
......@@ -17,7 +17,6 @@
#include "wine/obj_base.h"
#include "wine/winbase16.h"
#include "heap.h"
#include "ifs.h"
#include "debugtools.h"
......@@ -199,35 +198,36 @@ LPVOID WINAPI IMalloc16_fnHeapMinimize(IMalloc16* iface) {
return NULL;
}
static ICOM_VTABLE(IMalloc16)* msegvt16 = NULL;
/******************************************************************************
* IMalloc16_Constructor [VTABLE]
*/
LPMALLOC16
IMalloc16_Constructor() {
IMalloc16Impl* This;
HMODULE16 hcomp = GetModuleHandle16("COMPOBJ");
This = (IMalloc16Impl*)SEGPTR_NEW(IMalloc16Impl);
if (!msegvt16) {
msegvt16 = SEGPTR_NEW(ICOM_VTABLE(IMalloc16));
#define VTENT(x) msegvt16->x = (void*)GetProcAddress16(hcomp,"IMalloc16_"#x);assert(msegvt16->x)
VTENT(QueryInterface);
VTENT(AddRef);
VTENT(Release);
VTENT(Alloc);
VTENT(Realloc);
VTENT(Free);
VTENT(GetSize);
VTENT(DidAlloc);
VTENT(HeapMinimize);
IMalloc16_Constructor()
{
static ICOM_VTABLE(IMalloc16) 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
}
ICOM_VTBL(This) = (ICOM_VTABLE(IMalloc16)*)SEGPTR_GET(msegvt16);
This->ref = 1;
return (LPMALLOC16)SEGPTR_GET(This);
msegvt16 = MapLS( &vt16 );
}
ICOM_VTBL(This) = (ICOM_VTABLE(IMalloc16)*)msegvt16;
This->ref = 1;
return (LPMALLOC16)MapLS( This );
}
......
......@@ -16,11 +16,11 @@
#include "ntddk.h"
#include "winerror.h"
#include "wine/winbase16.h"
#include "wine/unicode.h"
#include "wingdi.h"
#include "wtypes.h"
#include "wine/obj_base.h"
#include "wine/obj_storage.h"
#include "heap.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(ole);
......@@ -715,7 +715,8 @@ ULONG WINAPI IStream16_fnRelease(IStream16* iface) {
This->ref--;
if (!This->ref) {
CloseHandle(This->hf);
SEGPTR_FREE(This);
UnMapLS( This->thisptr );
HeapFree( GetProcessHeap(), 0, This );
return 0;
}
return This->ref;
......@@ -1117,9 +1118,7 @@ static void _create_istream16(LPSTREAM16 *str) {
VTENT(Stat);
VTENT(Clone);
#undef VTENT
segstrvt16 = SEGPTR_NEW(ICOM_VTABLE(IStream16));
memcpy(segstrvt16,&strvt16,sizeof(strvt16));
segstrvt16 = (ICOM_VTABLE(IStream16)*)SEGPTR_GET(segstrvt16);
segstrvt16 = (ICOM_VTABLE(IStream16)*)MapLS( &strvt16 );
} else {
#define VTENT(xfn) strvt16.xfn = IStream16_fn##xfn;
VTENT(QueryInterface);
......@@ -1142,10 +1141,10 @@ static void _create_istream16(LPSTREAM16 *str) {
segstrvt16 = &strvt16;
}
}
lpst = SEGPTR_NEW(IStream16Impl);
lpst = HeapAlloc( GetProcessHeap(), 0, sizeof(*lpst) );
ICOM_VTBL(lpst) = segstrvt16;
lpst->ref = 1;
lpst->thisptr = SEGPTR_GET(lpst);
lpst->thisptr = MapLS( lpst );
*str = (void*)lpst->thisptr;
}
......@@ -1198,7 +1197,7 @@ ULONG WINAPI IStream_fnRelease(IStream* iface) {
This->ref--;
if (!This->ref) {
CloseHandle(This->hf);
SEGPTR_FREE(This);
HeapFree( GetProcessHeap(), 0, This );
return 0;
}
return This->ref;
......@@ -1251,7 +1250,8 @@ ULONG WINAPI IStorage16_fnRelease(IStorage16* iface) {
This->ref--;
if (This->ref)
return This->ref;
SEGPTR_FREE(This);
UnMapLS( This->thisptr );
HeapFree( GetProcessHeap(), 0, This );
return 0;
}
......@@ -1262,10 +1262,14 @@ HRESULT WINAPI IStorage16_fnStat(
LPSTORAGE16 iface,STATSTG16 *pstatstg, DWORD grfStatFlag
) {
ICOM_THIS(IStorage16Impl,iface);
DWORD len = WideCharToMultiByte( CP_ACP, 0, This->stde.pps_rawname, -1, NULL, 0, NULL, NULL );
LPSTR nameA = HeapAlloc( GetProcessHeap(), 0, len );
TRACE("(%p)->(%p,0x%08lx)\n",
This,pstatstg,grfStatFlag
);
pstatstg->pwcsName=(LPOLESTR16)SEGPTR_GET(SEGPTR_STRDUP_WtoA(This->stde.pps_rawname));
WideCharToMultiByte( CP_ACP, 0, This->stde.pps_rawname, -1, nameA, len, NULL, NULL );
pstatstg->pwcsName=(LPOLESTR16)MapLS( nameA );
pstatstg->type = This->stde.pps_type;
pstatstg->cbSize.s.LowPart = This->stde.pps_size;
pstatstg->mtime = This->stde.pps_ft1; /* FIXME */ /* why? */
......@@ -1520,9 +1524,7 @@ static void _create_istorage16(LPSTORAGE16 *stg) {
VTENT(SetStateBits)
VTENT(Stat)
#undef VTENT
segstvt16 = SEGPTR_NEW(ICOM_VTABLE(IStorage16));
memcpy(segstvt16,&stvt16,sizeof(stvt16));
segstvt16 = (ICOM_VTABLE(IStorage16)*)SEGPTR_GET(segstvt16);
segstvt16 = (ICOM_VTABLE(IStorage16)*)MapLS( &stvt16 );
} else {
#define VTENT(xfn) stvt16.xfn = IStorage16_fn##xfn;
VTENT(QueryInterface)
......@@ -1549,10 +1551,10 @@ static void _create_istorage16(LPSTORAGE16 *stg) {
segstvt16 = &stvt16;
}
}
lpst = SEGPTR_NEW(IStorage16Impl);
lpst = HeapAlloc( GetProcessHeap(), 0, sizeof(*lpst) );
ICOM_VTBL(lpst) = segstvt16;
lpst->ref = 1;
lpst->thisptr = SEGPTR_GET(lpst);
lpst->thisptr = MapLS(lpst);
*stg = (void*)lpst->thisptr;
}
......@@ -1648,11 +1650,14 @@ HRESULT WINAPI StgIsStorageFile16(LPCOLESTR16 fn) {
HRESULT WINAPI
StgIsStorageFile(LPCOLESTR fn)
{
LPOLESTR16 xfn = HEAP_strdupWtoA(GetProcessHeap(),0,fn);
HRESULT ret = StgIsStorageFile16(xfn);
HeapFree(GetProcessHeap(),0,xfn);
return ret;
HRESULT ret;
DWORD len = WideCharToMultiByte( CP_ACP, 0, fn, -1, NULL, 0, NULL, NULL );
LPSTR strA = HeapAlloc( GetProcessHeap(), 0, len );
WideCharToMultiByte( CP_ACP, 0, fn, -1, strA, len, NULL, NULL );
ret = StgIsStorageFile16(strA);
HeapFree( GetProcessHeap(), 0, strA );
return ret;
}
......
......@@ -49,7 +49,6 @@
#include "winuser.h"
#include "wine/winuser16.h"
#include "wine/port.h"
#include "heap.h"
#include "win.h"
#include "winerror.h"
......@@ -88,8 +87,9 @@ struct DosDeviceStruct {
OVERLAPPED read_ov, write_ov;
/* save terminal states */
DCB16 dcb;
/* pointer to unknown(==undocumented) comm structure */
LPCVOID *unknown;
/* pointer to unknown(==undocumented) comm structure */
SEGPTR seg_unknown;
BYTE unknown[40];
};
static struct DosDeviceStruct COM[MAX_PORTS];
......@@ -521,8 +521,8 @@ INT16 WINAPI OpenComm16(LPCSTR device,UINT16 cbInQueue,UINT16 cbOutQueue)
ERR("Couldn't open %s ! (%s)\n", COM[port].devicename, strerror(errno));
return IE_HARDWARE;
} else {
COM[port].unknown = SEGPTR_ALLOC(40);
memset(COM[port].unknown, 0, 40);
memset(COM[port].unknown, 0, sizeof(COM[port].unknown));
COM[port].seg_unknown = 0;
COM[port].handle = handle;
COM[port].commerror = 0;
COM[port].eventmask = 0;
......@@ -609,8 +609,7 @@ INT16 WINAPI CloseComm16(INT16 cid)
}
if (!(cid&FLAG_LPT)) {
/* COM port */
SEGPTR_FREE(COM[cid].unknown); /* [LW] */
UnMapLS( COM[cid].seg_unknown );
CloseHandle(COM[cid].read_ov.hEvent);
CloseHandle(COM[cid].write_ov.hEvent);
......@@ -843,7 +842,8 @@ SEGPTR WINAPI SetCommEventMask16(INT16 cid,UINT16 fuEvtMask)
COMM_MSRUpdate( ptr->handle, stol );
TRACE(" modem dcd construct %x\n",*stol);
return SEGPTR_GET(COM[cid].unknown);
if (!COM[cid].seg_unknown) COM[cid].seg_unknown = MapLS( COM[cid].unknown );
return COM[cid].seg_unknown;
}
/*****************************************************************************
......
......@@ -95,34 +95,30 @@ static int DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
* lParam2 is a pointer to DRVCONFIGINFO
*/
if (*lParam2) {
LPDRVCONFIGINFO16 dci16 = (LPDRVCONFIGINFO16)SEGPTR_ALLOC(sizeof(DRVCONFIGINFO16));
LPDRVCONFIGINFO16 dci16 = HeapAlloc( GetProcessHeap(), 0, sizeof(*dci16) );
LPDRVCONFIGINFO dci32 = (LPDRVCONFIGINFO)(*lParam2);
if (dci16) {
LPSTR str1, str2;
LPSTR str1;
dci16->dwDCISize = sizeof(DRVCONFIGINFO16);
if ((str1 = HEAP_strdupWtoA(GetProcessHeap(), 0, dci32->lpszDCISectionName)) != NULL &&
(str2 = SEGPTR_STRDUP(str1)) != NULL) {
dci16->lpszDCISectionName = SEGPTR_GET(str2);
if (!HeapFree(GetProcessHeap(), 0, str1))
FIXME("bad free line=%d\n", __LINE__);
if ((str1 = HEAP_strdupWtoA(GetProcessHeap(), 0, dci32->lpszDCISectionName)) != NULL)
{
dci16->lpszDCISectionName = MapLS( str1 );
} else {
return -2;
}
if ((str1 = HEAP_strdupWtoA(GetProcessHeap(), 0, dci32->lpszDCIAliasName)) != NULL &&
(str2 = SEGPTR_STRDUP(str1)) != NULL) {
dci16->lpszDCIAliasName = SEGPTR_GET(str2);
if (!HeapFree(GetProcessHeap(), 0, str1))
FIXME("bad free line=%d\n", __LINE__);
if ((str1 = HEAP_strdupWtoA(GetProcessHeap(), 0, dci32->lpszDCIAliasName)) != NULL)
{
dci16->lpszDCIAliasName = MapLS( str1 );
} else {
return -2;
}
} else {
return -2;
}
*lParam2 = (LPARAM)SEGPTR_GET(dci16);
*lParam2 = MapLS( dci16 );
ret = 1;
} else {
ret = 0;
......@@ -168,13 +164,12 @@ static int DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2)
/* lParam1 is a handle to a window (or not used), lParam2 is a pointer to DRVCONFIGINFO, lParam2 */
if (lParam2) {
LPDRVCONFIGINFO16 dci16 = MapSL(lParam2);
if (!SEGPTR_FREE(MapSL(dci16->lpszDCISectionName)))
FIXME("bad free line=%d\n", __LINE__);
if (!SEGPTR_FREE(MapSL(dci16->lpszDCIAliasName)))
FIXME("bad free line=%d\n", __LINE__);
if (!SEGPTR_FREE(dci16))
FIXME("bad free line=%d\n", __LINE__);
HeapFree( GetProcessHeap(), 0, MapSL(dci16->lpszDCISectionName) );
HeapFree( GetProcessHeap(), 0, MapSL(dci16->lpszDCIAliasName) );
HeapFree( GetProcessHeap(), 0, dci16 );
UnMapLS( lParam2 );
UnMapLS( dci16->lpszDCISectionName );
UnMapLS( dci16->lpszDCIAliasName );
}
ret = 0;
break;
......
......@@ -338,28 +338,15 @@ static LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc,
static LRESULT MMIO_Map32To16(DWORD wMsg, LPARAM* lp1, LPARAM* lp2)
{
switch (wMsg) {
case MMIOM_OPEN:
{
char *lp = SEGPTR_STRDUP( (LPSTR)*lp1 );
if (!lp) return MMSYSERR_NOMEM;
*lp1 = SEGPTR_GET(lp);
}
break;
case MMIOM_CLOSE:
case MMIOM_SEEK:
/* nothing to do */
break;
case MMIOM_OPEN:
case MMIOM_READ:
case MMIOM_WRITE:
case MMIOM_WRITEFLUSH:
{
void* lp = SEGPTR_ALLOC(*lp2);
if (!lp) return MMSYSERR_NOMEM;
if (wMsg != MMIOM_READ)
memcpy(lp, (void*)*lp1, *lp2);
*lp1 = SEGPTR_GET(lp);
}
*lp1 = MapLS( (void *)*lp1 );
break;
default:
TRACE("Not a mappable message (%ld)\n", wMsg);
......@@ -374,23 +361,15 @@ static LRESULT MMIO_UnMap32To16(DWORD wMsg, LPARAM lParam1, LPARAM lParam2,
LPARAM lp1, LPARAM lp2)
{
switch (wMsg) {
case MMIOM_OPEN:
if (!SEGPTR_FREE((void*)lp1)) {
FIXME("bad free line=%d\n", __LINE__);
}
break;
case MMIOM_CLOSE:
case MMIOM_SEEK:
/* nothing to do */
break;
case MMIOM_OPEN:
case MMIOM_READ:
memcpy((void*)lParam1, MapSL(lp1), lp2);
/* fall through */
case MMIOM_WRITE:
case MMIOM_WRITEFLUSH:
if (!SEGPTR_FREE(MapSL(lp1))) {
FIXME("bad free line=%d\n", __LINE__);
}
UnMapLS( lp1 );
break;
default:
TRACE("Not a mappable message (%ld)\n", wMsg);
......@@ -399,47 +378,12 @@ static LRESULT MMIO_UnMap32To16(DWORD wMsg, LPARAM lParam1, LPARAM lParam2,
}
/****************************************************************
* MMIO_GenerateInfoForIOProc [INTERNAL]
*/
static SEGPTR MMIO_GenerateInfoForIOProc(const WINE_MMIO* wm)
{
LPMMIOINFO16 mmioInfo16 = SEGPTR_ALLOC(sizeof(MMIOINFO16));
memset(mmioInfo16, 0, sizeof(MMIOINFO16));
mmioInfo16->lDiskOffset = wm->info.lDiskOffset;
mmioInfo16->adwInfo[0] = wm->info.adwInfo[0];
mmioInfo16->adwInfo[1] = wm->info.adwInfo[1];
mmioInfo16->adwInfo[2] = wm->info.adwInfo[2];
mmioInfo16->adwInfo[3] = wm->info.adwInfo[3];
return SEGPTR_GET(mmioInfo16);
}
/****************************************************************
* MMIO_UpdateInfoForIOProc [INTERNAL]
*/
static LRESULT MMIO_UpdateInfoForIOProc(WINE_MMIO* wm, SEGPTR segmmioInfo16)
{
MMIOINFO16* mmioInfo16 = MapSL(segmmioInfo16);
wm->info.lDiskOffset = mmioInfo16->lDiskOffset;
wm->info.adwInfo[0] = mmioInfo16->adwInfo[0];
wm->info.adwInfo[1] = mmioInfo16->adwInfo[1];
wm->info.adwInfo[2] = mmioInfo16->adwInfo[2];
wm->info.adwInfo[3] = mmioInfo16->adwInfo[3];
if (!SEGPTR_FREE(mmioInfo16)) FIXME("bad free\n");
return MMSYSERR_NOERROR;
}
/****************************************************************
* MMIO_SendMessage [INTERNAL]
*/
static LRESULT MMIO_SendMessage(LPWINE_MMIO wm, DWORD wMsg, LPARAM lParam1,
LPARAM lParam2, enum mmioProcType type)
{
MMIOINFO16 mmioInfo16;
LRESULT result;
SEGPTR segmmioInfo16;
LPARAM lp1 = lParam1, lp2 = lParam2;
......@@ -451,7 +395,12 @@ static LRESULT MMIO_SendMessage(LPWINE_MMIO wm, DWORD wMsg, LPARAM lParam1,
switch (wm->ioProc->type) {
case MMIO_PROC_16:
segmmioInfo16 = MMIO_GenerateInfoForIOProc(wm);
memset( &mmioInfo16, 0, sizeof(MMIOINFO16));
mmioInfo16.lDiskOffset = wm->info.lDiskOffset;
mmioInfo16.adwInfo[0] = wm->info.adwInfo[0];
mmioInfo16.adwInfo[1] = wm->info.adwInfo[1];
mmioInfo16.adwInfo[2] = wm->info.adwInfo[2];
mmioInfo16.adwInfo[3] = wm->info.adwInfo[3];
if (wm->ioProc->type != type) {
/* map (lParam1, lParam2) into (lp1, lp2) 32=>16 */
if ((result = MMIO_Map32To16(wMsg, &lp1, &lp2)) != MMSYSERR_NOERROR)
......@@ -460,13 +409,17 @@ static LRESULT MMIO_SendMessage(LPWINE_MMIO wm, DWORD wMsg, LPARAM lParam1,
/* FIXME: is wm->info.pIOProc a segmented or a linear address ?
* sounds to me it's a segmented one, should use a thunk somewhere
*/
result = ((LPMMIOPROC16)wm->info.pIOProc)((LPSTR)segmmioInfo16,
wMsg, lp1, lp2);
segmmioInfo16 = MapLS( &mmioInfo16 );
result = ((LPMMIOPROC16)wm->info.pIOProc)((LPSTR)segmmioInfo16, wMsg, lp1, lp2);
UnMapLS( segmmioInfo16 );
if (wm->ioProc->type != type) {
MMIO_UnMap32To16(wMsg, lParam1, lParam2, lp1, lp2);
}
MMIO_UpdateInfoForIOProc(wm, segmmioInfo16);
wm->info.lDiskOffset = mmioInfo16.lDiskOffset;
wm->info.adwInfo[0] = mmioInfo16.adwInfo[0];
wm->info.adwInfo[1] = mmioInfo16.adwInfo[1];
wm->info.adwInfo[2] = mmioInfo16.adwInfo[2];
wm->info.adwInfo[3] = mmioInfo16.adwInfo[3];
break;
case MMIO_PROC_32A:
case MMIO_PROC_32W:
......
......@@ -4864,12 +4864,12 @@ DWORD WINAPI waveInMessage16(HWAVEIN16 hWaveIn, UINT16 uMessage,
*/
HINSTANCE16 WINAPI mmTaskCreate16(SEGPTR spProc, HINSTANCE16 *lphMmTask, DWORD dwPmt)
{
DWORD *pShowCmd;
LPSTR cmdline;
LOADPARAMS16* lp;
HINSTANCE16 ret;
HINSTANCE16 handle;
char cmdline[16];
DWORD showCmd = 0x40002;
LOADPARAMS16 lp;
TRACE("(%08lx, %p, %08lx);\n", spProc, lphMmTask, dwPmt);
/* This to work requires NE modules to be started with a binary command line
* which is not currently the case. A patch exists but has never been committed.
......@@ -4880,25 +4880,20 @@ HINSTANCE16 WINAPI mmTaskCreate16(SEGPTR spProc, HINSTANCE16 *lphMmTask, DWORD d
*/
FIXME("This is currently broken. It will fail\n");
cmdline = SEGPTR_ALLOC(0x0d);
cmdline[0] = 0x0d;
*(LPDWORD)(cmdline + 1) = (DWORD)spProc;
*(LPDWORD)(cmdline + 5) = dwPmt;
*(LPDWORD)(cmdline + 9) = 0;
pShowCmd = SEGPTR_ALLOC(sizeof(DWORD));
*pShowCmd = 0x40002;
lp = (LOADPARAMS16*)HeapAlloc(GetProcessHeap(), 0, sizeof(LOADPARAMS16));
lp->hEnvironment = 0;
lp->cmdLine = SEGPTR_GET(cmdline);
lp->showCmd = SEGPTR_GET(pShowCmd);
lp->reserved = 0;
lp.hEnvironment = 0;
lp.cmdLine = MapLS(cmdline);
lp.showCmd = MapLS(&showCmd);
lp.reserved = 0;
#ifndef USE_MM_TSK_WINE
handle = LoadModule16("c:\\windows\\system\\mmtask.tsk", lp);
handle = LoadModule16("c:\\windows\\system\\mmtask.tsk", &lp);
#else
handle = LoadModule16("mmtask.tsk", lp);
handle = LoadModule16("mmtask.tsk", &lp);
#endif
if (handle < 32) {
ret = (handle) ? 1 : 2;
......@@ -4909,10 +4904,8 @@ HINSTANCE16 WINAPI mmTaskCreate16(SEGPTR spProc, HINSTANCE16 *lphMmTask, DWORD d
if (lphMmTask)
*lphMmTask = handle;
HeapFree(GetProcessHeap(), 0, lp);
SEGPTR_FREE(pShowCmd);
SEGPTR_FREE(cmdline);
UnMapLS( lp.cmdLine );
UnMapLS( lp.showCmd );
TRACE("=> 0x%04x/%d\n", handle, ret);
return ret;
}
......
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