Fri Nov 3 20:08:17 1995 Alexandre Julliard <julliard@sunsite.unc.edu> * [configure.in] Attempt to check for -li386 on NetBSD. Please test this. Mon Oct 30 12:40:32 EST 1995 Jim Peterson <jspeter@birch.ee.vt.edu> * [*/*] Eliminated various warnings with either explicit casts or more accurate variable/parameter declarations (e.g. INT instead of short or WORD). Changed macros 'min' and 'max' to 'MIN' and 'MAX', since they're macros. * [controls/edit.c] [windows/defdlg.c] Added '#ifdef SUPERFLUOUS_FUNCTIONS' wrappers around function definition of EDIT_KeyVScrollDoc, EDIT_TextLineNumber, and DEFDLG_FindDefButton to avoid warnings. * [controls/button.c] [controls/scroll.c] [windows/defwnd.c] [windows/message.c] [windows/nonclient.c] Converted MAKEPOINT macro call to manual conversion. * [include/windows.h] For WINELIB32, structures POINT, SIZE, and RECT have LONG members instead of INT. This also invalidates the macro MAKEPOINT(), which is not supported in Win32. Also defined the POINTS structure (SHORT members) and the MAKEPOINTS macro. * [misc/commdlg.c] Changed a lot of 'strcpy' calls to 'strncpy' calls. I'm desperate to find this memory bug, and this should be done anyway. * [controls/edit.c] Well, the alteration mentioned above didn't do it, but #ifdef'ing out a few lines in EDIT_ClearText did. This leads to bugs, but for now, it's better than bizzare memory troubles. * [toolkit/miscstubs.c] Removed warning messages in GLOBAL_CreateBlock(), GLOBAL_FreeBlock(), and RELAY32_GetEntryPoint(). These are the most popular warnings, and their current implementation seems fine. Sat Oct 28 09:39:18 1995 Jochen Karrer <cip307@wpax01.Physik.Uni-Wuerzburg.DE> * [objects/cursoricon.c] Fix for "broken" X servers that invert masked cursor colors. Fri Oct 27 19:27:21 1995 Alex Korobka <alex@phm6.pharm.sunysb.edu> * [windows/dialog.c] [windows/nonclient.c] Remove unnecessary items from the system menu. Thu Oct 26 05:03:03 MET 1995 Philippe De Muyter <phdm@info.ucl.ac.be> * [objects/color.c] [objects/palette.c] Make GetNearestColor return a RGB value instead of a pixel value. Wed Oct 25 23:33:39 1995 Martin von Loewis <loewis@informatik.hu-berlin.de> * [controls/desktop.c][controls/menu.c][include/menu.h] Changed WORD parameters to UINT parameters. * [include/wintypes.h] Made UINT 32bit for WINELIB. * [loader/main.c] Disabled RELAY32_Init and MODULE_Init for WINELIB. * [misc/main.c] Assume CPU386 for WINELIB. * [rc/winerc] add_popup: set MF_POPUP flag on menu item. * [toolkit/Makefile.in][toolkit/hello3.c][toolkit/hello3res.c] Add resource demo hello3 for WINELIB. New file README.resources. * [toolkit/miscstubs.c] Add a case for 17. Tue Oct 17 15:13:10 IST 1995 Itai Nahshon <nahshon@vnet.ibm.com> * [loader/module.c] Do not append .exe if the file name already has an extension. * [misc/profile.c] Avoid creating a file with a junk name if a .ini file does not exist. * [if1632/gdi.spec] [if1632/user.spec] [if1632/dummy.c] Added a lot of dummy stubs for Windows Hebrew version. Tue Oct 17 01:03:24 1995 William Magro <wmagro@tc.cornell.edu> * [controls/button.c] Fix for buttons with no label. * [controls/combo.c][controls/listbox.c] Fixes for scrollbar positioning. Now disappears correctly for short lists. * [controls/edit.c] Handle memory allocation differently when building as library. * [controls/static] Don't destroy old icon before drawing new icon. (Fixes landscape/ portrait toggle icon in print dialog.) * [if1632/gdi.spec] New functions SetMetaFileBits and GetMetaFileBits * [include/sysmetrics.h] [windows/sysmetrics.c] Add support for GetSystemMetrics(SM_CMETRICS) == SM_CMETRICS * [include/windows.h] META_EXTTEXTOUT, not META_SETTEXTOUT define GetCurrentTime as GetTickCount (for wine library) * [loader/main.c] Don't initialize built-in modules in wine library * [memory/local.c] LocalReAlloc was defined incorrectly. Swap flags and size arguments. * [misc/main.c] Always report CPUTYPE=4 to wine library. * [objects/dib.c] RLE8 images were missing top line when decompressed. * [objects/metafile.c] SetMetaFileBits and GetMetaFileBits implemented. Works when called from winhelp. More testing needed. Various memory leaks plugged. Various other bug fixes. New metafile operations added in PlayMetaFileRecord: CreatePalette, SetTextAlign, SelectPalette, SetMapperFlags, RealizePalette, ExtTextOut, Escape. Testing needed. * [toolkit/heap.c] LocalUnLock changed to LocalUnlock Sun Oct 15 21:55:33 1995 Anand Kumria <akumria@ozemail.com.au> * [misc/winsock.c] Return the correct error number, for host lookup operations. Also, correct the problem with send_message. Fri Oct 13 19:04:35 1995 Morten Welinder <terra@diku.dk> * [Makefile.in] Using nm's built-in sorting. * [*/*.c] Use xmalloc for malloc and xrealloc for realloc in all ungarded cases. * [debugger/dbg.y] Handle C-like expressions. Clean-up. * [debugger/debug.l] Lots of new tokens for expressions. * [debugger/info.c] Implement "list" command for disassembling. * [misc/ole2nls.c] Implement more Danish stuff. Fri Oct 6 10:39:39 1995 Ram'on Garc'ia <ramon@ie3.clubs.etsit.upm.es> * [loader/module.c] Updated self-loading modules to support for new 32 bit stack frames.
386 lines
10 KiB
C
386 lines
10 KiB
C
/*
|
||
* Resources
|
||
*
|
||
* Copyright 1993 Robert J. Amstadt
|
||
* Copyright 1995 Alexandre Julliard
|
||
*/
|
||
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
#include <sys/types.h>
|
||
#include <sys/stat.h>
|
||
#include <fcntl.h>
|
||
#include <unistd.h>
|
||
#include "arch.h"
|
||
#include "windows.h"
|
||
#include "gdi.h"
|
||
#include "global.h"
|
||
#include "neexe.h"
|
||
#include "accel.h"
|
||
#include "dlls.h"
|
||
#include "module.h"
|
||
#include "resource.h"
|
||
#include "stddebug.h"
|
||
#include "debug.h"
|
||
|
||
#define PrintId(name) \
|
||
if (HIWORD((DWORD)name)) \
|
||
dprintf_resource( stddeb, "'%s'", (char *)PTR_SEG_TO_LIN(name)); \
|
||
else \
|
||
dprintf_resource( stddeb, "#%04x", LOWORD(name));
|
||
|
||
|
||
/**********************************************************************
|
||
* FindResource (KERNEL.60)
|
||
*/
|
||
HRSRC FindResource( HMODULE hModule, SEGPTR name, SEGPTR type )
|
||
{
|
||
WORD *pModule;
|
||
|
||
hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */
|
||
dprintf_resource(stddeb, "FindResource: module="NPFMT" type=", hModule );
|
||
PrintId( type );
|
||
dprintf_resource( stddeb, " name=" );
|
||
PrintId( name );
|
||
dprintf_resource( stddeb, "\n" );
|
||
if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0;
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return NE_FindResource( hModule, type, name );
|
||
case PE_SIGNATURE:
|
||
return 0;
|
||
default:
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
|
||
/**********************************************************************
|
||
* LoadResource (KERNEL.61)
|
||
*/
|
||
HGLOBAL LoadResource( HMODULE hModule, HRSRC hRsrc )
|
||
{
|
||
WORD *pModule;
|
||
|
||
hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */
|
||
dprintf_resource(stddeb, "LoadResource: module="NPFMT" res="NPFMT"\n",
|
||
hModule, hRsrc );
|
||
if (!hRsrc) return 0;
|
||
if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0;
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return NE_LoadResource( hModule, hRsrc );
|
||
case PE_SIGNATURE:
|
||
return 0;
|
||
default:
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
|
||
/**********************************************************************
|
||
* LockResource (KERNEL.62)
|
||
*/
|
||
/* 16-bit version */
|
||
SEGPTR WIN16_LockResource( HGLOBAL handle )
|
||
{
|
||
HMODULE hModule;
|
||
WORD *pModule;
|
||
|
||
dprintf_resource(stddeb, "LockResource: handle="NPFMT"\n", handle );
|
||
if (!handle) return (SEGPTR)0;
|
||
hModule = GetExePtr( handle );
|
||
if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0;
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return NE_LockResource( hModule, handle );
|
||
case PE_SIGNATURE:
|
||
return 0;
|
||
default:
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
/* 32-bit version */
|
||
LPSTR LockResource( HGLOBAL handle )
|
||
{
|
||
HMODULE hModule;
|
||
WORD *pModule;
|
||
|
||
dprintf_resource(stddeb, "LockResource: handle="NPFMT"\n", handle );
|
||
if (!handle) return NULL;
|
||
hModule = GetExePtr( handle );
|
||
if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0;
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return (LPSTR)PTR_SEG_TO_LIN( NE_LockResource( hModule, handle ) );
|
||
case PE_SIGNATURE:
|
||
return 0;
|
||
default:
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
|
||
/**********************************************************************
|
||
* FreeResource (KERNEL.63)
|
||
*/
|
||
BOOL FreeResource( HGLOBAL handle )
|
||
{
|
||
HMODULE hModule;
|
||
WORD *pModule;
|
||
|
||
dprintf_resource(stddeb, "FreeResource: handle="NPFMT"\n", handle );
|
||
if (!handle) return FALSE;
|
||
hModule = GetExePtr( handle );
|
||
if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0;
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return NE_FreeResource( hModule, handle );
|
||
case PE_SIGNATURE:
|
||
return FALSE;
|
||
default:
|
||
return FALSE;
|
||
}
|
||
}
|
||
|
||
|
||
/**********************************************************************
|
||
* AccessResource (KERNEL.64)
|
||
*/
|
||
INT AccessResource( HINSTANCE hModule, HRSRC hRsrc )
|
||
{
|
||
WORD *pModule;
|
||
|
||
hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */
|
||
dprintf_resource(stddeb, "AccessResource: module="NPFMT" res="NPFMT"\n",
|
||
hModule, hRsrc );
|
||
if (!hRsrc) return 0;
|
||
if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0;
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return NE_AccessResource( hModule, hRsrc );
|
||
case PE_SIGNATURE:
|
||
return 0;
|
||
default:
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
|
||
/**********************************************************************
|
||
* SizeofResource (KERNEL.65)
|
||
*/
|
||
DWORD SizeofResource( HMODULE hModule, HRSRC hRsrc )
|
||
{
|
||
WORD *pModule;
|
||
|
||
hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */
|
||
dprintf_resource(stddeb, "SizeofResource: module="NPFMT" res="NPFMT"\n",
|
||
hModule, hRsrc );
|
||
if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0;
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return NE_SizeofResource( hModule, hRsrc );
|
||
case PE_SIGNATURE:
|
||
return 0;
|
||
default:
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
|
||
/**********************************************************************
|
||
* AllocResource (KERNEL.66)
|
||
*/
|
||
HGLOBAL AllocResource( HMODULE hModule, HRSRC hRsrc, DWORD size )
|
||
{
|
||
WORD *pModule;
|
||
|
||
hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */
|
||
dprintf_resource(stddeb, "AllocResource: module="NPFMT" res="NPFMT" size=%ld\n",
|
||
hModule, hRsrc, size );
|
||
if (!hRsrc) return 0;
|
||
if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0;
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return NE_AllocResource( hModule, hRsrc, size );
|
||
case PE_SIGNATURE:
|
||
return 0;
|
||
default:
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
/**********************************************************************
|
||
* DirectResAlloc (KERNEL.168)
|
||
*
|
||
* Check Schulman, p. 232 for details
|
||
*/
|
||
HANDLE DirectResAlloc(HANDLE hInstance, WORD wType, WORD wSize)
|
||
{
|
||
dprintf_resource(stddeb,"DirectResAlloc("NPFMT",%x,%x)\n",hInstance,wType,wSize);
|
||
hInstance = GetExePtr(hInstance);
|
||
if(!hInstance)return 0;
|
||
if(wType != 0x10) /* 0x10 is the only observed value, passed from
|
||
CreateCursorIndirect. */
|
||
fprintf(stderr, "DirectResAlloc: wType = %x\n", wType);
|
||
return GLOBAL_Alloc(GMEM_MOVEABLE, wSize, hInstance, FALSE, FALSE, FALSE);
|
||
}
|
||
|
||
|
||
/**********************************************************************
|
||
* LoadAccelerators [USER.177]
|
||
*/
|
||
HANDLE LoadAccelerators(HANDLE instance, SEGPTR lpTableName)
|
||
{
|
||
HANDLE hAccel;
|
||
HANDLE rsc_mem;
|
||
HRSRC hRsrc;
|
||
BYTE *lp;
|
||
ACCELHEADER *lpAccelTbl;
|
||
int i, n;
|
||
|
||
if (HIWORD(lpTableName))
|
||
dprintf_accel( stddeb, "LoadAccelerators: "NPFMT" '%s'\n",
|
||
instance, (char *)PTR_SEG_TO_LIN( lpTableName ) );
|
||
else
|
||
dprintf_accel( stddeb, "LoadAccelerators: "NPFMT" %04x\n",
|
||
instance, LOWORD(lpTableName) );
|
||
|
||
if (!(hRsrc = FindResource( instance, lpTableName, RT_ACCELERATOR )))
|
||
return 0;
|
||
if (!(rsc_mem = LoadResource( instance, hRsrc ))) return 0;
|
||
|
||
lp = (BYTE *)LockResource(rsc_mem);
|
||
n = SizeofResource( instance, hRsrc ) / sizeof(ACCELENTRY);
|
||
hAccel = GlobalAlloc(GMEM_MOVEABLE,
|
||
sizeof(ACCELHEADER) + (n + 1)*sizeof(ACCELENTRY));
|
||
lpAccelTbl = (LPACCELHEADER)GlobalLock(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++;
|
||
}
|
||
GlobalUnlock(hAccel);
|
||
FreeResource( rsc_mem );
|
||
return hAccel;
|
||
}
|
||
|
||
/**********************************************************************
|
||
* TranslateAccelerator [USER.178]
|
||
*/
|
||
int TranslateAccelerator(HWND hWnd, HANDLE hAccel, LPMSG msg)
|
||
{
|
||
ACCELHEADER *lpAccelTbl;
|
||
int i;
|
||
|
||
if (hAccel == 0 || msg == NULL) return 0;
|
||
if (msg->message != WM_KEYDOWN &&
|
||
msg->message != WM_KEYUP &&
|
||
msg->message != WM_SYSKEYDOWN &&
|
||
msg->message != WM_SYSKEYUP &&
|
||
msg->message != WM_CHAR) return 0;
|
||
|
||
dprintf_accel(stddeb, "TranslateAccelerators hAccel="NPFMT" !\n", hAccel);
|
||
|
||
lpAccelTbl = (LPACCELHEADER)GlobalLock(hAccel);
|
||
for (i = 0; i < lpAccelTbl->wCount; i++) {
|
||
if(lpAccelTbl->tbl[i].type & VIRTKEY_ACCEL) {
|
||
if(msg->wParam == lpAccelTbl->tbl[i].wEvent &&
|
||
(msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN)) {
|
||
INT mask = 0;
|
||
|
||
if(GetKeyState(VK_SHIFT) & 0xf) mask |= SHIFT_ACCEL;
|
||
if(GetKeyState(VK_CONTROL) & 0xf) mask |= CONTROL_ACCEL;
|
||
if(GetKeyState(VK_MENU) & 0xf) mask |= ALT_ACCEL;
|
||
if(mask == (lpAccelTbl->tbl[i].type &
|
||
(SHIFT_ACCEL | CONTROL_ACCEL | ALT_ACCEL))) {
|
||
SendMessage(hWnd, WM_COMMAND, lpAccelTbl->tbl[i].wIDval,
|
||
0x00010000L);
|
||
GlobalUnlock(hAccel);
|
||
return 1;
|
||
}
|
||
if (msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP)
|
||
return 1;
|
||
}
|
||
}
|
||
else {
|
||
if (msg->wParam == lpAccelTbl->tbl[i].wEvent &&
|
||
msg->message == WM_CHAR) {
|
||
SendMessage(hWnd, WM_COMMAND, lpAccelTbl->tbl[i].wIDval, 0x00010000L);
|
||
GlobalUnlock(hAccel);
|
||
return 1;
|
||
}
|
||
}
|
||
}
|
||
GlobalUnlock(hAccel);
|
||
return 0;
|
||
}
|
||
|
||
/**********************************************************************
|
||
* LoadString
|
||
*/
|
||
int
|
||
LoadString(HANDLE instance, WORD resource_id, LPSTR buffer, int buflen)
|
||
{
|
||
HANDLE hmem, hrsrc;
|
||
unsigned char *p;
|
||
int string_num;
|
||
int i;
|
||
|
||
dprintf_resource(stddeb, "LoadString: instance = "NPFMT", id = %04x, buffer = %08x, "
|
||
"length = %d\n", instance, resource_id, (int) buffer, buflen);
|
||
|
||
hrsrc = FindResource( instance, (SEGPTR)((resource_id>>4)+1), RT_STRING );
|
||
if (!hrsrc) return 0;
|
||
hmem = LoadResource( instance, hrsrc );
|
||
if (!hmem) return 0;
|
||
|
||
p = LockResource(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);
|
||
buffer[i] = '\0';
|
||
} else {
|
||
if (buflen > 1) {
|
||
buffer[0] = '\0';
|
||
return 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);
|
||
}
|
||
FreeResource( hmem );
|
||
|
||
dprintf_resource(stddeb,"LoadString // '%s' copied !\n", buffer);
|
||
return i;
|
||
}
|
||
|
||
|
||
|