1994-10-17 19:12:41 +01:00
|
|
|
/*
|
1996-07-17 22:02:21 +02:00
|
|
|
* PE (Portable Execute) File Resources
|
1994-10-17 19:12:41 +01:00
|
|
|
*
|
1996-07-17 22:02:21 +02:00
|
|
|
* Copyright 1995 Thomas Sandford
|
|
|
|
* Copyright 1996 Martin von Loewis
|
1994-10-17 19:12:41 +01:00
|
|
|
*
|
1996-07-17 22:02:21 +02:00
|
|
|
* Based on the Win16 resource handling code in loader/resource.c
|
|
|
|
* Copyright 1993 Robert J. Amstadt
|
|
|
|
* Copyright 1995 Alexandre Julliard
|
1997-02-02 20:01:52 +01:00
|
|
|
* Copyright 1997 Marcus Meissner
|
1994-10-17 19:12:41 +01:00
|
|
|
*/
|
|
|
|
|
1997-03-05 09:22:35 +01:00
|
|
|
#include <stdlib.h>
|
1994-10-17 19:12:41 +01:00
|
|
|
#include <sys/types.h>
|
2000-09-26 02:39:06 +02:00
|
|
|
|
2000-12-27 05:18:26 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-06-13 03:10:29 +02:00
|
|
|
#include "wine/unicode.h"
|
1999-03-14 17:35:05 +01:00
|
|
|
#include "windef.h"
|
2000-05-05 20:17:52 +02:00
|
|
|
#include "winnls.h"
|
2000-09-26 02:39:06 +02:00
|
|
|
#include "winerror.h"
|
1996-07-17 22:02:21 +02:00
|
|
|
#include "module.h"
|
1996-12-22 19:27:48 +01:00
|
|
|
#include "heap.h"
|
1996-07-17 22:02:21 +02:00
|
|
|
#include "stackframe.h"
|
1999-06-12 17:45:58 +02:00
|
|
|
#include "debugtools.h"
|
1994-10-17 19:12:41 +01:00
|
|
|
|
2000-09-26 02:39:06 +02:00
|
|
|
DEFAULT_DEBUG_CHANNEL(resource);
|
|
|
|
|
1997-02-02 20:01:52 +01:00
|
|
|
/**********************************************************************
|
2000-08-07 06:12:41 +02:00
|
|
|
* get_resdir
|
1997-02-02 20:01:52 +01:00
|
|
|
*
|
2000-08-07 06:12:41 +02:00
|
|
|
* Get the resource directory of a PE module
|
1997-02-02 20:01:52 +01:00
|
|
|
*/
|
2000-10-19 22:29:53 +02:00
|
|
|
static const IMAGE_RESOURCE_DIRECTORY* get_resdir( HMODULE hmod )
|
2000-08-07 06:12:41 +02:00
|
|
|
{
|
2000-10-19 22:29:53 +02:00
|
|
|
const IMAGE_DATA_DIRECTORY *dir;
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY *ret = NULL;
|
2000-08-07 06:12:41 +02:00
|
|
|
|
|
|
|
if (!hmod) hmod = GetModuleHandleA( NULL );
|
2000-09-26 02:39:06 +02:00
|
|
|
else if (!HIWORD(hmod))
|
|
|
|
{
|
|
|
|
FIXME("Enumeration of 16-bit resources is not supported\n");
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return NULL;
|
|
|
|
}
|
2000-08-07 06:12:41 +02:00
|
|
|
dir = &PE_HEADER(hmod)->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE];
|
|
|
|
if (dir->Size && dir->VirtualAddress)
|
|
|
|
ret = (IMAGE_RESOURCE_DIRECTORY *)((char *)hmod + dir->VirtualAddress);
|
|
|
|
return ret;
|
1997-02-02 20:01:52 +01:00
|
|
|
}
|
1994-10-17 19:12:41 +01:00
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
|
2000-10-19 22:29:53 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* find_entry_by_id
|
|
|
|
*
|
|
|
|
* Find an entry by id in a resource directory
|
|
|
|
*/
|
2000-10-24 23:35:14 +02:00
|
|
|
static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_id( const IMAGE_RESOURCE_DIRECTORY *dir,
|
|
|
|
WORD id, const void *root )
|
2000-10-19 22:29:53 +02:00
|
|
|
{
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry;
|
|
|
|
int min, max, pos;
|
|
|
|
|
|
|
|
entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
|
|
|
|
min = dir->NumberOfNamedEntries;
|
|
|
|
max = min + dir->NumberOfIdEntries - 1;
|
|
|
|
while (min <= max)
|
|
|
|
{
|
|
|
|
pos = (min + max) / 2;
|
2000-12-19 04:38:53 +01:00
|
|
|
if (entry[pos].u1.s2.Id == id)
|
2000-12-20 00:31:52 +01:00
|
|
|
return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].u2.s3.OffsetToDirectory);
|
2000-12-19 04:38:53 +01:00
|
|
|
if (entry[pos].u1.s2.Id > id) max = pos - 1;
|
2000-10-19 22:29:53 +02:00
|
|
|
else min = pos + 1;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-10-24 23:35:14 +02:00
|
|
|
* find_entry_by_nameW
|
2000-10-19 22:29:53 +02:00
|
|
|
*
|
2000-10-24 23:35:14 +02:00
|
|
|
* Find an entry by name in a resource directory
|
2000-10-19 22:29:53 +02:00
|
|
|
*/
|
2000-10-24 23:35:14 +02:00
|
|
|
static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_nameW( const IMAGE_RESOURCE_DIRECTORY *dir,
|
|
|
|
LPCWSTR name, const void *root )
|
2000-10-19 22:29:53 +02:00
|
|
|
{
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry;
|
2000-10-24 23:35:14 +02:00
|
|
|
const IMAGE_RESOURCE_DIR_STRING_U *str;
|
|
|
|
int min, max, res, pos, namelen;
|
|
|
|
|
|
|
|
if (!HIWORD(name)) return find_entry_by_id( dir, LOWORD(name), root );
|
|
|
|
if (name[0] == '#')
|
|
|
|
{
|
|
|
|
char buf[16];
|
|
|
|
if (!WideCharToMultiByte( CP_ACP, 0, name+1, -1, buf, sizeof(buf), NULL, NULL ))
|
|
|
|
return NULL;
|
|
|
|
return find_entry_by_id( dir, atoi(buf), root );
|
|
|
|
}
|
2000-10-19 22:29:53 +02:00
|
|
|
|
|
|
|
entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
|
2000-10-24 23:35:14 +02:00
|
|
|
namelen = strlenW(name);
|
|
|
|
min = 0;
|
|
|
|
max = dir->NumberOfNamedEntries - 1;
|
|
|
|
while (min <= max)
|
|
|
|
{
|
|
|
|
pos = (min + max) / 2;
|
2000-11-10 23:34:39 +01:00
|
|
|
str = (IMAGE_RESOURCE_DIR_STRING_U *)((char *)root + entry[pos].u1.s1.NameOffset);
|
2000-10-24 23:35:14 +02:00
|
|
|
res = strncmpiW( name, str->NameString, str->Length );
|
|
|
|
if (!res && namelen == str->Length)
|
2000-12-20 00:31:52 +01:00
|
|
|
return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].u2.s3.OffsetToDirectory);
|
2000-10-24 23:35:14 +02:00
|
|
|
if (res < 0) max = pos - 1;
|
|
|
|
else min = pos + 1;
|
|
|
|
}
|
2000-10-19 22:29:53 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-07-17 22:02:21 +02:00
|
|
|
/**********************************************************************
|
2000-10-24 23:35:14 +02:00
|
|
|
* find_entry_by_nameA
|
1996-07-17 22:02:21 +02:00
|
|
|
*
|
2000-10-24 23:35:14 +02:00
|
|
|
* Find an entry by name in a resource directory
|
1996-07-17 22:02:21 +02:00
|
|
|
*/
|
2000-10-24 23:35:14 +02:00
|
|
|
static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_nameA( const IMAGE_RESOURCE_DIRECTORY *dir,
|
|
|
|
LPCSTR name, const void *root )
|
1996-07-17 22:02:21 +02:00
|
|
|
{
|
2000-10-24 23:35:14 +02:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *ret = NULL;
|
|
|
|
LPWSTR nameW;
|
|
|
|
|
|
|
|
if (!HIWORD(name)) return find_entry_by_id( dir, LOWORD(name), root );
|
|
|
|
if (name[0] == '#')
|
2000-10-19 22:29:53 +02:00
|
|
|
{
|
2000-10-24 23:35:14 +02:00
|
|
|
return find_entry_by_id( dir, atoi(name+1), root );
|
2000-10-19 22:29:53 +02:00
|
|
|
}
|
2000-10-24 23:35:14 +02:00
|
|
|
|
|
|
|
if ((nameW = HEAP_strdupAtoW( GetProcessHeap(), 0, name )))
|
2000-10-19 22:29:53 +02:00
|
|
|
{
|
2000-10-24 23:35:14 +02:00
|
|
|
ret = find_entry_by_nameW( dir, nameW, root );
|
|
|
|
HeapFree( GetProcessHeap(), 0, nameW );
|
1996-07-17 22:02:21 +02:00
|
|
|
}
|
2000-10-24 23:35:14 +02:00
|
|
|
return ret;
|
1994-10-17 19:12:41 +01:00
|
|
|
}
|
|
|
|
|
2000-10-24 23:35:14 +02:00
|
|
|
|
1999-01-31 11:13:13 +01:00
|
|
|
/**********************************************************************
|
2000-10-24 23:35:14 +02:00
|
|
|
* find_entry_default
|
|
|
|
*
|
|
|
|
* Find a default entry in a resource directory
|
1999-01-31 11:13:13 +01:00
|
|
|
*/
|
2000-10-24 23:35:14 +02:00
|
|
|
static const IMAGE_RESOURCE_DIRECTORY *find_entry_default( const IMAGE_RESOURCE_DIRECTORY *dir,
|
|
|
|
const void *root )
|
1999-01-31 11:13:13 +01:00
|
|
|
{
|
2000-10-24 23:35:14 +02:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry;
|
1999-01-31 11:13:13 +01:00
|
|
|
|
2000-10-24 23:35:14 +02:00
|
|
|
entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
|
2000-12-20 00:31:52 +01:00
|
|
|
return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry->u2.s3.OffsetToDirectory);
|
1999-01-31 11:13:13 +01:00
|
|
|
}
|
|
|
|
|
2000-10-24 23:35:14 +02:00
|
|
|
|
1996-07-17 22:02:21 +02:00
|
|
|
/**********************************************************************
|
2000-08-07 06:12:41 +02:00
|
|
|
* PE_FindResourceExW
|
2000-08-11 14:50:56 +02:00
|
|
|
*
|
|
|
|
* FindResourceExA/W does search in the following order:
|
|
|
|
* 1. Exact specified language
|
|
|
|
* 2. Language with neutral sublanguage
|
|
|
|
* 3. Neutral language with neutral sublanguage
|
|
|
|
* 4. Neutral language with default sublanguage
|
1996-07-17 22:02:21 +02:00
|
|
|
*/
|
2000-08-11 14:50:56 +02:00
|
|
|
HRSRC PE_FindResourceExW( HMODULE hmod, LPCWSTR name, LPCWSTR type, WORD lang )
|
2000-08-07 06:12:41 +02:00
|
|
|
{
|
2000-10-19 22:29:53 +02:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdirptr = get_resdir(hmod);
|
|
|
|
const void *root;
|
2000-08-11 14:50:56 +02:00
|
|
|
HRSRC result;
|
1994-10-17 19:12:41 +01:00
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
if (!resdirptr) return 0;
|
1996-07-17 22:02:21 +02:00
|
|
|
|
2000-10-19 22:29:53 +02:00
|
|
|
root = resdirptr;
|
2000-10-24 23:35:14 +02:00
|
|
|
if (!(resdirptr = find_entry_by_nameW(resdirptr, type, root))) return 0;
|
|
|
|
if (!(resdirptr = find_entry_by_nameW(resdirptr, name, root))) return 0;
|
2000-08-11 14:50:56 +02:00
|
|
|
|
|
|
|
/* 1. Exact specified language */
|
2000-10-19 22:29:53 +02:00
|
|
|
if ((result = (HRSRC)find_entry_by_id( resdirptr, lang, root ))) goto found;
|
2000-05-05 20:17:52 +02:00
|
|
|
|
2000-10-19 22:29:53 +02:00
|
|
|
/* 2. Language with neutral sublanguage */
|
|
|
|
lang = MAKELANGID(PRIMARYLANGID(lang), SUBLANG_NEUTRAL);
|
|
|
|
if ((result = (HRSRC)find_entry_by_id( resdirptr, lang, root ))) goto found;
|
2000-08-11 14:50:56 +02:00
|
|
|
|
2000-10-19 22:29:53 +02:00
|
|
|
/* 3. Neutral language with neutral sublanguage */
|
|
|
|
lang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);
|
|
|
|
if ((result = (HRSRC)find_entry_by_id( resdirptr, lang, root ))) goto found;
|
2000-08-11 14:50:56 +02:00
|
|
|
|
2000-10-19 22:29:53 +02:00
|
|
|
/* 4. Neutral language with default sublanguage */
|
|
|
|
lang = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
|
|
|
|
result = (HRSRC)find_entry_by_id( resdirptr, lang, root );
|
2000-08-11 14:50:56 +02:00
|
|
|
|
2000-10-19 22:29:53 +02:00
|
|
|
found:
|
2000-08-11 14:50:56 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* PE_FindResourceW
|
|
|
|
*
|
|
|
|
* Load[String]/[Icon]/[Menu]/[etc.] does use FindResourceA/W.
|
|
|
|
* FindResourceA/W does search in the following order:
|
|
|
|
* 1. Neutral language with neutral sublanguage
|
|
|
|
* 2. Neutral language with default sublanguage
|
|
|
|
* 3. Current locale lang id
|
|
|
|
* 4. Current locale lang id with neutral sublanguage
|
|
|
|
* 5. (!) LANG_ENGLISH, SUBLANG_DEFAULT
|
|
|
|
* 6. Return first in the list
|
|
|
|
*/
|
|
|
|
HRSRC PE_FindResourceW( HMODULE hmod, LPCWSTR name, LPCWSTR type )
|
|
|
|
{
|
2000-10-19 22:29:53 +02:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdirptr = get_resdir(hmod);
|
|
|
|
const void *root;
|
2000-08-11 14:50:56 +02:00
|
|
|
HRSRC result;
|
|
|
|
WORD lang;
|
|
|
|
|
|
|
|
if (!resdirptr) return 0;
|
|
|
|
|
2000-10-19 22:29:53 +02:00
|
|
|
root = resdirptr;
|
2000-10-24 23:35:14 +02:00
|
|
|
if (!(resdirptr = find_entry_by_nameW(resdirptr, type, root))) return 0;
|
|
|
|
if (!(resdirptr = find_entry_by_nameW(resdirptr, name, root))) return 0;
|
2000-08-11 14:50:56 +02:00
|
|
|
|
|
|
|
/* 1. Neutral language with neutral sublanguage */
|
|
|
|
lang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);
|
2000-10-19 22:29:53 +02:00
|
|
|
if ((result = (HRSRC)find_entry_by_id( resdirptr, lang, root ))) goto found;
|
2000-08-11 14:50:56 +02:00
|
|
|
|
2000-10-19 22:29:53 +02:00
|
|
|
/* 2. Neutral language with default sublanguage */
|
|
|
|
lang = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
|
|
|
|
if ((result = (HRSRC)find_entry_by_id( resdirptr, lang, root ))) goto found;
|
2000-08-11 14:50:56 +02:00
|
|
|
|
2000-10-19 22:29:53 +02:00
|
|
|
/* 3. Current locale lang id */
|
|
|
|
lang = LANGIDFROMLCID(GetUserDefaultLCID());
|
|
|
|
if ((result = (HRSRC)find_entry_by_id( resdirptr, lang, root ))) goto found;
|
2000-08-11 14:50:56 +02:00
|
|
|
|
2000-10-19 22:29:53 +02:00
|
|
|
/* 4. Current locale lang id with neutral sublanguage */
|
|
|
|
lang = MAKELANGID(PRIMARYLANGID(lang), SUBLANG_NEUTRAL);
|
|
|
|
if ((result = (HRSRC)find_entry_by_id( resdirptr, lang, root ))) goto found;
|
2000-08-11 14:50:56 +02:00
|
|
|
|
2000-10-19 22:29:53 +02:00
|
|
|
/* 5. (!) LANG_ENGLISH, SUBLANG_DEFAULT */
|
|
|
|
lang = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
|
|
|
|
if ((result = (HRSRC)find_entry_by_id( resdirptr, lang, root ))) goto found;
|
2000-08-11 14:50:56 +02:00
|
|
|
|
2000-10-19 22:29:53 +02:00
|
|
|
/* 6. Return first in the list */
|
|
|
|
result = (HRSRC)find_entry_default( resdirptr, root );
|
2000-08-11 14:50:56 +02:00
|
|
|
|
2000-10-19 22:29:53 +02:00
|
|
|
found:
|
1996-07-17 22:02:21 +02:00
|
|
|
return result;
|
1994-10-17 19:12:41 +01:00
|
|
|
}
|
|
|
|
|
1996-07-17 22:02:21 +02:00
|
|
|
|
1994-10-17 19:12:41 +01:00
|
|
|
/**********************************************************************
|
2000-08-07 06:12:41 +02:00
|
|
|
* PE_LoadResource
|
1994-10-17 19:12:41 +01:00
|
|
|
*/
|
2000-12-24 21:33:01 +01:00
|
|
|
HGLOBAL PE_LoadResource( HMODULE hmod, HRSRC hRsrc )
|
1994-10-17 19:12:41 +01:00
|
|
|
{
|
2000-08-07 06:12:41 +02:00
|
|
|
if (!hRsrc) return 0;
|
|
|
|
return (HANDLE)(hmod + ((PIMAGE_RESOURCE_DATA_ENTRY)hRsrc)->OffsetToData);
|
1997-02-02 20:01:52 +01:00
|
|
|
}
|
|
|
|
|
1996-07-17 22:02:21 +02:00
|
|
|
|
1997-02-02 20:01:52 +01:00
|
|
|
/**********************************************************************
|
2000-08-08 01:50:00 +02:00
|
|
|
* PE_SizeofResource
|
1997-02-02 20:01:52 +01:00
|
|
|
*/
|
2000-12-24 21:33:01 +01:00
|
|
|
DWORD PE_SizeofResource( HRSRC hRsrc )
|
1997-02-02 20:01:52 +01:00
|
|
|
{
|
2000-08-08 01:50:00 +02:00
|
|
|
if (!hRsrc) return 0;
|
1998-10-16 11:30:33 +02:00
|
|
|
return ((PIMAGE_RESOURCE_DATA_ENTRY)hRsrc)->Size;
|
1997-02-02 20:01:52 +01:00
|
|
|
}
|
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
|
1997-02-02 20:01:52 +01:00
|
|
|
/**********************************************************************
|
2000-08-07 06:12:41 +02:00
|
|
|
* EnumResourceTypesA (KERNEL32.90)
|
1997-02-02 20:01:52 +01:00
|
|
|
*/
|
2000-08-07 06:12:41 +02:00
|
|
|
BOOL WINAPI EnumResourceTypesA( HMODULE hmod, ENUMRESTYPEPROCA lpfun, LONG lparam)
|
|
|
|
{
|
1997-02-02 20:01:52 +01:00
|
|
|
int i;
|
2000-10-19 22:29:53 +02:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdir = get_resdir(hmod);
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *et;
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL ret;
|
1997-02-02 20:01:52 +01:00
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
if (!resdir) return FALSE;
|
1997-02-02 20:01:52 +01:00
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)(resdir + 1);
|
1997-02-02 20:01:52 +01:00
|
|
|
ret = FALSE;
|
|
|
|
for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
|
2000-08-20 05:32:57 +02:00
|
|
|
LPSTR type;
|
|
|
|
|
2000-11-10 23:34:39 +01:00
|
|
|
if (et[i].u1.s1.NameIsString)
|
2000-08-20 05:32:57 +02:00
|
|
|
{
|
2000-11-10 23:34:39 +01:00
|
|
|
PIMAGE_RESOURCE_DIR_STRING_U pResString = (PIMAGE_RESOURCE_DIR_STRING_U) ((LPBYTE) resdir + et[i].u1.s1.NameOffset);
|
2000-08-20 05:32:57 +02:00
|
|
|
DWORD len = WideCharToMultiByte( CP_ACP, 0, pResString->NameString, pResString->Length,
|
|
|
|
NULL, 0, NULL, NULL);
|
|
|
|
if (!(type = HeapAlloc(GetProcessHeap(), 0, len + 1)))
|
|
|
|
return FALSE;
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, pResString->NameString, pResString->Length,
|
|
|
|
type, len, NULL, NULL);
|
|
|
|
type[len] = '\0';
|
|
|
|
ret = lpfun(hmod,type,lparam);
|
|
|
|
HeapFree(GetProcessHeap(), 0, type);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-12-19 04:38:53 +01:00
|
|
|
type = (LPSTR)(int)et[i].u1.s2.Id;
|
2000-08-20 05:32:57 +02:00
|
|
|
ret = lpfun(hmod,type,lparam);
|
|
|
|
}
|
1997-02-02 20:01:52 +01:00
|
|
|
if (!ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
|
1997-02-02 20:01:52 +01:00
|
|
|
/**********************************************************************
|
2000-08-07 06:12:41 +02:00
|
|
|
* EnumResourceTypesW (KERNEL32.91)
|
1997-02-02 20:01:52 +01:00
|
|
|
*/
|
2000-08-07 06:12:41 +02:00
|
|
|
BOOL WINAPI EnumResourceTypesW( HMODULE hmod, ENUMRESTYPEPROCW lpfun, LONG lparam)
|
|
|
|
{
|
1997-02-02 20:01:52 +01:00
|
|
|
int i;
|
2000-10-19 22:29:53 +02:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdir = get_resdir(hmod);
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *et;
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL ret;
|
1997-02-02 20:01:52 +01:00
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
if (!resdir) return FALSE;
|
1997-02-02 20:01:52 +01:00
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)(resdir + 1);
|
1997-02-02 20:01:52 +01:00
|
|
|
ret = FALSE;
|
|
|
|
for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
|
|
|
|
LPWSTR type;
|
|
|
|
|
2000-11-10 23:34:39 +01:00
|
|
|
if (et[i].u1.s1.NameIsString)
|
2000-08-20 05:32:57 +02:00
|
|
|
{
|
2000-11-10 23:34:39 +01:00
|
|
|
PIMAGE_RESOURCE_DIR_STRING_U pResString = (PIMAGE_RESOURCE_DIR_STRING_U) ((LPBYTE) resdir + et[i].u1.s1.NameOffset);
|
2000-08-20 05:32:57 +02:00
|
|
|
if (!(type = HeapAlloc(GetProcessHeap(), 0, (pResString->Length+1) * sizeof (WCHAR))))
|
|
|
|
return FALSE;
|
|
|
|
memcpy(type, pResString->NameString, pResString->Length * sizeof (WCHAR));
|
|
|
|
type[pResString->Length] = '\0';
|
|
|
|
ret = lpfun(hmod,type,lparam);
|
|
|
|
HeapFree(GetProcessHeap(), 0, type);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-12-19 04:38:53 +01:00
|
|
|
type = (LPWSTR)(int)et[i].u1.s2.Id;
|
2000-08-20 05:32:57 +02:00
|
|
|
ret = lpfun(hmod,type,lparam);
|
|
|
|
}
|
1997-02-02 20:01:52 +01:00
|
|
|
if (!ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
|
1997-02-02 20:01:52 +01:00
|
|
|
/**********************************************************************
|
2000-08-07 06:12:41 +02:00
|
|
|
* EnumResourceNamesA (KERNEL32.88)
|
1997-02-02 20:01:52 +01:00
|
|
|
*/
|
2000-08-07 06:12:41 +02:00
|
|
|
BOOL WINAPI EnumResourceNamesA( HMODULE hmod, LPCSTR type, ENUMRESNAMEPROCA lpfun, LONG lparam )
|
|
|
|
{
|
1997-02-02 20:01:52 +01:00
|
|
|
int i;
|
2000-10-19 22:29:53 +02:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *basedir = get_resdir(hmod);
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdir;
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *et;
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL ret;
|
1997-02-02 20:01:52 +01:00
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
if (!basedir) return FALSE;
|
|
|
|
|
2000-10-24 23:35:14 +02:00
|
|
|
if (!(resdir = find_entry_by_nameA( basedir, type, basedir ))) return FALSE;
|
2000-08-20 05:32:57 +02:00
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)(resdir + 1);
|
1997-02-02 20:01:52 +01:00
|
|
|
ret = FALSE;
|
|
|
|
for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
|
2000-08-20 05:32:57 +02:00
|
|
|
LPSTR name;
|
|
|
|
|
2000-11-10 23:34:39 +01:00
|
|
|
if (et[i].u1.s1.NameIsString)
|
2000-08-20 05:32:57 +02:00
|
|
|
{
|
2000-11-10 23:34:39 +01:00
|
|
|
PIMAGE_RESOURCE_DIR_STRING_U pResString = (PIMAGE_RESOURCE_DIR_STRING_U) ((LPBYTE) basedir + et[i].u1.s1.NameOffset);
|
2000-08-20 05:32:57 +02:00
|
|
|
DWORD len = WideCharToMultiByte(CP_ACP, 0, pResString->NameString, pResString->Length,
|
|
|
|
NULL, 0, NULL, NULL);
|
|
|
|
if (!(name = HeapAlloc(GetProcessHeap(), 0, len + 1 )))
|
|
|
|
return FALSE;
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, pResString->NameString, pResString->Length,
|
|
|
|
name, len, NULL, NULL );
|
|
|
|
name[len] = '\0';
|
|
|
|
ret = lpfun(hmod,type,name,lparam);
|
|
|
|
HeapFree( GetProcessHeap(), 0, name );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-12-19 04:38:53 +01:00
|
|
|
name = (LPSTR)(int)et[i].u1.s2.Id;
|
2000-08-20 05:32:57 +02:00
|
|
|
ret = lpfun(hmod,type,name,lparam);
|
|
|
|
}
|
1997-02-02 20:01:52 +01:00
|
|
|
if (!ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
|
1997-02-02 20:01:52 +01:00
|
|
|
/**********************************************************************
|
2000-08-07 06:12:41 +02:00
|
|
|
* EnumResourceNamesW (KERNEL32.89)
|
1997-02-02 20:01:52 +01:00
|
|
|
*/
|
2000-08-07 06:12:41 +02:00
|
|
|
BOOL WINAPI EnumResourceNamesW( HMODULE hmod, LPCWSTR type, ENUMRESNAMEPROCW lpfun, LONG lparam )
|
|
|
|
{
|
1997-02-02 20:01:52 +01:00
|
|
|
int i;
|
2000-10-19 22:29:53 +02:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *basedir = get_resdir(hmod);
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdir;
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *et;
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL ret;
|
1997-02-02 20:01:52 +01:00
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
if (!basedir) return FALSE;
|
1997-02-02 20:01:52 +01:00
|
|
|
|
2000-10-24 23:35:14 +02:00
|
|
|
if (!(resdir = find_entry_by_nameW( basedir, type, basedir ))) return FALSE;
|
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
et = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(resdir + 1);
|
1997-02-02 20:01:52 +01:00
|
|
|
ret = FALSE;
|
|
|
|
for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
|
2000-08-20 05:32:57 +02:00
|
|
|
LPWSTR name;
|
|
|
|
|
2000-11-10 23:34:39 +01:00
|
|
|
if (et[i].u1.s1.NameIsString)
|
2000-08-20 05:32:57 +02:00
|
|
|
{
|
2000-11-10 23:34:39 +01:00
|
|
|
PIMAGE_RESOURCE_DIR_STRING_U pResString = (PIMAGE_RESOURCE_DIR_STRING_U) ((LPBYTE) basedir + et[i].u1.s1.NameOffset);
|
2000-08-20 05:32:57 +02:00
|
|
|
if (!(name = HeapAlloc(GetProcessHeap(), 0, (pResString->Length + 1) * sizeof (WCHAR))))
|
|
|
|
return FALSE;
|
|
|
|
memcpy(name, pResString->NameString, pResString->Length * sizeof (WCHAR));
|
|
|
|
name[pResString->Length] = '\0';
|
|
|
|
ret = lpfun(hmod,type,name,lparam);
|
|
|
|
HeapFree(GetProcessHeap(), 0, name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-12-19 04:38:53 +01:00
|
|
|
name = (LPWSTR)(int)et[i].u1.s2.Id;
|
2000-08-20 05:32:57 +02:00
|
|
|
ret = lpfun(hmod,type,name,lparam);
|
|
|
|
}
|
1997-02-02 20:01:52 +01:00
|
|
|
if (!ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
|
1997-02-02 20:01:52 +01:00
|
|
|
/**********************************************************************
|
2000-08-07 06:12:41 +02:00
|
|
|
* EnumResourceLanguagesA (KERNEL32.86)
|
1997-02-02 20:01:52 +01:00
|
|
|
*/
|
2000-08-07 06:12:41 +02:00
|
|
|
BOOL WINAPI EnumResourceLanguagesA( HMODULE hmod, LPCSTR type, LPCSTR name,
|
|
|
|
ENUMRESLANGPROCA lpfun, LONG lparam )
|
|
|
|
{
|
1997-02-02 20:01:52 +01:00
|
|
|
int i;
|
2000-10-19 22:29:53 +02:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *basedir = get_resdir(hmod);
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdir;
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *et;
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL ret;
|
1997-02-02 20:01:52 +01:00
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
if (!basedir) return FALSE;
|
2000-10-24 23:35:14 +02:00
|
|
|
if (!(resdir = find_entry_by_nameA( basedir, type, basedir ))) return FALSE;
|
|
|
|
if (!(resdir = find_entry_by_nameA( resdir, name, basedir ))) return FALSE;
|
2000-08-07 06:12:41 +02:00
|
|
|
|
|
|
|
et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)(resdir + 1);
|
1997-02-02 20:01:52 +01:00
|
|
|
ret = FALSE;
|
|
|
|
for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
|
2000-08-20 05:32:57 +02:00
|
|
|
/* languages are just ids... I hope */
|
2000-12-19 04:38:53 +01:00
|
|
|
ret = lpfun(hmod,type,name,et[i].u1.s2.Id,lparam);
|
1997-02-02 20:01:52 +01:00
|
|
|
if (!ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
|
1997-02-02 20:01:52 +01:00
|
|
|
/**********************************************************************
|
2000-08-07 06:12:41 +02:00
|
|
|
* EnumResourceLanguagesW (KERNEL32.87)
|
1997-02-02 20:01:52 +01:00
|
|
|
*/
|
2000-08-07 06:12:41 +02:00
|
|
|
BOOL WINAPI EnumResourceLanguagesW( HMODULE hmod, LPCWSTR type, LPCWSTR name,
|
|
|
|
ENUMRESLANGPROCW lpfun, LONG lparam )
|
|
|
|
{
|
1997-02-02 20:01:52 +01:00
|
|
|
int i;
|
2000-10-19 22:29:53 +02:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *basedir = get_resdir(hmod);
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdir;
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *et;
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL ret;
|
1997-02-02 20:01:52 +01:00
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
if (!basedir) return FALSE;
|
1997-02-02 20:01:52 +01:00
|
|
|
|
2000-10-24 23:35:14 +02:00
|
|
|
if (!(resdir = find_entry_by_nameW( basedir, type, basedir ))) return FALSE;
|
|
|
|
if (!(resdir = find_entry_by_nameW( resdir, name, basedir ))) return FALSE;
|
|
|
|
|
2000-08-07 06:12:41 +02:00
|
|
|
et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)(resdir + 1);
|
1997-02-02 20:01:52 +01:00
|
|
|
ret = FALSE;
|
|
|
|
for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
|
2000-12-19 04:38:53 +01:00
|
|
|
ret = lpfun(hmod,type,name,et[i].u1.s2.Id,lparam);
|
1997-02-02 20:01:52 +01:00
|
|
|
if (!ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
1994-10-17 19:12:41 +01:00
|
|
|
}
|