Commit 003e24ca authored by Alexandre Julliard's avatar Alexandre Julliard

Added support for loading Win32 .res files.

parent 2affae5a
......@@ -3,6 +3,7 @@ TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
LIBEXT = @LIBEXT@
PROGRAMS = winebuild
MODULE = none
......@@ -12,6 +13,7 @@ C_SRCS = \
main.c \
parser.c \
relay.c \
res32.c \
spec16.c \
spec32.c \
utils.c
......@@ -20,8 +22,11 @@ all: $(PROGRAMS)
@MAKE_RULES@
winebuild: $(OBJS)
$(CC) $(CFLAGS) -o winebuild $(OBJS)
winebuild: $(OBJS) $(TOPOBJDIR)/libwine_unicode.$(LIBEXT)
$(CC) $(CFLAGS) -o winebuild $(OBJS) -L$(TOPOBJDIR) -lwine_unicode
$(TOPOBJDIR)/libwine_unicode.$(LIBEXT):
cd $(TOPOBJDIR) && $(MAKE) libwine_unicode.$(LIBEXT)
install:: $(PROGRAMS)
[ -d $(bindir) ] || $(MKDIR) $(bindir)
......
......@@ -137,11 +137,14 @@ extern void *xrealloc (void *ptr, size_t size);
extern char *xstrdup( const char *str );
extern char *strupper(char *s);
extern void fatal_error( const char *msg, ... );
extern void fatal_perror( const char *msg, ... );
extern void warning( const char *msg, ... );
extern void dump_bytes( FILE *outfile, const unsigned char *data, int len, const char *label );
extern void add_import_dll( const char *name );
extern void resolve_imports( FILE *outfile );
extern int output_imports( FILE *outfile );
extern void load_res32_file( const char *name );
extern int output_resources( FILE *outfile );
extern void BuildGlue( FILE *outfile, FILE *infile );
extern void BuildRelays( FILE *outfile );
......
......@@ -481,9 +481,13 @@ SPEC_TYPE ParseTopLevel( FILE *file )
}
else if (strcmp(token, "rsrc") == 0)
{
if (SpecType != SPEC_WIN16) load_res32_file( GetToken() );
else
{
strcpy( rsrc_name, GetToken() );
strcat( rsrc_name, "_ResourceDescriptor" );
}
}
else if (strcmp(token, "owner") == 0)
{
if (SpecType != SPEC_WIN16)
......
......@@ -274,7 +274,7 @@ void BuildSpec32File( FILE *outfile )
{
ORDDEF *odp;
int i, fwd_size = 0, have_regs = FALSE;
int nr_exports, nr_imports;
int nr_exports, nr_imports, nr_resources;
int characteristics, subsystem;
const char *init_func;
DWORD page_size;
......@@ -379,6 +379,10 @@ void BuildSpec32File( FILE *outfile )
nr_imports = output_imports( outfile );
/* Output the resources */
nr_resources = output_resources( outfile );
/* Output LibMain function */
init_func = DLLInitFunc[0] ? DLLInitFunc : NULL;
......@@ -445,10 +449,6 @@ void BuildSpec32File( FILE *outfile )
break;
}
/* Output the DLL descriptor */
if (rsrc_name[0]) fprintf( outfile, "extern char %s[];\n\n", rsrc_name );
/* Output the NT header */
/* this is the IMAGE_NT_HEADERS structure, but we cannot include winnt.h here */
......@@ -493,7 +493,7 @@ void BuildSpec32File( FILE *outfile )
fprintf( outfile, " int SizeOfHeapCommit;\n" );
fprintf( outfile, " int LoaderFlags;\n" );
fprintf( outfile, " int NumberOfRvaAndSizes;\n" );
fprintf( outfile, " struct { void *VirtualAddress; int Size; } DataDirectory[%d];\n",
fprintf( outfile, " struct { const void *VirtualAddress; int Size; } DataDirectory[%d];\n",
IMAGE_NUMBEROF_DIRECTORY_ENTRIES );
fprintf( outfile, " } OptionalHeader;\n" );
fprintf( outfile, "} nt_header = {\n" );
......@@ -527,8 +527,8 @@ void BuildSpec32File( FILE *outfile )
nr_exports ? "&exports" : "0", nr_exports ? "sizeof(exports.exp)" : "0" );
fprintf( outfile, " { %s, %s },\n", /* IMAGE_DIRECTORY_ENTRY_IMPORT */
nr_imports ? "&imports" : "0", nr_imports ? "sizeof(imports)" : "0" );
fprintf( outfile, " { %s, 0 },\n", /* IMAGE_DIRECTORY_ENTRY_RESOURCE */
rsrc_name[0] ? rsrc_name : "0" );
fprintf( outfile, " { %s, %s },\n", /* IMAGE_DIRECTORY_ENTRY_RESOURCE */
nr_resources ? "&resources" : "0", nr_resources ? "sizeof(resources)" : "0" );
fprintf( outfile, " }\n }\n};\n\n" );
/* Output the DLL constructor */
......
......@@ -67,6 +67,23 @@ void fatal_error( const char *msg, ... )
exit(1);
}
void fatal_perror( const char *msg, ... )
{
va_list valist;
va_start( valist, msg );
if (input_file_name)
{
fprintf( stderr, "%s:", input_file_name );
if (current_line)
fprintf( stderr, "%d:", current_line );
fputc( ' ', stderr );
}
vfprintf( stderr, msg, valist );
perror( " " );
va_end( valist );
exit(1);
}
void warning( const char *msg, ... )
{
va_list valist;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment