1994-10-17 18:12:41 +00:00
|
|
|
/*
|
1996-07-17 20:02:21 +00:00
|
|
|
* PE (Portable Execute) File Resources
|
1994-10-17 18:12:41 +00:00
|
|
|
*
|
1996-07-17 20:02:21 +00:00
|
|
|
* Copyright 1995 Thomas Sandford
|
|
|
|
* Copyright 1996 Martin von Loewis
|
1994-10-17 18:12:41 +00:00
|
|
|
*
|
1996-07-17 20:02:21 +00:00
|
|
|
* Based on the Win16 resource handling code in loader/resource.c
|
|
|
|
* Copyright 1993 Robert J. Amstadt
|
|
|
|
* Copyright 1995 Alexandre Julliard
|
1997-02-02 19:01:52 +00:00
|
|
|
* Copyright 1997 Marcus Meissner
|
1994-10-17 18:12:41 +00:00
|
|
|
*/
|
|
|
|
|
1997-03-05 08:22:35 +00:00
|
|
|
#include <stdlib.h>
|
1994-10-17 18:12:41 +00:00
|
|
|
#include <sys/types.h>
|
2000-09-26 00:39:06 +00:00
|
|
|
|
2000-06-13 01:10:29 +00:00
|
|
|
#include "wine/unicode.h"
|
1999-03-14 16:35:05 +00:00
|
|
|
#include "windef.h"
|
2000-05-05 18:17:52 +00:00
|
|
|
#include "winnls.h"
|
2000-09-26 00:39:06 +00:00
|
|
|
#include "winerror.h"
|
1996-07-17 20:02:21 +00:00
|
|
|
#include "module.h"
|
1996-12-22 18:27:48 +00:00
|
|
|
#include "heap.h"
|
Release 970914
Thu Sep 11 18:24:56 1997 Philippe De Muyter <phdm@info.ucl.ac.be>
* [objects/dc.c]
In DC_SetupGCForPatBlt, replace R2_NOT by GXxor with (black xor white).
Tue Sep 9 23:04:02 1997 U. Bonnes <bon@elektron.ikp.physik.th-darmstadt.de>
* [memory/virtual.c]
Do not write debugging info unconditionally to stderr.
* [files/profile.c]
Call PROFILE_GetSection in PROFILE_GetString for key_name "" too.
* [misc/crtdll.c]
Many new functions.
* [include/windows.h] [windows/winpos.c]
ClientToScreen16 doesn't have a return value.
Sun Sep 7 10:06:39 1997 Alexandre Julliard <julliard@lrc.epfl.ch>
* [misc/main.c] [AUTHORS]
Update the list of contributors. Please let me know if I forgot
someone.
* [if1632/*.spec] [if1632/builtin.c] [tools/build.c]
Ordinal base for Win32 DLLs is now computed automatically from the
lowest ordinal found.
* [include/wintypes.h]
WINAPI is now defined as attribute((stdcall)). This will require
gcc to compile.
* [if1632/thunk.c]
Removed Win32 thunks (no longer needed with stdcall).
* [if1632/crtdll.spec] [misc/crtdll.c]
Make sure we only reference cdecl functions in the spec file.
* [objects/dc.c]
Use CapNotLast drawing style for 1-pixel wide lines.
* [tools/build.c]
Added 'double' argument type.
Added 'varargs' function type for Win32.
Made CallTo16_xxx functions stdcall.
Fri Sep 5 14:50:49 1997 Alex Korobka <alex@trantor.pharm.sunysb.edu>
* [tools/build.c] [windows/win.c] [windows/event.c] [windows/message.c]
More fixes to get message exchange closer to the original.
* [misc/spy.c]
Message logs now contain window names.
* [loader/resource.c] [loader/ne_resource.c] [loader/task.c]
[objects/cursoricon.c] [windows/user.c]
Added some obscure features to fix memory leaks.
Fri Sep 5 00:46:28 1997 Jan Willamowius <jan@janhh.shnet.org>
* [if1632/kernel32.spec] [win32/newfns.c]
Added stub for UTRegister() and UTUnRegister().
Thu Sep 4 12:03:12 1997 Frans van Dorsselaer <dorssel@rulhmpc49.LeidenUniv.nl>
* [controls/edit.c]
Allow ASCII codes > 127 in WM_CHAR.
Mon Sep 1 17:23:24 1997 Dimitrie O. Paun <dimi@mail.cs.toronto.edu>
* [controls/widgets.c]
In InitCommonControls, remember the name of the class
because lpszClassName was made to point to a local array
Added the ProgressBar to the list of implemented controls.
Call InitCommonControls from WIDGETS_Init to register all
implemented Common Controls.
* [include/commctrl.h]
Added misc decl for the Progress Bar.
* [controls/progress.c] [include/progress.h]
First attempt at implementiong the Progress Bar class.
* [objects/brush.h]
Implementation for GetSysColorBrush[16|32]
* [controls/status.c]
Use DrawEdge to draw the borders and fill the background
* [controls/uitools.c]
Added DrawDiagEdge32 and DrawRectEdge32
* [graphics/painting.c]
Implement DrawEdge[16|32]
Started DrawFrameControl32
Mon Sep 1 10:07:09 1997 Lawson Whitney <lawson_whitney@juno.com>
* [misc/comm.c] [include/windows.h]
SetCommEventMask returns a SEGPTR.
Sun Aug 31 23:28:32 1997 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
* [loader/pe_image.c][loader/module.c][include/pe_image.h]
[include/module.h]
Cleaned up the whole Win32 library mess (a bit).
* [debugger/stabs.c]
If 'wine' has no absolute path and isn't found, check $PATH too.
* [misc/ole2nls.c]
Some fixes.
* [misc/ver.c]
Added support for PE style version resources.
* [memory/string.c]
Check for NULL pointers to _lstr* functions, just as Windows95 does.
* [multimedia/time.c]
Made list of timers a simple linked list.
* [loader/resource.c]
Netscape 3 seems to pass NEGATIVE resource Ids (in an
unsigned int, yes). Don't know why, fixed it anyway.
* [objects/bitmap.c]
LoadImageW added.
* [include/win.h][windows/win.c]
Change wIDmenu from UINT16 to UINT32 and changed the
SetWindow(Long|Word) accordingly.
Thu Aug 28 19:30:08 1997 Morten Welinder <terra@diku.dk>
* [include/windows.h]
Add a few more colors defined for Win95.
Add a few more brush styles.
* [windows/syscolor.c]
Add error checks for SYSCOLOR_SetColor, SYSCOLOR_Init,
GetSysColor16, GetSysColor32. Add support for above colors.
Sun Aug 24 16:22:57 1997 Andrew Taylor <andrew@riscan.com>
* [multimedia/mmsystem.c]
Changed mmioDescend to use mmio functions for file I/O, neccessary
for memory files.
1997-09-14 17:17:23 +00:00
|
|
|
#include "task.h"
|
|
|
|
#include "process.h"
|
1996-07-17 20:02:21 +00:00
|
|
|
#include "stackframe.h"
|
|
|
|
#include "neexe.h"
|
1999-06-12 15:45:58 +00:00
|
|
|
#include "debugtools.h"
|
1994-10-17 18:12:41 +00:00
|
|
|
|
2000-09-26 00:39:06 +00:00
|
|
|
DEFAULT_DEBUG_CHANNEL(resource);
|
|
|
|
|
1997-02-02 19:01:52 +00:00
|
|
|
/**********************************************************************
|
2000-08-07 04:12:41 +00:00
|
|
|
* get_resdir
|
1997-02-02 19:01:52 +00:00
|
|
|
*
|
2000-08-07 04:12:41 +00:00
|
|
|
* Get the resource directory of a PE module
|
1997-02-02 19:01:52 +00:00
|
|
|
*/
|
2000-10-19 20:29:53 +00:00
|
|
|
static const IMAGE_RESOURCE_DIRECTORY* get_resdir( HMODULE hmod )
|
2000-08-07 04:12:41 +00:00
|
|
|
{
|
2000-10-19 20:29:53 +00:00
|
|
|
const IMAGE_DATA_DIRECTORY *dir;
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY *ret = NULL;
|
2000-08-07 04:12:41 +00:00
|
|
|
|
|
|
|
if (!hmod) hmod = GetModuleHandleA( NULL );
|
2000-09-26 00:39:06 +00:00
|
|
|
else if (!HIWORD(hmod))
|
|
|
|
{
|
|
|
|
FIXME("Enumeration of 16-bit resources is not supported\n");
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return NULL;
|
|
|
|
}
|
2000-08-07 04:12:41 +00: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 19:01:52 +00:00
|
|
|
}
|
1994-10-17 18:12:41 +00:00
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
|
2000-10-19 20:29:53 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* find_entry_by_id
|
|
|
|
*
|
|
|
|
* Find an entry by id in a resource directory
|
|
|
|
*/
|
2000-10-24 21:35:14 +00:00
|
|
|
static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_id( const IMAGE_RESOURCE_DIRECTORY *dir,
|
|
|
|
WORD id, const void *root )
|
2000-10-19 20:29:53 +00: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;
|
|
|
|
if (entry[pos].u1.Id == id)
|
2000-11-10 22:34:39 +00:00
|
|
|
return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].u2.s2.OffsetToDirectory);
|
2000-10-19 20:29:53 +00:00
|
|
|
if (entry[pos].u1.Id > id) max = pos - 1;
|
|
|
|
else min = pos + 1;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-10-24 21:35:14 +00:00
|
|
|
* find_entry_by_nameW
|
2000-10-19 20:29:53 +00:00
|
|
|
*
|
2000-10-24 21:35:14 +00:00
|
|
|
* Find an entry by name in a resource directory
|
2000-10-19 20:29:53 +00:00
|
|
|
*/
|
2000-10-24 21:35:14 +00:00
|
|
|
static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_nameW( const IMAGE_RESOURCE_DIRECTORY *dir,
|
|
|
|
LPCWSTR name, const void *root )
|
2000-10-19 20:29:53 +00:00
|
|
|
{
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry;
|
2000-10-24 21:35:14 +00: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 20:29:53 +00:00
|
|
|
|
|
|
|
entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
|
2000-10-24 21:35:14 +00:00
|
|
|
namelen = strlenW(name);
|
|
|
|
min = 0;
|
|
|
|
max = dir->NumberOfNamedEntries - 1;
|
|
|
|
while (min <= max)
|
|
|
|
{
|
|
|
|
pos = (min + max) / 2;
|
2000-11-10 22:34:39 +00:00
|
|
|
str = (IMAGE_RESOURCE_DIR_STRING_U *)((char *)root + entry[pos].u1.s1.NameOffset);
|
2000-10-24 21:35:14 +00:00
|
|
|
res = strncmpiW( name, str->NameString, str->Length );
|
|
|
|
if (!res && namelen == str->Length)
|
2000-11-10 22:34:39 +00:00
|
|
|
return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry[pos].u2.s2.OffsetToDirectory);
|
2000-10-24 21:35:14 +00:00
|
|
|
if (res < 0) max = pos - 1;
|
|
|
|
else min = pos + 1;
|
|
|
|
}
|
2000-10-19 20:29:53 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-07-17 20:02:21 +00:00
|
|
|
/**********************************************************************
|
2000-10-24 21:35:14 +00:00
|
|
|
* find_entry_by_nameA
|
1996-07-17 20:02:21 +00:00
|
|
|
*
|
2000-10-24 21:35:14 +00:00
|
|
|
* Find an entry by name in a resource directory
|
1996-07-17 20:02:21 +00:00
|
|
|
*/
|
2000-10-24 21:35:14 +00:00
|
|
|
static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_nameA( const IMAGE_RESOURCE_DIRECTORY *dir,
|
|
|
|
LPCSTR name, const void *root )
|
1996-07-17 20:02:21 +00:00
|
|
|
{
|
2000-10-24 21:35:14 +00: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 20:29:53 +00:00
|
|
|
{
|
2000-10-24 21:35:14 +00:00
|
|
|
return find_entry_by_id( dir, atoi(name+1), root );
|
2000-10-19 20:29:53 +00:00
|
|
|
}
|
2000-10-24 21:35:14 +00:00
|
|
|
|
|
|
|
if ((nameW = HEAP_strdupAtoW( GetProcessHeap(), 0, name )))
|
2000-10-19 20:29:53 +00:00
|
|
|
{
|
2000-10-24 21:35:14 +00:00
|
|
|
ret = find_entry_by_nameW( dir, nameW, root );
|
|
|
|
HeapFree( GetProcessHeap(), 0, nameW );
|
1996-07-17 20:02:21 +00:00
|
|
|
}
|
2000-10-24 21:35:14 +00:00
|
|
|
return ret;
|
1994-10-17 18:12:41 +00:00
|
|
|
}
|
|
|
|
|
2000-10-24 21:35:14 +00:00
|
|
|
|
1999-01-31 10:13:13 +00:00
|
|
|
/**********************************************************************
|
2000-10-24 21:35:14 +00:00
|
|
|
* find_entry_default
|
|
|
|
*
|
|
|
|
* Find a default entry in a resource directory
|
1999-01-31 10:13:13 +00:00
|
|
|
*/
|
2000-10-24 21:35:14 +00:00
|
|
|
static const IMAGE_RESOURCE_DIRECTORY *find_entry_default( const IMAGE_RESOURCE_DIRECTORY *dir,
|
|
|
|
const void *root )
|
1999-01-31 10:13:13 +00:00
|
|
|
{
|
2000-10-24 21:35:14 +00:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry;
|
1999-01-31 10:13:13 +00:00
|
|
|
|
2000-10-24 21:35:14 +00:00
|
|
|
entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1);
|
2000-11-10 22:34:39 +00:00
|
|
|
return (IMAGE_RESOURCE_DIRECTORY *)((char *)root + entry->u2.s2.OffsetToDirectory);
|
1999-01-31 10:13:13 +00:00
|
|
|
}
|
|
|
|
|
2000-10-24 21:35:14 +00:00
|
|
|
|
1996-07-17 20:02:21 +00:00
|
|
|
/**********************************************************************
|
2000-08-07 04:12:41 +00:00
|
|
|
* PE_FindResourceExW
|
2000-08-11 12:50:56 +00: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 20:02:21 +00:00
|
|
|
*/
|
2000-08-11 12:50:56 +00:00
|
|
|
HRSRC PE_FindResourceExW( HMODULE hmod, LPCWSTR name, LPCWSTR type, WORD lang )
|
2000-08-07 04:12:41 +00:00
|
|
|
{
|
2000-10-19 20:29:53 +00:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdirptr = get_resdir(hmod);
|
|
|
|
const void *root;
|
2000-08-11 12:50:56 +00:00
|
|
|
HRSRC result;
|
1994-10-17 18:12:41 +00:00
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
if (!resdirptr) return 0;
|
1996-07-17 20:02:21 +00:00
|
|
|
|
2000-10-19 20:29:53 +00:00
|
|
|
root = resdirptr;
|
2000-10-24 21:35:14 +00: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 12:50:56 +00:00
|
|
|
|
|
|
|
/* 1. Exact specified language */
|
2000-10-19 20:29:53 +00:00
|
|
|
if ((result = (HRSRC)find_entry_by_id( resdirptr, lang, root ))) goto found;
|
2000-05-05 18:17:52 +00:00
|
|
|
|
2000-10-19 20:29:53 +00: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 12:50:56 +00:00
|
|
|
|
2000-10-19 20:29:53 +00: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 12:50:56 +00:00
|
|
|
|
2000-10-19 20:29:53 +00: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 12:50:56 +00:00
|
|
|
|
2000-10-19 20:29:53 +00:00
|
|
|
found:
|
2000-08-11 12:50:56 +00: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 20:29:53 +00:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdirptr = get_resdir(hmod);
|
|
|
|
const void *root;
|
2000-08-11 12:50:56 +00:00
|
|
|
HRSRC result;
|
|
|
|
WORD lang;
|
|
|
|
|
|
|
|
if (!resdirptr) return 0;
|
|
|
|
|
2000-10-19 20:29:53 +00:00
|
|
|
root = resdirptr;
|
2000-10-24 21:35:14 +00: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 12:50:56 +00:00
|
|
|
|
|
|
|
/* 1. Neutral language with neutral sublanguage */
|
|
|
|
lang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);
|
2000-10-19 20:29:53 +00:00
|
|
|
if ((result = (HRSRC)find_entry_by_id( resdirptr, lang, root ))) goto found;
|
2000-08-11 12:50:56 +00:00
|
|
|
|
2000-10-19 20:29:53 +00: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 12:50:56 +00:00
|
|
|
|
2000-10-19 20:29:53 +00:00
|
|
|
/* 3. Current locale lang id */
|
|
|
|
lang = LANGIDFROMLCID(GetUserDefaultLCID());
|
|
|
|
if ((result = (HRSRC)find_entry_by_id( resdirptr, lang, root ))) goto found;
|
2000-08-11 12:50:56 +00:00
|
|
|
|
2000-10-19 20:29:53 +00: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 12:50:56 +00:00
|
|
|
|
2000-10-19 20:29:53 +00: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 12:50:56 +00:00
|
|
|
|
2000-10-19 20:29:53 +00:00
|
|
|
/* 6. Return first in the list */
|
|
|
|
result = (HRSRC)find_entry_default( resdirptr, root );
|
2000-08-11 12:50:56 +00:00
|
|
|
|
2000-10-19 20:29:53 +00:00
|
|
|
found:
|
1996-07-17 20:02:21 +00:00
|
|
|
return result;
|
1994-10-17 18:12:41 +00:00
|
|
|
}
|
|
|
|
|
1996-07-17 20:02:21 +00:00
|
|
|
|
1994-10-17 18:12:41 +00:00
|
|
|
/**********************************************************************
|
2000-08-07 04:12:41 +00:00
|
|
|
* PE_LoadResource
|
1994-10-17 18:12:41 +00:00
|
|
|
*/
|
2000-08-07 04:12:41 +00:00
|
|
|
HANDLE PE_LoadResource( HMODULE hmod, HANDLE hRsrc )
|
1994-10-17 18:12:41 +00:00
|
|
|
{
|
2000-08-07 04:12:41 +00:00
|
|
|
if (!hRsrc) return 0;
|
|
|
|
return (HANDLE)(hmod + ((PIMAGE_RESOURCE_DATA_ENTRY)hRsrc)->OffsetToData);
|
1997-02-02 19:01:52 +00:00
|
|
|
}
|
|
|
|
|
1996-07-17 20:02:21 +00:00
|
|
|
|
1997-02-02 19:01:52 +00:00
|
|
|
/**********************************************************************
|
2000-08-07 23:50:00 +00:00
|
|
|
* PE_SizeofResource
|
1997-02-02 19:01:52 +00:00
|
|
|
*/
|
2000-08-07 23:50:00 +00:00
|
|
|
DWORD PE_SizeofResource( HANDLE hRsrc )
|
1997-02-02 19:01:52 +00:00
|
|
|
{
|
2000-08-07 23:50:00 +00:00
|
|
|
if (!hRsrc) return 0;
|
1998-10-16 09:30:33 +00:00
|
|
|
return ((PIMAGE_RESOURCE_DATA_ENTRY)hRsrc)->Size;
|
1997-02-02 19:01:52 +00:00
|
|
|
}
|
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
|
1997-02-02 19:01:52 +00:00
|
|
|
/**********************************************************************
|
2000-08-07 04:12:41 +00:00
|
|
|
* EnumResourceTypesA (KERNEL32.90)
|
1997-02-02 19:01:52 +00:00
|
|
|
*/
|
2000-08-07 04:12:41 +00:00
|
|
|
BOOL WINAPI EnumResourceTypesA( HMODULE hmod, ENUMRESTYPEPROCA lpfun, LONG lparam)
|
|
|
|
{
|
1997-02-02 19:01:52 +00:00
|
|
|
int i;
|
2000-10-19 20:29:53 +00:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdir = get_resdir(hmod);
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *et;
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL ret;
|
1997-02-02 19:01:52 +00:00
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
if (!resdir) return FALSE;
|
1997-02-02 19:01:52 +00:00
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)(resdir + 1);
|
1997-02-02 19:01:52 +00:00
|
|
|
ret = FALSE;
|
|
|
|
for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
|
2000-08-20 03:32:57 +00:00
|
|
|
LPSTR type;
|
|
|
|
|
2000-11-10 22:34:39 +00:00
|
|
|
if (et[i].u1.s1.NameIsString)
|
2000-08-20 03:32:57 +00:00
|
|
|
{
|
2000-11-10 22:34:39 +00:00
|
|
|
PIMAGE_RESOURCE_DIR_STRING_U pResString = (PIMAGE_RESOURCE_DIR_STRING_U) ((LPBYTE) resdir + et[i].u1.s1.NameOffset);
|
2000-08-20 03:32:57 +00: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
|
|
|
|
{
|
|
|
|
type = (LPSTR)(int)et[i].u1.Id;
|
|
|
|
ret = lpfun(hmod,type,lparam);
|
|
|
|
}
|
1997-02-02 19:01:52 +00:00
|
|
|
if (!ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
|
1997-02-02 19:01:52 +00:00
|
|
|
/**********************************************************************
|
2000-08-07 04:12:41 +00:00
|
|
|
* EnumResourceTypesW (KERNEL32.91)
|
1997-02-02 19:01:52 +00:00
|
|
|
*/
|
2000-08-07 04:12:41 +00:00
|
|
|
BOOL WINAPI EnumResourceTypesW( HMODULE hmod, ENUMRESTYPEPROCW lpfun, LONG lparam)
|
|
|
|
{
|
1997-02-02 19:01:52 +00:00
|
|
|
int i;
|
2000-10-19 20:29:53 +00:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdir = get_resdir(hmod);
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *et;
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL ret;
|
1997-02-02 19:01:52 +00:00
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
if (!resdir) return FALSE;
|
1997-02-02 19:01:52 +00:00
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)(resdir + 1);
|
1997-02-02 19:01:52 +00:00
|
|
|
ret = FALSE;
|
|
|
|
for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
|
|
|
|
LPWSTR type;
|
|
|
|
|
2000-11-10 22:34:39 +00:00
|
|
|
if (et[i].u1.s1.NameIsString)
|
2000-08-20 03:32:57 +00:00
|
|
|
{
|
2000-11-10 22:34:39 +00:00
|
|
|
PIMAGE_RESOURCE_DIR_STRING_U pResString = (PIMAGE_RESOURCE_DIR_STRING_U) ((LPBYTE) resdir + et[i].u1.s1.NameOffset);
|
2000-08-20 03:32:57 +00: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
|
|
|
|
{
|
|
|
|
type = (LPWSTR)(int)et[i].u1.Id;
|
|
|
|
ret = lpfun(hmod,type,lparam);
|
|
|
|
}
|
1997-02-02 19:01:52 +00:00
|
|
|
if (!ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
|
1997-02-02 19:01:52 +00:00
|
|
|
/**********************************************************************
|
2000-08-07 04:12:41 +00:00
|
|
|
* EnumResourceNamesA (KERNEL32.88)
|
1997-02-02 19:01:52 +00:00
|
|
|
*/
|
2000-08-07 04:12:41 +00:00
|
|
|
BOOL WINAPI EnumResourceNamesA( HMODULE hmod, LPCSTR type, ENUMRESNAMEPROCA lpfun, LONG lparam )
|
|
|
|
{
|
1997-02-02 19:01:52 +00:00
|
|
|
int i;
|
2000-10-19 20:29:53 +00:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *basedir = get_resdir(hmod);
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdir;
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *et;
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL ret;
|
1997-02-02 19:01:52 +00:00
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
if (!basedir) return FALSE;
|
|
|
|
|
2000-10-24 21:35:14 +00:00
|
|
|
if (!(resdir = find_entry_by_nameA( basedir, type, basedir ))) return FALSE;
|
2000-08-20 03:32:57 +00:00
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)(resdir + 1);
|
1997-02-02 19:01:52 +00:00
|
|
|
ret = FALSE;
|
|
|
|
for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
|
2000-08-20 03:32:57 +00:00
|
|
|
LPSTR name;
|
|
|
|
|
2000-11-10 22:34:39 +00:00
|
|
|
if (et[i].u1.s1.NameIsString)
|
2000-08-20 03:32:57 +00:00
|
|
|
{
|
2000-11-10 22:34:39 +00:00
|
|
|
PIMAGE_RESOURCE_DIR_STRING_U pResString = (PIMAGE_RESOURCE_DIR_STRING_U) ((LPBYTE) basedir + et[i].u1.s1.NameOffset);
|
2000-08-20 03:32:57 +00: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
|
|
|
|
{
|
|
|
|
name = (LPSTR)(int)et[i].u1.Id;
|
|
|
|
ret = lpfun(hmod,type,name,lparam);
|
|
|
|
}
|
1997-02-02 19:01:52 +00:00
|
|
|
if (!ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
|
1997-02-02 19:01:52 +00:00
|
|
|
/**********************************************************************
|
2000-08-07 04:12:41 +00:00
|
|
|
* EnumResourceNamesW (KERNEL32.89)
|
1997-02-02 19:01:52 +00:00
|
|
|
*/
|
2000-08-07 04:12:41 +00:00
|
|
|
BOOL WINAPI EnumResourceNamesW( HMODULE hmod, LPCWSTR type, ENUMRESNAMEPROCW lpfun, LONG lparam )
|
|
|
|
{
|
1997-02-02 19:01:52 +00:00
|
|
|
int i;
|
2000-10-19 20:29:53 +00:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *basedir = get_resdir(hmod);
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdir;
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *et;
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL ret;
|
1997-02-02 19:01:52 +00:00
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
if (!basedir) return FALSE;
|
1997-02-02 19:01:52 +00:00
|
|
|
|
2000-10-24 21:35:14 +00:00
|
|
|
if (!(resdir = find_entry_by_nameW( basedir, type, basedir ))) return FALSE;
|
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
et = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)(resdir + 1);
|
1997-02-02 19:01:52 +00:00
|
|
|
ret = FALSE;
|
|
|
|
for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
|
2000-08-20 03:32:57 +00:00
|
|
|
LPWSTR name;
|
|
|
|
|
2000-11-10 22:34:39 +00:00
|
|
|
if (et[i].u1.s1.NameIsString)
|
2000-08-20 03:32:57 +00:00
|
|
|
{
|
2000-11-10 22:34:39 +00:00
|
|
|
PIMAGE_RESOURCE_DIR_STRING_U pResString = (PIMAGE_RESOURCE_DIR_STRING_U) ((LPBYTE) basedir + et[i].u1.s1.NameOffset);
|
2000-08-20 03:32:57 +00: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
|
|
|
|
{
|
|
|
|
name = (LPWSTR)(int)et[i].u1.Id;
|
|
|
|
ret = lpfun(hmod,type,name,lparam);
|
|
|
|
}
|
1997-02-02 19:01:52 +00:00
|
|
|
if (!ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
|
1997-02-02 19:01:52 +00:00
|
|
|
/**********************************************************************
|
2000-08-07 04:12:41 +00:00
|
|
|
* EnumResourceLanguagesA (KERNEL32.86)
|
1997-02-02 19:01:52 +00:00
|
|
|
*/
|
2000-08-07 04:12:41 +00:00
|
|
|
BOOL WINAPI EnumResourceLanguagesA( HMODULE hmod, LPCSTR type, LPCSTR name,
|
|
|
|
ENUMRESLANGPROCA lpfun, LONG lparam )
|
|
|
|
{
|
1997-02-02 19:01:52 +00:00
|
|
|
int i;
|
2000-10-19 20:29:53 +00:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *basedir = get_resdir(hmod);
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdir;
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *et;
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL ret;
|
1997-02-02 19:01:52 +00:00
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
if (!basedir) return FALSE;
|
2000-10-24 21:35:14 +00: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 04:12:41 +00:00
|
|
|
|
|
|
|
et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)(resdir + 1);
|
1997-02-02 19:01:52 +00:00
|
|
|
ret = FALSE;
|
|
|
|
for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
|
2000-08-20 03:32:57 +00:00
|
|
|
/* languages are just ids... I hope */
|
2000-08-07 04:12:41 +00:00
|
|
|
ret = lpfun(hmod,type,name,et[i].u1.Id,lparam);
|
1997-02-02 19:01:52 +00:00
|
|
|
if (!ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
|
1997-02-02 19:01:52 +00:00
|
|
|
/**********************************************************************
|
2000-08-07 04:12:41 +00:00
|
|
|
* EnumResourceLanguagesW (KERNEL32.87)
|
1997-02-02 19:01:52 +00:00
|
|
|
*/
|
2000-08-07 04:12:41 +00:00
|
|
|
BOOL WINAPI EnumResourceLanguagesW( HMODULE hmod, LPCWSTR type, LPCWSTR name,
|
|
|
|
ENUMRESLANGPROCW lpfun, LONG lparam )
|
|
|
|
{
|
1997-02-02 19:01:52 +00:00
|
|
|
int i;
|
2000-10-19 20:29:53 +00:00
|
|
|
const IMAGE_RESOURCE_DIRECTORY *basedir = get_resdir(hmod);
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY *resdir;
|
|
|
|
const IMAGE_RESOURCE_DIRECTORY_ENTRY *et;
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL ret;
|
1997-02-02 19:01:52 +00:00
|
|
|
|
2000-08-07 04:12:41 +00:00
|
|
|
if (!basedir) return FALSE;
|
1997-02-02 19:01:52 +00:00
|
|
|
|
2000-10-24 21:35:14 +00: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 04:12:41 +00:00
|
|
|
et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)(resdir + 1);
|
1997-02-02 19:01:52 +00:00
|
|
|
ret = FALSE;
|
|
|
|
for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
|
2000-08-07 04:12:41 +00:00
|
|
|
ret = lpfun(hmod,type,name,et[i].u1.Id,lparam);
|
1997-02-02 19:01:52 +00:00
|
|
|
if (!ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
1994-10-17 18:12:41 +00:00
|
|
|
}
|