Release 960717
Wed Jul 17 16:10:16 1996 Alexandre Julliard <julliard@lrc.epfl.ch>
* [configure.in]
Generate include/config.h instead of putting everything on the
command-line.
Removed -with-malloc-debug option (not useful for end users
anyway).
Added check for memmove().
* [include/wintypes.h] [*/Makefile.in]
Added definition of __WINE__ symbol when compiling Wine code
(emulator or library) as opposed to user programs.
* [debugger/editline.c] [debugger/readline/*]
Moved all the readline code into debugger/editline.c. Removed the
readline subdirectory.
* [files/profile.c]
Added PROFILE_GetWineIniInt().
* [include/stackframe.h] [loader/task.c]
The 16-bit stackframe now also exists for Winelib (even though it
only ever contains one frame).
* [loader/module.c]
Added function MODULE_CreateDummyModule() to create a dummy Win16
module for Winelib and Win32.
* [memory/ldt.c]
Make sure the ldt entry contents will be acceptable for the Linux
kernel.
* [memory/selector.c]
Fixed SetSelectorLimit() when the limit is in pages.
* [misc/port.c]
Added memmove().
* [miscemu/dpmi.c]
Clear the segment registers that contain the selector being freed
in int31/ax=0001.
Added missing break after SelectorAccessRights call.
* [win32/struct32.c]
Added conversions for MDICREATESTRUCT.
* [windows/winproc.c]
Added message conversions for WM_MDICREATE.
Tue Jul 16 19:46:24 1996 Pavel Kankovsky <KAN@frode.dcit.cz>
* [windows/class.c]
Added GetExePtr() call in CLASS_FindClassByAtom().
Mon Jul 15 17:49:38 1996 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
* [if1632/*.spec]
Some more trivial specs added.
* [if1632/gdi32.spec] [objects/font.c][windows/dialog.c]
CreateFont32* added, changed to new naming std.
* [include/windows.h] [include/mmsystem.h] [include/wintypes.h]
Some defines/types added.
* [win32/thread.c]
TlsSetValue() returns boolean.
* [win32/resource.c] [loader/pe_resource.c] [loader/resource.c]
[controls/menu.c] [objects/bitmap.c]
Cleanup of the resource functions, mostly changes to new naming
standard and fixing of argument types so that they agree with the
win16/win32 API.
Thu Jul 11 15:00:00 1996 Alex Korobka <alex@phm30.pharm.sunysb.edu>
* [windows/winpos.c]
ShowWindow() fixes.
* [windows/mdi.c]
Fix reversed LPARAM in WM_MDIACTIVATE.
* [wine.ini]
New option AllocSystemColors tells Wine how many colors to grab
from the system colormap.
* [objects/bitblt.c] [objects/dc.c]
Fixed pink garbage over Word buttons in PseudoColor. Added
optional DSTINVERT shortcut for faster text selection.
* [misc/wsprintf.c]
Skip bogus segmented pointers in wsvnprintf16().
* [objects/gdiobj.c]
Added palette handling to UnrealizeObject().
* [objects/color.c] [objects/palette.c] [windows/dce.c]
Wine gets palette manager with support for more than 20 colors.
Only PseudoColor and TrueColor visuals tested so far.
* [windows/winpos.c] [windows/win.c]
Set X size hints for WS_EX_DLGMODALFRAME windows (no resize) and
use XReconfigureWMWindows() instead of XConfigureWindow() in
managed mode.
* [memory/global.c]
Do not allocate more than 640K of DOS memory.
* [misc/main.c]
Do not allow -desktop and -managed together.
diff --git a/loader/resource.c b/loader/resource.c
index 9f0aa83..cea0057 100644
--- a/loader/resource.c
+++ b/loader/resource.c
@@ -23,6 +23,8 @@
#include "stddebug.h"
#include "debug.h"
#include "libres.h"
+#include "string32.h"
+#include "xmalloc.h"
#define PrintId(name) \
if (HIWORD((DWORD)name)) \
@@ -32,14 +34,14 @@
/**********************************************************************
- * FindResource (KERNEL.60)
+ * FindResource16 (KERNEL.60)
*/
-HRSRC FindResource( HMODULE hModule, SEGPTR name, SEGPTR type )
+HRSRC16 FindResource16( HMODULE16 hModule, SEGPTR name, SEGPTR type )
{
NE_MODULE *pModule;
hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */
- dprintf_resource(stddeb, "FindResource: module=%04x type=", hModule );
+ dprintf_resource(stddeb, "FindResource16: module=%04x type=", hModule );
PrintId( type );
if (HIWORD(name)) /* Check for '#xxx' name */
{
@@ -55,7 +57,7 @@
#ifndef WINELIB
if (pModule->flags & NE_FFLAGS_WIN32)
{
- fprintf(stderr,"Don't know how to FindResource() for Win32 module\n");
+ fprintf(stderr,"Don't know how to FindResource16() for Win32 module\n");
return 0;
}
return NE_FindResource( hModule, type, name );
@@ -66,21 +68,67 @@
/**********************************************************************
- * LoadResource (KERNEL.61)
+ * FindResource32A (KERNEL32.128)
*/
-HGLOBAL LoadResource( HMODULE hModule, HRSRC hRsrc )
+HANDLE32 FindResource32A( HINSTANCE32 hModule, LPCSTR name, LPCSTR type )
+{
+ LPWSTR xname,xtype;
+ HANDLE32 ret;
+
+ if (HIWORD((DWORD)name)) xname = STRING32_DupAnsiToUni(name);
+ else xname = (LPWSTR)name;
+ if (HIWORD((DWORD)type)) xtype = STRING32_DupAnsiToUni(type);
+ else xtype = (LPWSTR)type;
+ ret = FindResource32W(hModule,xname,xtype);
+ if (HIWORD((DWORD)name)) free(xname);
+ if (HIWORD((DWORD)type)) free(xtype);
+ return ret;
+}
+
+
+/**********************************************************************
+ * FindResource32W (KERNEL32.131)
+ */
+HRSRC32 FindResource32W( HINSTANCE32 hModule, LPCWSTR name, LPCWSTR type )
+{
+#ifndef WINELIB
+ NE_MODULE *pModule;
+
+ /* Sometimes we get passed hModule = 0x00000000. FIXME: is GetTaskDS()
+ * ok?
+ */
+ if (!hModule) hModule = GetTaskDS();
+ hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */
+ dprintf_resource(stddeb, "FindResource32W: module=%08x type=", hModule );
+ PrintId( type );
+ dprintf_resource( stddeb, " name=" );
+ PrintId( name );
+ dprintf_resource( stddeb, "\n" );
+ if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
+ if (!(pModule->flags & NE_FFLAGS_WIN32)) return 0;
+ return PE_FindResource32W(hModule,name,type);
+#else
+ return LIBRES_FindResource( hModule, name, type );
+#endif
+}
+
+
+/**********************************************************************
+ * LoadResource16 (KERNEL.61)
+ */
+HGLOBAL16 LoadResource16( HMODULE16 hModule, HRSRC16 hRsrc )
{
NE_MODULE *pModule;
hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */
- dprintf_resource(stddeb, "LoadResource: module=%04x res=%04x\n",
+ dprintf_resource(stddeb, "LoadResource16: module=%04x res=%04x\n",
hModule, hRsrc );
if (!hRsrc) return 0;
if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
#ifndef WINELIB
if (pModule->flags & NE_FFLAGS_WIN32)
{
- fprintf(stderr,"Don't know how to LoadResource() for Win32 module\n");
+ fprintf(stderr,"Don't know how to LoadResource16() for Win32 module\n");
return 0;
}
return NE_LoadResource( hModule, hRsrc );
@@ -89,15 +137,41 @@
#endif
}
+/**********************************************************************
+ * LoadResource32 (KERNEL32.370)
+ */
+HGLOBAL32 LoadResource32( HINSTANCE32 hModule, HRSRC32 hRsrc )
+{
+#ifndef WINELIB
+ NE_MODULE *pModule;
+
+ if (!hModule) hModule = GetTaskDS(); /* FIXME: see FindResource32W */
+ hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */
+ dprintf_resource(stddeb, "LoadResource32: module=%04x res=%04x\n",
+ hModule, hRsrc );
+ if (!hRsrc) return 0;
+
+ if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
+ if (!(pModule->flags & NE_FFLAGS_WIN32))
+ {
+ fprintf(stderr,"LoadResource32: tried to load a non win32 resource.\n");
+ return 0; /* FIXME? */
+ }
+ return PE_LoadResource32(hModule,hRsrc);
+#else
+ return LIBRES_LoadResource( hModule, hRsrc );
+#endif
+}
+
/**********************************************************************
* LockResource (KERNEL.62)
*/
/* 16-bit version */
-SEGPTR WIN16_LockResource( HGLOBAL handle )
+SEGPTR WIN16_LockResource16(HGLOBAL16 handle)
{
#ifndef WINELIB
- HMODULE hModule;
+ HMODULE16 hModule;
NE_MODULE *pModule;
dprintf_resource(stddeb, "LockResource: handle=%04x\n", handle );
@@ -115,11 +189,11 @@
#endif
}
-/* 32-bit version */
-LPVOID LockResource( HGLOBAL handle )
+/* WINELIB 16-bit version */
+LPVOID LockResource16( HGLOBAL16 handle )
{
#ifndef WINELIB
- HMODULE hModule;
+ HMODULE16 hModule;
NE_MODULE *pModule;
dprintf_resource(stddeb, "LockResource: handle=%04x\n", handle );
@@ -128,7 +202,7 @@
if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
if (pModule->flags & NE_FFLAGS_WIN32)
{
- fprintf(stderr,"Don't know how to LockResource() for Win32 module\n");
+ fprintf(stderr,"Don't know how to LockResource16() for Win32 module\n");
return 0;
}
return (LPSTR)PTR_SEG_TO_LIN( NE_LockResource( hModule, handle ) );
@@ -139,21 +213,30 @@
/**********************************************************************
- * FreeResource (KERNEL.63)
+ * LockResource32 (KERNEL32.384)
*/
-BOOL FreeResource( HGLOBAL handle )
+LPVOID LockResource32( HGLOBAL32 handle )
+{
+ return (LPVOID)handle;
+}
+
+
+/**********************************************************************
+ * FreeResource16 (KERNEL.63)
+ */
+BOOL16 FreeResource16( HGLOBAL16 handle )
{
#ifndef WINELIB
- HMODULE hModule;
+ HMODULE16 hModule;
NE_MODULE *pModule;
- dprintf_resource(stddeb, "FreeResource: handle=%04x\n", handle );
+ dprintf_resource(stddeb, "FreeResource16: handle=%04x\n", handle );
if (!handle) return FALSE;
hModule = GetExePtr( handle );
if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
if (pModule->flags & NE_FFLAGS_WIN32)
{
- fprintf(stderr,"Don't know how to FreeResource() for Win32 module\n");
+ fprintf(stderr,"Don't know how to FreeResource16() for Win32 module\n");
return 0;
}
return NE_FreeResource( hModule, handle );
@@ -162,23 +245,32 @@
#endif
}
+/**********************************************************************
+ * FreeResource32 (KERNEL32.145)
+ */
+BOOL32 FreeResource32( HGLOBAL32 handle )
+{
+ /* no longer used in Win32 */
+ return TRUE;
+}
+
/**********************************************************************
- * AccessResource (KERNEL.64)
+ * AccessResource16 (KERNEL.64)
*/
-INT AccessResource( HINSTANCE hModule, HRSRC hRsrc )
+INT16 AccessResource16( HINSTANCE16 hModule, HRSRC16 hRsrc )
{
NE_MODULE *pModule;
hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */
- dprintf_resource(stddeb, "AccessResource: module=%04x res=%04x\n",
+ dprintf_resource(stddeb, "AccessResource16: module=%04x res=%04x\n",
hModule, hRsrc );
if (!hRsrc) return 0;
if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
#ifndef WINELIB
if (pModule->flags & NE_FFLAGS_WIN32)
{
- fprintf(stderr,"Don't know how to AccessResource() for Win32 module\n");
+ fprintf(stderr,"Don't know how to AccessResource16() for Win32 module\n");
return 0;
}
return NE_AccessResource( hModule, hRsrc );
@@ -189,20 +281,34 @@
/**********************************************************************
- * SizeofResource (KERNEL.65)
+ * AccessResource32 (KERNEL32.64)
*/
-DWORD SizeofResource( HMODULE hModule, HRSRC hRsrc )
+INT32 AccessResource32( HINSTANCE32 hModule, HRSRC32 hRsrc )
+{
+ hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */
+ dprintf_resource(stddeb, "AccessResource: module=%04x res=%04x\n",
+ hModule, hRsrc );
+ if (!hRsrc) return 0;
+ fprintf(stderr,"AccessResource32: not implemented\n");
+ return 0;
+}
+
+
+/**********************************************************************
+ * SizeofResource16 (KERNEL.65)
+ */
+DWORD SizeofResource16( HMODULE16 hModule, HRSRC16 hRsrc )
{
NE_MODULE *pModule;
hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */
- dprintf_resource(stddeb, "SizeofResource: module=%04x res=%04x\n",
+ dprintf_resource(stddeb, "SizeofResource16: module=%04x res=%04x\n",
hModule, hRsrc );
if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
#ifndef WINELIB
if (pModule->flags & NE_FFLAGS_WIN32)
{
- fprintf(stderr,"Don't know how to SizeOfResource() for Win32 module\n");
+ fprintf(stderr,"Don't know how to SizeOfResource16() for Win32 module\n");
return 0;
}
return NE_SizeofResource( hModule, hRsrc );
@@ -213,9 +319,22 @@
/**********************************************************************
- * AllocResource (KERNEL.66)
+ * SizeofResource32 (KERNEL32.522)
*/
-HGLOBAL AllocResource( HMODULE hModule, HRSRC hRsrc, DWORD size )
+DWORD SizeofResource32( HINSTANCE32 hModule, HRSRC32 hRsrc )
+{
+ hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */
+ dprintf_resource(stddeb, "SizeofResource32: module=%04x res=%04x\n",
+ hModule, hRsrc );
+ fprintf(stderr,"SizeofResource32: not implemented\n");
+ return 0;
+}
+
+
+/**********************************************************************
+ * AllocResource16 (KERNEL.66)
+ */
+HGLOBAL16 AllocResource16( HMODULE16 hModule, HRSRC16 hRsrc, DWORD size )
{
NE_MODULE *pModule;
@@ -255,13 +374,13 @@
/**********************************************************************
- * LoadAccelerators [USER.177]
+ * LoadAccelerators16 [USER.177]
*/
-HANDLE LoadAccelerators(HANDLE instance, SEGPTR lpTableName)
+HACCEL16 LoadAccelerators16(HINSTANCE16 instance, SEGPTR lpTableName)
{
- HANDLE hAccel;
- HANDLE rsc_mem;
- HRSRC hRsrc;
+ HACCEL16 hAccel;
+ HGLOBAL16 rsc_mem;
+ HRSRC16 hRsrc;
BYTE *lp;
ACCELHEADER *lpAccelTbl;
int i, n;
@@ -273,12 +392,12 @@
dprintf_accel( stddeb, "LoadAccelerators: %04x %04x\n",
instance, LOWORD(lpTableName) );
- if (!(hRsrc = FindResource( instance, lpTableName, RT_ACCELERATOR )))
+ if (!(hRsrc = FindResource16( instance, lpTableName, RT_ACCELERATOR )))
return 0;
- if (!(rsc_mem = LoadResource( instance, hRsrc ))) return 0;
+ if (!(rsc_mem = LoadResource16( instance, hRsrc ))) return 0;
- lp = (BYTE *)LockResource(rsc_mem);
- n = SizeofResource( instance, hRsrc ) / sizeof(ACCELENTRY);
+ lp = (BYTE *)LockResource16(rsc_mem);
+ n = SizeofResource16(instance,hRsrc)/sizeof(ACCELENTRY);
hAccel = GlobalAlloc16(GMEM_MOVEABLE,
sizeof(ACCELHEADER) + (n + 1)*sizeof(ACCELENTRY));
lpAccelTbl = (LPACCELHEADER)GlobalLock16(hAccel);
@@ -297,10 +416,78 @@
lpAccelTbl->wCount++;
}
GlobalUnlock16(hAccel);
- FreeResource( rsc_mem );
+ FreeResource16( rsc_mem );
return hAccel;
}
-
+
+/**********************************************************************
+ * LoadAccelerators32W [USER.177]
+ */
+HACCEL32 LoadAccelerators32W(HINSTANCE32 instance,LPCWSTR lpTableName)
+{
+#if 0
+ HACCEL32 hAccel;
+ HGLOBAL32 rsc_mem;
+ HRSRC32 hRsrc;
+ BYTE *lp;
+ ACCELHEADER *lpAccelTbl;
+ int i, n;
+
+ if (HIWORD(lpTableName))
+ dprintf_accel( stddeb, "LoadAccelerators: %04x '%s'\n",
+ instance, (char *)( lpTableName ) );
+ else
+ dprintf_accel( stddeb, "LoadAccelerators: %04x %04x\n",
+ instance, LOWORD(lpTableName) );
+
+ if (!(hRsrc = FindResource32W( instance, lpTableName,
+ (LPCWSTR)RT_ACCELERATOR )))
+ return 0;
+ if (!(rsc_mem = LoadResource32( instance, hRsrc ))) return 0;
+
+ lp = (BYTE *)LockResource32(rsc_mem);
+ n = SizeofResource32(instance,hRsrc)/sizeof(ACCELENTRY);
+ hAccel = GlobalAlloc16(GMEM_MOVEABLE,
+ sizeof(ACCELHEADER) + (n + 1)*sizeof(ACCELENTRY));
+ lpAccelTbl = (LPACCELHEADER)GlobalLock16(hAccel);
+ lpAccelTbl->wCount = 0;
+ for (i = 0; i < n; i++) {
+ lpAccelTbl->tbl[i].type = *(lp++);
+ lpAccelTbl->tbl[i].wEvent = *((WORD *)lp);
+ lp += 2;
+ lpAccelTbl->tbl[i].wIDval = *((WORD *)lp);
+ lp += 2;
+ if (lpAccelTbl->tbl[i].wEvent == 0) break;
+ dprintf_accel(stddeb,
+ "Accelerator #%u / event=%04X id=%04X type=%02X \n",
+ i, lpAccelTbl->tbl[i].wEvent, lpAccelTbl->tbl[i].wIDval,
+ lpAccelTbl->tbl[i].type);
+ lpAccelTbl->wCount++;
+ }
+ GlobalUnlock16(hAccel);
+ FreeResource32(rsc_mem);
+ return hAccel;
+#else
+ fprintf(stderr,"LoadAcceleratorsW: not implemented\n");
+ return 0x100; /* Return something anyway */
+#endif
+}
+
+HACCEL32 LoadAccelerators32A(HINSTANCE32 instance,LPCSTR lpTableName)
+{
+ LPWSTR uni;
+ HACCEL32 result;
+ if (HIWORD(lpTableName))
+ uni=STRING32_DupAnsiToUni(lpTableName);
+ else
+ uni=(LPWSTR)lpTableName;
+ result=LoadAccelerators32W(instance,uni);
+ if (HIWORD(uni))
+ free(uni);
+ return result;
+}
+
+
/**********************************************************************
* TranslateAccelerator [USER.178]
*/
@@ -351,14 +538,15 @@
GlobalUnlock16(hAccel);
return 0;
}
-
+
/**********************************************************************
- * LoadString
+ * LoadString16
*/
-int
-LoadString(HANDLE instance, WORD resource_id, LPSTR buffer, int buflen)
+INT16
+LoadString16(HINSTANCE16 instance,UINT16 resource_id,LPSTR buffer,INT16 buflen)
{
- HANDLE hmem, hrsrc;
+ HGLOBAL16 hmem;
+ HRSRC16 hrsrc;
unsigned char *p;
int string_num;
int i;
@@ -366,12 +554,12 @@
dprintf_resource(stddeb,"LoadString: inst=%04x id=%04x buff=%08x len=%d\n",
instance, resource_id, (int) buffer, buflen);
- hrsrc = FindResource( instance, (SEGPTR)((resource_id>>4)+1), RT_STRING );
+ hrsrc = FindResource16( instance, (SEGPTR)((resource_id>>4)+1), RT_STRING );
if (!hrsrc) return 0;
- hmem = LoadResource( instance, hrsrc );
+ hmem = LoadResource16( instance, hrsrc );
if (!hmem) return 0;
- p = LockResource(hmem);
+ p = LockResource16(hmem);
string_num = resource_id & 0x000f;
for (i = 0; i < string_num; i++)
p += *p + 1;
@@ -392,11 +580,73 @@
fprintf(stderr,"LoadString // I dont know why , but caller give buflen=%d *p=%d !\n", buflen, *p);
fprintf(stderr,"LoadString // and try to obtain string '%s'\n", p + 1);
}
- FreeResource( hmem );
+ FreeResource16( hmem );
dprintf_resource(stddeb,"LoadString // '%s' copied !\n", buffer);
return i;
}
+/**********************************************************************
+ * LoadString32W (USER32.375)
+ */
+INT32
+LoadString32W(HINSTANCE32 instance,UINT32 resource_id,LPWSTR buffer,int buflen)
+{
+ HGLOBAL32 hmem;
+ HRSRC32 hrsrc;
+ WCHAR *p;
+ int string_num;
+ int i;
+ dprintf_resource(stddeb, "LoadString: instance = %04x, id = %04x, buffer = %08x, "
+ "length = %d\n", instance, (int)resource_id, (int) buffer, buflen);
+
+ hrsrc = FindResource32W( instance, (LPCWSTR)((resource_id>>4)+1),
+ (LPCWSTR)RT_STRING );
+ if (!hrsrc) return 0;
+ hmem = LoadResource32( instance, hrsrc );
+ if (!hmem) return 0;
+
+ p = LockResource32(hmem);
+ string_num = resource_id & 0x000f;
+ for (i = 0; i < string_num; i++)
+ p += *p + 1;
+
+ dprintf_resource( stddeb, "strlen = %d\n", (int)*p );
+
+ i = MIN(buflen - 1, *p);
+ if (buffer == NULL)
+ return i;
+ if (i > 0) {
+ memcpy(buffer, p + 1, i * sizeof (WCHAR));
+ buffer[i] = (WCHAR) 0;
+ } else {
+ if (buflen > 1) {
+ buffer[0] = (WCHAR) 0;
+ return 0;
+ }
+#if 0
+ fprintf(stderr,"LoadString // I dont know why , but caller give buflen=%d *p=%d !\n", buflen, *p);
+ fprintf(stderr,"LoadString // and try to obtain string '%s'\n", p + 1);
+#endif
+ }
+#if 0
+ dprintf_resource(stddeb,"LoadString // '%s' copied !\n", buffer);
+#endif
+ return i;
+}
+
+/**********************************************************************
+ * LoadString32A (USER32.374)
+ */
+INT32
+LoadString32A(HINSTANCE32 instance,UINT32 resource_id,LPSTR buffer,int buflen)
+{
+ LPWSTR buffer2 = (LPWSTR)xmalloc(buflen*2);
+ INT32 retval = LoadString32W(instance,resource_id,buffer2,buflen);
+
+ STRING32_UniToAnsi(buffer,buffer2);
+ free(buffer2);
+ return retval;
+}