2000-08-04 06:21:02 +02:00
|
|
|
/*
|
|
|
|
* USER resource functions
|
|
|
|
*
|
|
|
|
* Copyright 1993 Robert J. Amstadt
|
|
|
|
* Copyright 1995 Alexandre Julliard
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-08-04 06:21:02 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2000-08-04 06:21:02 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
2008-03-03 20:06:54 +01:00
|
|
|
#include "winternl.h"
|
2000-08-04 06:21:02 +02:00
|
|
|
#include "winnls.h"
|
|
|
|
#include "wine/winbase16.h"
|
|
|
|
#include "wine/winuser16.h"
|
2002-10-17 18:43:42 +02:00
|
|
|
#include "wownt32.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-08-04 06:21:02 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(resource);
|
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(accel);
|
2000-08-04 06:21:02 +02:00
|
|
|
|
2000-10-13 01:18:55 +02:00
|
|
|
/* this is the 8 byte accel struct used in Win32 resources (internal only) */
|
|
|
|
typedef struct
|
|
|
|
{
|
2004-11-21 16:41:38 +01:00
|
|
|
WORD fVirt;
|
2000-10-13 01:18:55 +02:00
|
|
|
WORD key;
|
|
|
|
WORD cmd;
|
2004-11-21 16:41:38 +01:00
|
|
|
WORD pad;
|
2000-10-13 01:18:55 +02:00
|
|
|
} PE_ACCEL, *LPPE_ACCEL;
|
|
|
|
|
2000-08-04 06:21:02 +02:00
|
|
|
/**********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* LoadAccelerators [USER.177]
|
2000-08-04 06:21:02 +02:00
|
|
|
*/
|
2000-11-27 22:54:01 +01:00
|
|
|
HACCEL16 WINAPI LoadAccelerators16(HINSTANCE16 instance, LPCSTR lpTableName)
|
2000-08-04 06:21:02 +02:00
|
|
|
{
|
|
|
|
HRSRC16 hRsrc;
|
|
|
|
|
2002-05-17 04:55:48 +02:00
|
|
|
TRACE_(accel)("%04x %s\n", instance, debugstr_a(lpTableName) );
|
2000-08-04 06:21:02 +02:00
|
|
|
|
2003-09-10 05:56:47 +02:00
|
|
|
if (!(hRsrc = FindResource16( instance, lpTableName, (LPSTR)RT_ACCELERATOR ))) {
|
2000-08-04 06:21:02 +02:00
|
|
|
WARN_(accel)("couldn't find accelerator table resource\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE_(accel)("returning HACCEL 0x%x\n", hRsrc);
|
|
|
|
return LoadResource16(instance,hRsrc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2001-01-25 23:22:21 +01:00
|
|
|
* LoadAcceleratorsW (USER32.@)
|
2000-08-04 06:21:02 +02:00
|
|
|
* The image layout seems to look like this (not 100% sure):
|
2004-11-21 16:41:38 +01:00
|
|
|
* 00: WORD type type of accelerator
|
2000-08-04 06:21:02 +02:00
|
|
|
* 02: WORD event
|
2002-06-01 01:06:46 +02:00
|
|
|
* 04: WORD IDval
|
2000-08-04 06:21:02 +02:00
|
|
|
* 06: WORD pad (to DWORD boundary)
|
|
|
|
*/
|
|
|
|
HACCEL WINAPI LoadAcceleratorsW(HINSTANCE instance,LPCWSTR lpTableName)
|
|
|
|
{
|
|
|
|
HRSRC hRsrc;
|
2002-08-28 02:39:39 +02:00
|
|
|
HACCEL hMem;
|
|
|
|
HACCEL16 hRetval=0;
|
2000-08-04 06:21:02 +02:00
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
if (HIWORD(lpTableName))
|
|
|
|
TRACE_(accel)("%p '%s'\n",
|
2004-11-30 22:38:57 +01:00
|
|
|
(LPVOID)instance, (const char *)( lpTableName ) );
|
2000-08-04 06:21:02 +02:00
|
|
|
else
|
|
|
|
TRACE_(accel)("%p 0x%04x\n",
|
|
|
|
(LPVOID)instance, LOWORD(lpTableName) );
|
|
|
|
|
2003-09-10 05:56:47 +02:00
|
|
|
if (!(hRsrc = FindResourceW( instance, lpTableName, (LPWSTR)RT_ACCELERATOR )))
|
2000-08-04 06:21:02 +02:00
|
|
|
{
|
|
|
|
WARN_(accel)("couldn't find accelerator table resource\n");
|
|
|
|
} else {
|
|
|
|
hMem = LoadResource( instance, hRsrc );
|
|
|
|
size = SizeofResource( instance, hRsrc );
|
|
|
|
if(size>=sizeof(PE_ACCEL))
|
|
|
|
{
|
|
|
|
LPPE_ACCEL accel_table = (LPPE_ACCEL) hMem;
|
|
|
|
LPACCEL16 accel16;
|
|
|
|
int i,nrofaccells = size/sizeof(PE_ACCEL);
|
|
|
|
|
|
|
|
hRetval = GlobalAlloc16(0,sizeof(ACCEL16)*nrofaccells);
|
|
|
|
accel16 = (LPACCEL16)GlobalLock16(hRetval);
|
|
|
|
for (i=0;i<nrofaccells;i++) {
|
2004-07-13 01:26:05 +02:00
|
|
|
accel16[i].fVirt = accel_table[i].fVirt & 0x7f;
|
|
|
|
accel16[i].key = accel_table[i].key;
|
|
|
|
if( !(accel16[i].fVirt & FVIRTKEY) )
|
|
|
|
accel16[i].key &= 0x00ff;
|
|
|
|
accel16[i].cmd = accel_table[i].cmd;
|
2000-08-04 06:21:02 +02:00
|
|
|
}
|
|
|
|
accel16[i-1].fVirt |= 0x80;
|
|
|
|
}
|
|
|
|
}
|
2002-11-22 22:22:14 +01:00
|
|
|
TRACE_(accel)("returning HACCEL %p\n", hRsrc);
|
2002-08-28 02:39:39 +02:00
|
|
|
return HACCEL_32(hRetval);
|
2000-08-04 06:21:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-01-25 23:22:21 +01:00
|
|
|
* LoadAcceleratorsA (USER32.@)
|
2000-08-04 06:21:02 +02:00
|
|
|
*/
|
|
|
|
HACCEL WINAPI LoadAcceleratorsA(HINSTANCE instance,LPCSTR lpTableName)
|
|
|
|
{
|
2002-01-01 01:24:30 +01:00
|
|
|
INT len;
|
|
|
|
LPWSTR uni;
|
|
|
|
HACCEL result = 0;
|
|
|
|
|
|
|
|
if (!HIWORD(lpTableName)) return LoadAcceleratorsW( instance, (LPCWSTR)lpTableName );
|
|
|
|
|
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, lpTableName, -1, NULL, 0 );
|
|
|
|
if ((uni = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
|
|
|
|
{
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, lpTableName, -1, uni, len );
|
|
|
|
result = LoadAcceleratorsW(instance,uni);
|
|
|
|
HeapFree( GetProcessHeap(), 0, uni);
|
|
|
|
}
|
|
|
|
return result;
|
2000-08-04 06:21:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2001-01-25 23:22:21 +01:00
|
|
|
* CopyAcceleratorTableA (USER32.@)
|
2000-08-04 06:21:02 +02:00
|
|
|
*/
|
|
|
|
INT WINAPI CopyAcceleratorTableA(HACCEL src, LPACCEL dst, INT entries)
|
|
|
|
{
|
|
|
|
return CopyAcceleratorTableW(src, dst, entries);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2001-01-25 23:22:21 +01:00
|
|
|
* CopyAcceleratorTableW (USER32.@)
|
2000-08-04 06:21:02 +02:00
|
|
|
*
|
|
|
|
* By mortene@pvv.org 980321
|
|
|
|
*/
|
|
|
|
INT WINAPI CopyAcceleratorTableW(HACCEL src, LPACCEL dst,
|
|
|
|
INT entries)
|
|
|
|
{
|
|
|
|
int i,xsize;
|
2002-08-28 02:39:39 +02:00
|
|
|
LPACCEL16 accel = (LPACCEL16)GlobalLock16(HACCEL_16(src));
|
2000-08-04 06:21:02 +02:00
|
|
|
BOOL done = FALSE;
|
|
|
|
|
|
|
|
/* Do parameter checking to avoid the explosions and the screaming
|
|
|
|
as far as possible. */
|
2002-12-02 19:10:57 +01:00
|
|
|
if((dst && (entries < 1)) || (src == NULL) || !accel) {
|
2000-08-04 06:21:02 +02:00
|
|
|
WARN_(accel)("Application sent invalid parameters (%p %p %d).\n",
|
|
|
|
(LPVOID)src, (LPVOID)dst, entries);
|
|
|
|
return 0;
|
|
|
|
}
|
2002-08-28 02:39:39 +02:00
|
|
|
xsize = GlobalSize16(HACCEL_16(src))/sizeof(ACCEL16);
|
2004-07-12 22:42:30 +02:00
|
|
|
if (xsize<entries) entries=xsize;
|
2000-08-04 06:21:02 +02:00
|
|
|
|
|
|
|
i=0;
|
|
|
|
while(!done) {
|
|
|
|
/* Spit out some debugging information. */
|
|
|
|
TRACE_(accel)("accel %d: type 0x%02x, event '%c', IDval 0x%04x.\n",
|
|
|
|
i, accel[i].fVirt, accel[i].key, accel[i].cmd);
|
|
|
|
|
|
|
|
/* Copy data to the destination structure array (if dst == NULL,
|
|
|
|
we're just supposed to count the number of entries). */
|
|
|
|
if(dst) {
|
2004-07-12 22:42:30 +02:00
|
|
|
dst[i].fVirt = accel[i].fVirt&0x7f;
|
2000-08-04 06:21:02 +02:00
|
|
|
dst[i].key = accel[i].key;
|
|
|
|
dst[i].cmd = accel[i].cmd;
|
|
|
|
|
|
|
|
/* Check if we've reached the end of the application supplied
|
|
|
|
accelerator table. */
|
2004-07-13 01:26:05 +02:00
|
|
|
if(i+1 == entries)
|
2000-08-04 06:21:02 +02:00
|
|
|
done = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The highest order bit seems to mark the end of the accelerator
|
|
|
|
resource table, but not always. Use GlobalSize() check too. */
|
|
|
|
if((accel[i].fVirt & 0x80) != 0) done = TRUE;
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-25 23:22:21 +01:00
|
|
|
* CreateAcceleratorTableA (USER32.@)
|
2000-08-04 06:21:02 +02:00
|
|
|
*
|
|
|
|
* By mortene@pvv.org 980321
|
|
|
|
*/
|
|
|
|
HACCEL WINAPI CreateAcceleratorTableA(LPACCEL lpaccel, INT cEntries)
|
|
|
|
{
|
|
|
|
HACCEL hAccel;
|
|
|
|
LPACCEL16 accel;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Do parameter checking just in case someone's trying to be
|
|
|
|
funny. */
|
|
|
|
if(cEntries < 1) {
|
|
|
|
WARN_(accel)("Application sent invalid parameters (%p %d).\n",
|
|
|
|
lpaccel, cEntries);
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
2002-12-02 19:10:57 +01:00
|
|
|
return NULL;
|
2000-08-04 06:21:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate memory and copy the table. */
|
2002-08-28 02:39:39 +02:00
|
|
|
hAccel = HACCEL_32(GlobalAlloc16(0,cEntries*sizeof(ACCEL16)));
|
2000-08-04 06:21:02 +02:00
|
|
|
|
2002-11-22 22:22:14 +01:00
|
|
|
TRACE_(accel)("handle %p\n", hAccel);
|
2000-08-04 06:21:02 +02:00
|
|
|
if(!hAccel) {
|
|
|
|
ERR_(accel)("Out of memory.\n");
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
2002-12-02 19:10:57 +01:00
|
|
|
return NULL;
|
2000-08-04 06:21:02 +02:00
|
|
|
}
|
2002-08-28 02:39:39 +02:00
|
|
|
accel = GlobalLock16(HACCEL_16(hAccel));
|
2000-08-04 06:21:02 +02:00
|
|
|
for (i=0;i<cEntries;i++) {
|
2004-07-13 01:26:05 +02:00
|
|
|
accel[i].fVirt = lpaccel[i].fVirt&0x7f;
|
|
|
|
accel[i].key = lpaccel[i].key;
|
|
|
|
if( !(accel[i].fVirt & FVIRTKEY) )
|
|
|
|
accel[i].key &= 0x00ff;
|
|
|
|
accel[i].cmd = lpaccel[i].cmd;
|
2000-08-04 06:21:02 +02:00
|
|
|
}
|
|
|
|
/* Set the end-of-table terminator. */
|
|
|
|
accel[cEntries-1].fVirt |= 0x80;
|
|
|
|
|
2003-11-26 23:28:16 +01:00
|
|
|
TRACE_(accel)("Allocated accelerator handle %p with %d entries\n", hAccel,cEntries);
|
2000-08-04 06:21:02 +02:00
|
|
|
return hAccel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-25 23:22:21 +01:00
|
|
|
* CreateAcceleratorTableW (USER32.@)
|
2000-08-04 06:21:02 +02:00
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
2000-08-04 06:21:02 +02:00
|
|
|
*/
|
|
|
|
HACCEL WINAPI CreateAcceleratorTableW(LPACCEL lpaccel, INT cEntries)
|
|
|
|
{
|
|
|
|
HACCEL hAccel;
|
|
|
|
LPACCEL16 accel;
|
|
|
|
int i;
|
2002-06-01 01:06:46 +02:00
|
|
|
char ckey;
|
2000-08-04 06:21:02 +02:00
|
|
|
|
|
|
|
/* Do parameter checking just in case someone's trying to be
|
|
|
|
funny. */
|
|
|
|
if(cEntries < 1) {
|
|
|
|
WARN_(accel)("Application sent invalid parameters (%p %d).\n",
|
|
|
|
lpaccel, cEntries);
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
2002-12-02 19:10:57 +01:00
|
|
|
return NULL;
|
2000-08-04 06:21:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate memory and copy the table. */
|
2002-08-28 02:39:39 +02:00
|
|
|
hAccel = HACCEL_32(GlobalAlloc16(0,cEntries*sizeof(ACCEL16)));
|
2000-08-04 06:21:02 +02:00
|
|
|
|
2002-11-22 22:22:14 +01:00
|
|
|
TRACE_(accel)("handle %p\n", hAccel);
|
2000-08-04 06:21:02 +02:00
|
|
|
if(!hAccel) {
|
|
|
|
ERR_(accel)("Out of memory.\n");
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
2002-12-02 19:10:57 +01:00
|
|
|
return NULL;
|
2000-08-04 06:21:02 +02:00
|
|
|
}
|
2002-08-28 02:39:39 +02:00
|
|
|
accel = GlobalLock16(HACCEL_16(hAccel));
|
2000-08-04 06:21:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
for (i=0;i<cEntries;i++) {
|
2004-07-13 01:26:05 +02:00
|
|
|
accel[i].fVirt = lpaccel[i].fVirt&0x7f;
|
2000-08-04 06:21:02 +02:00
|
|
|
if( !(accel[i].fVirt & FVIRTKEY) ) {
|
|
|
|
ckey = (char) lpaccel[i].key;
|
|
|
|
if(!MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, &ckey, 1, &accel[i].key, 1))
|
2004-01-27 01:01:43 +01:00
|
|
|
WARN_(accel)("Error converting ASCII accelerator table to Unicode\n");
|
2000-08-04 06:21:02 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
else
|
|
|
|
accel[i].key = lpaccel[i].key;
|
2000-08-04 06:21:02 +02:00
|
|
|
accel[i].cmd = lpaccel[i].cmd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the end-of-table terminator. */
|
|
|
|
accel[cEntries-1].fVirt |= 0x80;
|
|
|
|
|
2002-11-22 22:22:14 +01:00
|
|
|
TRACE_(accel)("Allocated accelerator handle %p\n", hAccel);
|
2000-08-04 06:21:02 +02:00
|
|
|
return hAccel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-01-25 23:22:21 +01:00
|
|
|
* DestroyAcceleratorTable [USER32.@]
|
2000-08-04 06:21:02 +02:00
|
|
|
* Destroys an accelerator table
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* By mortene@pvv.org 980321
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* handle [I] Handle to accelerator table
|
|
|
|
*
|
2005-11-09 11:33:40 +01:00
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
2000-08-04 06:21:02 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI DestroyAcceleratorTable( HACCEL handle )
|
|
|
|
{
|
2004-07-12 22:42:30 +02:00
|
|
|
if( !handle )
|
|
|
|
return FALSE;
|
2002-08-28 02:39:39 +02:00
|
|
|
return !GlobalFree16(HACCEL_16(handle));
|
2000-08-04 06:21:02 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-04 06:21:02 +02:00
|
|
|
/**********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* LoadString (USER.176)
|
2000-08-04 06:21:02 +02:00
|
|
|
*/
|
|
|
|
INT16 WINAPI LoadString16( HINSTANCE16 instance, UINT16 resource_id,
|
|
|
|
LPSTR buffer, INT16 buflen )
|
|
|
|
{
|
|
|
|
HGLOBAL16 hmem;
|
|
|
|
HRSRC16 hrsrc;
|
|
|
|
unsigned char *p;
|
|
|
|
int string_num;
|
|
|
|
int i;
|
|
|
|
|
2005-09-12 16:12:46 +02:00
|
|
|
TRACE("inst=%04x id=%04x buff=%p len=%d\n",
|
|
|
|
instance, resource_id, buffer, buflen);
|
2000-08-04 06:21:02 +02:00
|
|
|
|
2005-09-12 16:12:46 +02:00
|
|
|
hrsrc = FindResource16( instance, MAKEINTRESOURCEA((resource_id>>4)+1), (LPSTR)RT_STRING );
|
2000-08-04 06:21:02 +02:00
|
|
|
if (!hrsrc) return 0;
|
|
|
|
hmem = LoadResource16( instance, hrsrc );
|
|
|
|
if (!hmem) return 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-04 06:21:02 +02:00
|
|
|
p = LockResource16(hmem);
|
|
|
|
string_num = resource_id & 0x000f;
|
|
|
|
for (i = 0; i < string_num; i++)
|
|
|
|
p += *p + 1;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-04 06:21:02 +02:00
|
|
|
TRACE("strlen = %d\n", (int)*p );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-04 06:21:02 +02:00
|
|
|
if (buffer == NULL) return *p;
|
|
|
|
i = min(buflen - 1, *p);
|
|
|
|
if (i > 0) {
|
|
|
|
memcpy(buffer, p + 1, i);
|
|
|
|
buffer[i] = '\0';
|
|
|
|
} else {
|
|
|
|
if (buflen > 1) {
|
|
|
|
buffer[0] = '\0';
|
|
|
|
return 0;
|
|
|
|
}
|
2004-01-06 23:08:33 +01:00
|
|
|
WARN("Don't know why caller gave buflen=%d *p=%d trying to obtain string '%s'\n", buflen, *p, p + 1);
|
2000-08-04 06:21:02 +02:00
|
|
|
}
|
|
|
|
FreeResource16( hmem );
|
|
|
|
|
|
|
|
TRACE("'%s' loaded !\n", buffer);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2001-01-25 23:22:21 +01:00
|
|
|
* LoadStringW (USER32.@)
|
2000-08-04 06:21:02 +02:00
|
|
|
*/
|
|
|
|
INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
|
|
|
|
LPWSTR buffer, INT buflen )
|
|
|
|
{
|
|
|
|
HGLOBAL hmem;
|
|
|
|
HRSRC hrsrc;
|
|
|
|
WCHAR *p;
|
|
|
|
int string_num;
|
|
|
|
int i;
|
|
|
|
|
2005-09-12 16:12:46 +02:00
|
|
|
TRACE("instance = %p, id = %04x, buffer = %p, length = %d\n",
|
|
|
|
instance, resource_id, buffer, buflen);
|
2000-08-04 06:21:02 +02:00
|
|
|
|
2008-03-05 21:28:54 +01:00
|
|
|
if(buffer == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2006-09-21 20:47:20 +02:00
|
|
|
/* Use loword (incremented by 1) as resourceid */
|
|
|
|
hrsrc = FindResourceW( instance, MAKEINTRESOURCEW((LOWORD(resource_id) >> 4) + 1),
|
2003-09-10 05:56:47 +02:00
|
|
|
(LPWSTR)RT_STRING );
|
2000-08-04 06:21:02 +02:00
|
|
|
if (!hrsrc) return 0;
|
|
|
|
hmem = LoadResource( instance, hrsrc );
|
|
|
|
if (!hmem) return 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-04 06:21:02 +02:00
|
|
|
p = LockResource(hmem);
|
|
|
|
string_num = resource_id & 0x000f;
|
|
|
|
for (i = 0; i < string_num; i++)
|
|
|
|
p += *p + 1;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-04 06:21:02 +02:00
|
|
|
TRACE("strlen = %d\n", (int)*p );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2008-03-05 21:28:54 +01:00
|
|
|
/*if buflen == 0, then return a read-only pointer to the resource itself in buffer
|
|
|
|
it is assumed that buffer is actually a (LPWSTR *) */
|
|
|
|
if(buflen == 0)
|
|
|
|
{
|
|
|
|
*((LPWSTR *)buffer) = p + 1;
|
|
|
|
return *p;
|
|
|
|
}
|
|
|
|
|
2000-08-04 06:21:02 +02:00
|
|
|
i = min(buflen - 1, *p);
|
|
|
|
if (i > 0) {
|
|
|
|
memcpy(buffer, p + 1, i * sizeof (WCHAR));
|
|
|
|
buffer[i] = (WCHAR) 0;
|
|
|
|
} else {
|
|
|
|
if (buflen > 1) {
|
|
|
|
buffer[0] = (WCHAR) 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("%s loaded !\n", debugstr_w(buffer));
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2001-01-25 23:22:21 +01:00
|
|
|
* LoadStringA (USER32.@)
|
2000-08-04 06:21:02 +02:00
|
|
|
*/
|
2008-03-03 20:06:54 +01:00
|
|
|
INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id, LPSTR buffer, INT buflen )
|
2000-08-04 06:21:02 +02:00
|
|
|
{
|
2008-03-03 20:06:54 +01:00
|
|
|
HGLOBAL hmem;
|
|
|
|
HRSRC hrsrc;
|
|
|
|
DWORD retval = 0;
|
2000-08-04 06:21:02 +02:00
|
|
|
|
2005-09-12 16:12:46 +02:00
|
|
|
TRACE("instance = %p, id = %04x, buffer = %p, length = %d\n",
|
|
|
|
instance, resource_id, buffer, buflen);
|
2000-08-04 06:21:02 +02:00
|
|
|
|
2008-03-03 20:06:54 +01:00
|
|
|
if (!buflen) return -1;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2008-03-03 20:06:54 +01:00
|
|
|
/* Use loword (incremented by 1) as resourceid */
|
|
|
|
if ((hrsrc = FindResourceW( instance, MAKEINTRESOURCEW((LOWORD(resource_id) >> 4) + 1),
|
|
|
|
(LPWSTR)RT_STRING )) &&
|
|
|
|
(hmem = LoadResource( instance, hrsrc )))
|
2000-08-04 06:21:02 +02:00
|
|
|
{
|
2008-03-03 20:06:54 +01:00
|
|
|
const WCHAR *p = LockResource(hmem);
|
|
|
|
unsigned int id = resource_id & 0x000f;
|
|
|
|
|
|
|
|
while (id--) p += *p + 1;
|
2000-08-04 06:21:02 +02:00
|
|
|
|
2008-03-03 20:06:54 +01:00
|
|
|
RtlUnicodeToMultiByteN( buffer, buflen - 1, &retval, p + 1, *p * sizeof(WCHAR) );
|
|
|
|
}
|
|
|
|
buffer[retval] = 0;
|
|
|
|
TRACE("returning %s\n", debugstr_a(buffer));
|
2000-08-04 06:21:02 +02:00
|
|
|
return retval;
|
|
|
|
}
|
2004-04-07 21:41:21 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetGuiResources (USER32.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetGuiResources( HANDLE hProcess, DWORD uiFlags )
|
|
|
|
{
|
2008-09-28 20:47:07 +02:00
|
|
|
static BOOL warn = TRUE;
|
|
|
|
|
|
|
|
if (warn) {
|
|
|
|
FIXME("(%p,%x): stub\n",hProcess,uiFlags);
|
|
|
|
warn = FALSE;
|
|
|
|
}
|
|
|
|
|
2004-04-07 21:41:21 +02:00
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return 0;
|
|
|
|
}
|