Tue Nov 21 18:49:10 1995 Alexandre Julliard <julliard@sunsite.unc.edu> * [configure.in] [Makefile] [misc/dos_fs.c] Got rid of autoconf.h file. * [debugger/dbg.y] More logical behavior upon syntax errors. * [include/hook.h] [windows/hook.c] Changed hook structure and rewrote most of the hook functions for better compatibility, based on investigations by Alex Korobka. * [include/message.h] [windows/message.c] Added hooks to message queue structure and made the structure layout Windows-compatible. Added support for WH_MOUSE, WH_KEYBOARD, WH_HARDWARE and WH_JOURNALRECORD hooks. * [misc/main.c] Added command-line option for changing the language at run-time (not implemented yet), based on a suggestion from Michael Patra. * [objects/cursoricon.c] Fixed silly SEGPTR bug in DumpIcon(). Mon Nov 20 22:22:22 1995 Alex Korobka <alex@phm30.pharm.sunysb.edu> * [controls/listbox.c] [controls/combo.c] [include/listbox.h] Partial implementaion of LBS_EXTENDEDSEL style, yet more updates for drag & drop support. Now works. * [windows/defwnd.c] More message handlers. * [windows/win.c] DragObject, DragDetect, AnyPopup functions. * [controls/listbox.c] More kludgy fixes (WM_...TOITEM, etc.). * [objects/cursoricon.c] [objects/oembitmap.c] IconToCursor skeleton, patch for OBM_LoadCursorIcon to handle new cursor. * [include/bitmaps/ocr*] New OEM cursors. Mon Nov 20 11:05:20 EST 1995 Jim Peterson <jspeter@birch.ee.vt.edu> * [toolkit/heap.c] Swapped flags and size arguments to LocalRealloc as per changes in memory/local.c by William Magro in previous release. * [include/wintypes.h] Reinstated the #define's for 'min' and 'max', since they're part of the Windows API. I really don't think it's a wise idea, so I put a '#ifndef DONT_DEFINE_min_AND_max' around them. I think the actual WINE code should never use these (it should use 'MIN' and 'MAX' instead). * [loader/*] Put '#ifndef WINELIB' around many things that WINElib should not need. * [controls/edit.c] Took out many '#if defined(WINELIB)' sections with the associated comment 'temporary fix, until Local memory is correctly implemented in WINELIB', since the effective translations are now in toolkit/miscstubs.c. Took out the #ifndef's I put in EDIT_ClearText. Whoever modified this file fixed (or at least postponed) the bug I had encountered. * [loader/task.c] Put an #ifdef in TASK_CreateTask() that hardwires the current drive to C: This will probably cause a lot of trouble if this change is forgotten in the future, but it will let things like the OpenFileName dialog work for now. * [toolkit/libres.c] [toolkit/Makefile.in] [toolkit/Makefile] [include/libres.h] Made new libres.c file, which will contain functions for supporting accessing resources by name in WINElib. 'winerc' will need to be changed. * [toolkit/heap.c] Refined memory routines to allow for differences between LocalAlloc and GlobalAlloc and between LocalSize and GlobalSize. * [windows/message.c] [include/windows.h] Defined the GetCurrentTime routine in windows/message.c, and removed the #define in windows.h. Mon Nov 20 00:36:42 MET 1995 Sven Verdoolaege <skimo@dns.ufsia.ac.be> * [*/*] Added new debugging type DEBUG_WIN32 and DEBUG_ENV. * [loader/module.c] Added undocumented GetExpWinVer. * [tools/build.c] Previous code didn't pop possibly changed %esi, %edi and %edx from the stack. * [win32/advapi.c] Added GetUserNameA. * [win32/code_page.c] Added stub for MultiByteToWideChar. * [win32/console.c] Added SetConsoleCtrlHandler stub. * [win32/file.c] Added ReadFile CreateFileA GetFileInformationByHandle stubs. Added CloseHandle. * [win32/memory.c] Changed VirtualAlloc and VirtualFree. * [win32/process.c] Added ExitProcess. Sun Nov 19 17:54:42 1995 Bernd Schmidt <crux@pool.informatik.rwth-aachen.de> * [include/windows.h] Fixed a few broken structure definitions. * [loader/resource.c] FindResource(): Need to check for '#xxx' strings here. * [miscemu/int21.c] FindNext(): Return MS-DOS filenames uppercase. * [objects/cursoricon.c] CreateIcon(), CreateCursor(): Added missing element to CURSORICONINFO initializers. * [misc/file.c] _lopen(): Files opened in OF_WRITE mode are truncated. OpenFile(): Ignore OF_READ/OF_WRITE/OF_READWRITE when files are created; use read/write mode. * [misc/profile.c] load(): Rewritten. * [misc/commdlg.c] Fixed bad call to strncpy() that smashed the stack. * [controls/combo.c] [windows/winpos.c] [memory/selector.c] Operator precedence fixes. People who use gcc 2.7.1 don't need a debugger :-) * [if1632/gdi.spec] [objects/palette.c] Add ResizePalette() and AnimatePalette() stubs. They don't do anything, but sometimes that's good enough. Fri Nov 17 09:10:35 GMT 1995 John Harvey <john@division.co.uk> * [include/wine.h] [include/registers.h] [include/winsock.h] Added definitions for Unixware. * [loader/signal.c] [misc/comm.c] [misc/winsocket.c] Misc. fixes for Unixware. * [loader/task.c] Made assignemts to context in InitTask for registers use the macros from registers.h to make them more portable. (Needed for Unixware) * [tools/build.c] Fixed register acces routines to work on Unixware. Bit grubby but it seems to work. * [controls/edit.c] EDIT_WM_NCCreate allocates local heap if hasn't been previously allocated. * [miscemu/int21.c] mkdir now creates directory with permission to access it. * [misc/dos_fs.c] mkdir now creates directory with permission to access it. DOS_opendir now uses linked list of dirents to avoid problems with realloc changing address of malloced memory. Thu Nov 16 12:47:13 1995 Michael Patra <patra@itp1.Physik.TU-Berlin.DE> * [controls/menu.c] MENU_CalcItemSize(): Fixed handling of empty menu items. Sat Nov 11 21:46:54 1995 Hans de Graaff <graaff@twi72.twi.tudelft.nl> * [misc/file.c] In OpenFile, unlink should be done on the unix filename. Sat Nov 11 16:43:29 1995 Cameron Heide (heide@ee.ualberta.ca) * [include/handle32.h] New header file containing internal Win32 kernel handle information. * [win32/file.c] Added ReadFile, CreateFile, and CloseFileHandle, and did some reorganizing to match the new handle allocation scheme. * [win32/init.c] Added CloseHandle and the creation of standard I/O handles. * [win32/object_mgt.c] New module for allocating and freeing Win32 kernel handles.
426 lines
11 KiB
C
426 lines
11 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"
|
||
#include "libres.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 );
|
||
if (HIWORD(name)) /* Check for '#xxx' name */
|
||
{
|
||
char *ptr = PTR_SEG_TO_LIN( name );
|
||
if (ptr[0] == '#') {
|
||
if (!(name = (SEGPTR)atoi( ptr + 1 ))) return 0;
|
||
}
|
||
}
|
||
dprintf_resource( stddeb, " name=" );
|
||
PrintId( name );
|
||
dprintf_resource( stddeb, "\n" );
|
||
if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0;
|
||
#ifndef WINELIB
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return NE_FindResource( hModule, type, name );
|
||
case PE_SIGNATURE:
|
||
return 0;
|
||
default:
|
||
return 0;
|
||
}
|
||
#else
|
||
return LIBRES_FindResource( hModule, type, name );
|
||
#endif
|
||
}
|
||
|
||
|
||
/**********************************************************************
|
||
* 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;
|
||
#ifndef WINELIB
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return NE_LoadResource( hModule, hRsrc );
|
||
case PE_SIGNATURE:
|
||
return 0;
|
||
default:
|
||
return 0;
|
||
}
|
||
#else
|
||
return LIBRES_LoadResource( hModule, hRsrc );
|
||
#endif
|
||
}
|
||
|
||
|
||
/**********************************************************************
|
||
* 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;
|
||
#ifndef WINELIB
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return NE_LockResource( hModule, handle );
|
||
case PE_SIGNATURE:
|
||
return 0;
|
||
default:
|
||
return 0;
|
||
}
|
||
#else
|
||
return LIBRES_LockResource( hModule, handle );
|
||
#endif
|
||
}
|
||
|
||
/* 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;
|
||
#ifndef WINELIB
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return (LPSTR)PTR_SEG_TO_LIN( NE_LockResource( hModule, handle ) );
|
||
case PE_SIGNATURE:
|
||
return 0;
|
||
default:
|
||
return 0;
|
||
}
|
||
#else
|
||
return LIBRES_LockResource( hModule, handle );
|
||
#endif
|
||
}
|
||
|
||
|
||
/**********************************************************************
|
||
* 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;
|
||
#ifndef WINELIB
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return NE_FreeResource( hModule, handle );
|
||
case PE_SIGNATURE:
|
||
return FALSE;
|
||
default:
|
||
return FALSE;
|
||
}
|
||
#else
|
||
return LIBRES_FreeResource( hModule, handle );
|
||
#endif
|
||
}
|
||
|
||
|
||
/**********************************************************************
|
||
* 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;
|
||
#ifndef WINELIB
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return NE_AccessResource( hModule, hRsrc );
|
||
case PE_SIGNATURE:
|
||
return 0;
|
||
default:
|
||
return 0;
|
||
}
|
||
#else
|
||
return LIBRES_AccessResource( hModule, hRsrc );
|
||
#endif
|
||
}
|
||
|
||
|
||
/**********************************************************************
|
||
* 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;
|
||
#ifndef WINELIB
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return NE_SizeofResource( hModule, hRsrc );
|
||
case PE_SIGNATURE:
|
||
return 0;
|
||
default:
|
||
return 0;
|
||
}
|
||
#else
|
||
return LIBRES_SizeofResource( hModule, hRsrc );
|
||
#endif
|
||
}
|
||
|
||
|
||
/**********************************************************************
|
||
* 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;
|
||
#ifndef WINELIB
|
||
switch(*pModule)
|
||
{
|
||
case NE_SIGNATURE:
|
||
return NE_AllocResource( hModule, hRsrc, size );
|
||
case PE_SIGNATURE:
|
||
return 0;
|
||
default:
|
||
return 0;
|
||
}
|
||
#else
|
||
return LIBRES_AllocResource( hModule, hRsrc, size );
|
||
#endif
|
||
}
|
||
|
||
/**********************************************************************
|
||
* 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;
|
||
}
|
||
|
||
|
||
|