
Sun Apr 28 14:32:43 1996 Alexandre Julliard <julliard@lrc.epfl.ch> * [Makefile.in] Subdir memory is now also compiled for Winelib, in order to get the Win32 heap functions. * [if1632/Makefile.in] Renamed winprocs and winprocs32 to wprocs and wprocs32 to avoid DLL names > 8 characters. * [loader/builtin.c] (New file) Grouped all built-in DLLs code in a single file. * [memory/global.c] Use the Win32 heap code instead of malloc() to allocate linear memory. This will help test the heap code. * [memory/local.c] Fixed FreeSelector() to clear DS and ES correctly for huge blocks. * [tools/build.c] [if1632/relay.c] Removed 'id' directive in spec files. For relay debugging, the DLL entry point is now computed from the CS:IP entry point address. Added 'heap' directive to specifiy a local heap for the DLL. USER and GDI heap are now created this way. * [windows/class.c] [include/class.h] Changed the class structure to use pointers instead of handles. Changed Get/SetClassWord/Long to use a switch statement; this allows changing the layout of the CLASS structure. * [windows/win.c] [include/win.h] Use a CLASS * instead of a handle for the window class. Sat Apr 27 18:10:11 Martin von Loewis <loewis@informatik.hu-berlin.de> * [if1632/kernel32.spec] [memory/global.c] [win32/memory.c] [win32/process.c] GetProcessAffinityMask,GlobalLock,IsBadReadPtr,IsBadWritePtr, LocalLock,SetThreadAffinityMask: new relays. * [win32/cursoricon32.c] Return same handle if a cursor is loaded multiple times. Sat Apr 27 15:13:37 1996 Bang Jun Young <bangjy@nownuri.nowcom.co.kr> * [resources/sysres_Ko.rc] Added support for Korean [Ko] language. Fri Apr 26 00:49:05 1996 Huw D. M. Davies <h.davies1@physics.oxford.ac.uk> * [objects/dc.c] [objects/font.c] Fixed problem with SaveDC()/RestoreDC() and font cache 'used' count. * [objects/metafile.c] [objects/dcvalues.c] Fixed broken SetTextAlign() on metafiles. * [objects/metafile.c] Delete objects in handle table at end of PlayMetaFile(). Wed Apr 24 19:21:01 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de> * [if1632/ver.spec] [misc/ver.c] [include/ver.h] (New files) VER.DLL (partially) implemented (VerFindFile,VerInstallFile) [If it doesn't work for you, use -dll -ver and report it to me] * [if1632/user32.spec] [if1632/kernel32.spec] [if1632/shell.spec] [if1632/shell32.spec] [misc/ole2nls.c] [windows/message.c] [windows/graphics.c] Simple win32 functions, where we can just use the win16 counterpart. Misc. stubs. * [misc/lstr.c] Someone reported a _lstrlen(NULL). NULL is a valid argument. Fixed. * [misc/registry.c] Some alloclens were off by 1, one double fclose() fixed. Requesting value 0 of a key with no values returns an error (should we always return a made up value NULL? what does win3.1?) Tue Apr 23 17:00:00 1996 Alex Korobka <alex@phm30.pharm.sunysb.edu> * [misc/shell.c] Implemented FindEnvironmentString(), DoEnvironmentSubst(), ExtractIcon(), InternalExtractIcon() and ExtractAssociatedIcon(). * [misc/user.c] Do extensive cleanup on application exit. * [windows/hook.c] [windows/win.c] [windows/class.c] Added miscellaneous cleanup routines. * [controls/menu.c] More efficient popup menu window handling. Mon Apr 22 21:35:22 1996 Albrecht Kleine <kleine@ak.sax.de> * [include/windows.h][objects/oembitmap.c][include/bitmaps/obm_trtype] Added "TT-bitmap" for later usage in a ChooseFont() ownerdraw combobox.
155 lines
5.1 KiB
C
155 lines
5.1 KiB
C
#ifndef WINELIB
|
|
/*
|
|
* (c) 1994 Erik Bos <erik@xs4all.nl>
|
|
*
|
|
* based on Eric Youndale's pe-test and:
|
|
*
|
|
* ftp.microsoft.com:/pub/developer/MSDN/CD8/PEFILE.ZIP
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include "windows.h"
|
|
#include "ldt.h"
|
|
#include "neexe.h"
|
|
#include "peexe.h"
|
|
#include "pe_image.h"
|
|
#include "resource.h"
|
|
#include "stddebug.h"
|
|
/* #define DEBUG_RESOURCE */
|
|
#include "debug.h"
|
|
|
|
#if 0
|
|
|
|
static int
|
|
find_lang(char *root, struct PE_Resource_Directory *resource, RESOURCE *r)
|
|
{
|
|
struct PE_Directory_Entry *type_dir;
|
|
struct PE_Resource_Leaf_Entry *leaf;
|
|
|
|
type_dir = (struct PE_Directory_Entry *)(resource + 1);
|
|
type_dir += resource->NumberOfNamedEntries;
|
|
|
|
/* grab the 1st resource available */
|
|
leaf = (struct PE_Resource_Leaf_Entry *) (root + type_dir->OffsetToData);
|
|
dprintf_resource(stddeb, "\t\tPE_findlang: id %8x\n", (int) type_dir->Name);
|
|
dprintf_resource(stddeb, "\t\taddress %ld, size %ld, language id %ld\n", leaf->OffsetToData, leaf->Size, leaf->CodePage);
|
|
r->offset = leaf->OffsetToData - r->wpnt->pe->resource_offset;
|
|
r->size = leaf->Size;
|
|
printf("\t\toffset %d, size %d\n", r->offset, r->size);
|
|
return 1;
|
|
|
|
/* for(i=0; i< resource->NumberOfIdEntries; i++) {
|
|
leaf = (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY));
|
|
dprintf_resource(stddeb, "\t\tPE_findlang: id %8x\n",
|
|
(int) type_dir->Name);
|
|
dprintf_resource(stddeb, "\t\t%x %x %x\n", leaf->OffsetToData,
|
|
leaf->Size, leaf->CodePage);
|
|
type_dir++;
|
|
} */
|
|
}
|
|
|
|
static int
|
|
find_resource(char *root, struct PE_Resource_Directory *resource,
|
|
LPSTR resource_name, RESOURCE *r)
|
|
{
|
|
int i;
|
|
char res_name[256];
|
|
struct PE_Directory_Entry *type_dir;
|
|
struct PE_Directory_Name_String_U *name;
|
|
|
|
type_dir = (struct PE_Directory_Entry *)(resource + 1);
|
|
|
|
if (HIWORD((DWORD)resource_name)) {
|
|
for(i=0; i< resource->NumberOfNamedEntries; i++) {
|
|
name = (struct PE_Directory_Name_String_U *)(root + (type_dir->Name & ~IMAGE_RESOURCE_NAME_IS_STRING));
|
|
memset(res_name, 0, sizeof(res_name));
|
|
my_wcstombs(res_name, name->NameString, name->Length);
|
|
dprintf_resource(stddeb, "\tPE_findresource: name %s\n", res_name);
|
|
if (lstrcmpi(res_name, resource_name) == 0)
|
|
return find_lang(root, (struct PE_Resource_Directory *) (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY)), r);
|
|
type_dir++;
|
|
}
|
|
} else {
|
|
type_dir += resource->NumberOfNamedEntries;
|
|
for(i=0; i< resource->NumberOfIdEntries; i++) {
|
|
dprintf_resource(stddeb, "\tPE_findresource: name %8x\n", (int) type_dir->Name);
|
|
if (type_dir->Name == ((int) resource_name & 0xff))
|
|
return find_lang(root, (struct PE_Resource_Directory *) (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY)), r);
|
|
type_dir++;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int
|
|
find_type(struct PE_Resource_Directory *resource, LPSTR resource_name,
|
|
LPSTR type_name)
|
|
{
|
|
int i;
|
|
char *root, res_name[256];
|
|
struct PE_Directory_Entry *type_dir;
|
|
struct PE_Directory_Name_String_U *name;
|
|
|
|
root = (char *) resource;
|
|
type_dir = (struct PE_Directory_Entry *)(resource + 1);
|
|
|
|
if (HIWORD((DWORD)type_name)) {
|
|
for(i=0; i< resource->NumberOfNamedEntries; i++) {
|
|
name = (struct PE_Directory_Name_String_U *)(root + (type_dir->Name & ~IMAGE_RESOURCE_NAME_IS_STRING));
|
|
memset(res_name, 0, sizeof(res_name));
|
|
my_wcstombs(res_name, name->NameString, name->Length);
|
|
dprintf_resource(stddeb, "PE_findtype: type %s\n",
|
|
res_name);
|
|
if (lstrcmpi(res_name, type_name) == 0)
|
|
return find_resource(root, (struct PE_Resource_Directory *) (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY)), resource_name, r);
|
|
type_dir++;
|
|
}
|
|
} else {
|
|
type_dir += resource->NumberOfNamedEntries;
|
|
for(i=0; i< resource->NumberOfIdEntries; i++) {
|
|
dprintf_resource(stddeb, "PE_findtype: type %8x\n", (int) type_dir->Name);
|
|
if (type_dir->Name == ((int) type_name & 0xff))
|
|
return find_resource(root, (struct PE_Resource_Directory *) (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY)), resource_name, r);
|
|
type_dir++;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/**********************************************************************
|
|
* PE_FindResource [KERNEL.60]
|
|
*/
|
|
int
|
|
PE_FindResource(HANDLE instance, SEGPTR resource_name, SEGPTR type_name,
|
|
RESOURCE *r)
|
|
{
|
|
dprintf_resource(stddeb, "PE_FindResource hInst=%04X typename=%08X resname=%08X\n",
|
|
instance, (int) type_name, (int) resource_name);
|
|
if (HIWORD(resource_name))
|
|
{
|
|
char *resource_name_ptr = PTR_SEG_TO_LIN( resource_name );
|
|
if (resource_name_ptr[0] == '#')
|
|
resource_name = (SEGPTR) atoi(resource_name_ptr + 1);
|
|
else
|
|
resource_name = (SEGPTR)resource_name_ptr;
|
|
}
|
|
if (HIWORD(type_name))
|
|
{
|
|
char *type_name_ptr = PTR_SEG_TO_LIN( type_name );
|
|
if (type_name_ptr[0] == '#')
|
|
type_name = (SEGPTR) atoi(type_name_ptr + 1);
|
|
else
|
|
type_name = (SEGPTR) type_name_ptr;
|
|
}
|
|
return find_type(r->wpnt->pe->pe_resource, resource_name, type_name);
|
|
}
|
|
#endif
|
|
|
|
#endif /* WINELIB */
|