2000-06-23 22:15:35 +02:00
|
|
|
/*
|
|
|
|
* Copyright 1993 Robert J. Amstadt
|
|
|
|
* Copyright 1995 Martin von Loewis
|
|
|
|
* Copyright 1995, 1996, 1997 Alexandre Julliard
|
|
|
|
* Copyright 1997 Eric Youngdale
|
|
|
|
* Copyright 1999 Ulrich Weigand
|
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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2000-06-23 22:15:35 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __WINE_BUILD_H
|
|
|
|
#define __WINE_BUILD_H
|
|
|
|
|
2002-04-25 23:40:56 +02:00
|
|
|
#ifndef __WINE_CONFIG_H
|
|
|
|
# error You must include config.h to use this header
|
|
|
|
#endif
|
2001-11-06 21:57:11 +01:00
|
|
|
|
2000-06-23 22:15:35 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2002-03-11 06:09:02 +01:00
|
|
|
#include <string.h>
|
2000-06-23 22:15:35 +02:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2000-11-26 05:31:48 +01:00
|
|
|
TYPE_VARIABLE, /* variable */
|
2003-08-27 04:20:44 +02:00
|
|
|
TYPE_PASCAL, /* pascal function (Win16) */
|
2000-06-23 22:15:35 +02:00
|
|
|
TYPE_ABS, /* absolute value (Win16) */
|
|
|
|
TYPE_STUB, /* unimplemented stub */
|
|
|
|
TYPE_STDCALL, /* stdcall function (Win32) */
|
|
|
|
TYPE_CDECL, /* cdecl function (Win32) */
|
|
|
|
TYPE_VARARGS, /* varargs function (Win32) */
|
|
|
|
TYPE_EXTERN, /* external symbol (Win32) */
|
|
|
|
TYPE_NBTYPES
|
|
|
|
} ORD_TYPE;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
SPEC_WIN16,
|
|
|
|
SPEC_WIN32
|
|
|
|
} SPEC_TYPE;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int n_values;
|
|
|
|
int *values;
|
|
|
|
} ORD_VARIABLE;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2001-06-08 21:02:57 +02:00
|
|
|
char arg_types[21];
|
2000-06-23 22:15:35 +02:00
|
|
|
} ORD_FUNCTION;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int value;
|
|
|
|
} ORD_ABS;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ORD_TYPE type;
|
|
|
|
int ordinal;
|
|
|
|
int offset;
|
2000-11-26 05:31:48 +01:00
|
|
|
int lineno;
|
|
|
|
int flags;
|
2002-07-28 19:54:31 +02:00
|
|
|
char *name; /* public name of this function */
|
|
|
|
char *link_name; /* name of the C symbol to link to */
|
|
|
|
char *export_name; /* name exported under for noname exports */
|
2000-06-23 22:15:35 +02:00
|
|
|
union
|
|
|
|
{
|
|
|
|
ORD_VARIABLE var;
|
|
|
|
ORD_FUNCTION func;
|
|
|
|
ORD_ABS abs;
|
|
|
|
} u;
|
|
|
|
} ORDDEF;
|
|
|
|
|
2004-02-11 07:41:01 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char *file_name; /* file name of the dll */
|
|
|
|
char *dll_name; /* internal name of the dll */
|
|
|
|
char *owner_name; /* name of the 32-bit dll owning this one */
|
|
|
|
char *init_func; /* initialization routine */
|
|
|
|
SPEC_TYPE type; /* type of dll (Win16/Win32) */
|
|
|
|
int base; /* ordinal base */
|
|
|
|
int limit; /* ordinal limit */
|
|
|
|
int stack_size; /* exe stack size */
|
|
|
|
int heap_size; /* exe heap size */
|
|
|
|
int nb_entry_points; /* number of used entry points */
|
|
|
|
int alloc_entry_points; /* number of allocated entry points */
|
|
|
|
int nb_names; /* number of entry points with names */
|
2005-03-18 15:04:07 +01:00
|
|
|
unsigned int nb_resources; /* number of resources */
|
2004-03-25 01:40:52 +01:00
|
|
|
int characteristics; /* characteristics for the PE header */
|
|
|
|
int subsystem; /* subsystem id */
|
|
|
|
int subsystem_major; /* subsystem version major number */
|
|
|
|
int subsystem_minor; /* subsystem version minor number */
|
2004-02-11 07:41:01 +01:00
|
|
|
ORDDEF *entry_points; /* dll entry points */
|
|
|
|
ORDDEF **names; /* array of entry point names (points into entry_points) */
|
|
|
|
ORDDEF **ordinals; /* array of dll ordinals (points into entry_points) */
|
|
|
|
struct resource *resources; /* array of dll resources (format differs between Win16/Win32) */
|
|
|
|
} DLLSPEC;
|
|
|
|
|
2000-11-26 05:31:48 +01:00
|
|
|
/* entry point flags */
|
2002-12-12 03:20:47 +01:00
|
|
|
#define FLAG_NORELAY 0x01 /* don't use relay debugging for this function */
|
|
|
|
#define FLAG_NONAME 0x02 /* don't import function by name */
|
2003-08-27 04:20:44 +02:00
|
|
|
#define FLAG_RET16 0x04 /* function returns a 16-bit value */
|
|
|
|
#define FLAG_RET64 0x08 /* function returns a 64-bit value */
|
|
|
|
#define FLAG_I386 0x10 /* function is i386 only */
|
|
|
|
#define FLAG_REGISTER 0x20 /* use register calling convention */
|
2004-03-15 21:09:23 +01:00
|
|
|
#define FLAG_PRIVATE 0x40 /* function is private (cannot be imported) */
|
2003-07-28 21:19:48 +02:00
|
|
|
|
2004-03-15 21:09:23 +01:00
|
|
|
#define FLAG_FORWARD 0x80 /* function is a forwarded name */
|
2000-11-26 05:31:48 +01:00
|
|
|
|
2000-06-23 22:15:35 +02:00
|
|
|
/* Offset of a structure field relative to the start of the struct */
|
|
|
|
#define STRUCTOFFSET(type,field) ((int)&((type *)0)->field)
|
|
|
|
|
|
|
|
/* Offset of register relative to the start of the CONTEXT struct */
|
|
|
|
#define CONTEXTOFFSET(reg) STRUCTOFFSET(CONTEXT86,reg)
|
|
|
|
|
|
|
|
/* Offset of register relative to the start of the STACK16FRAME struct */
|
|
|
|
#define STACK16OFFSET(reg) STRUCTOFFSET(STACK16FRAME,reg)
|
|
|
|
|
|
|
|
/* Offset of register relative to the start of the STACK32FRAME struct */
|
|
|
|
#define STACK32OFFSET(reg) STRUCTOFFSET(STACK32FRAME,reg)
|
|
|
|
|
|
|
|
/* Offset of the stack pointer relative to %fs:(0) */
|
2005-05-14 14:16:46 +02:00
|
|
|
#define STACKOFFSET (STRUCTOFFSET(TEB,WOW32Reserved))
|
2000-06-23 22:15:35 +02:00
|
|
|
|
|
|
|
|
2000-12-16 00:04:40 +01:00
|
|
|
#define MAX_ORDINALS 65535
|
2000-06-23 22:15:35 +02:00
|
|
|
|
|
|
|
/* global functions */
|
|
|
|
|
2003-09-19 02:19:16 +02:00
|
|
|
#ifndef __GNUC__
|
|
|
|
#define __attribute__(X)
|
|
|
|
#endif
|
|
|
|
|
2000-06-23 22:15:35 +02:00
|
|
|
extern void *xmalloc (size_t size);
|
|
|
|
extern void *xrealloc (void *ptr, size_t size);
|
|
|
|
extern char *xstrdup( const char *str );
|
|
|
|
extern char *strupper(char *s);
|
2005-05-06 17:54:41 +02:00
|
|
|
extern int strendswith(const char* str, const char* end);
|
2003-09-19 02:19:16 +02:00
|
|
|
extern void fatal_error( const char *msg, ... )
|
|
|
|
__attribute__ ((__format__ (__printf__, 1, 2)));
|
|
|
|
extern void fatal_perror( const char *msg, ... )
|
|
|
|
__attribute__ ((__format__ (__printf__, 1, 2)));
|
|
|
|
extern void error( const char *msg, ... )
|
|
|
|
__attribute__ ((__format__ (__printf__, 1, 2)));
|
|
|
|
extern void warning( const char *msg, ... )
|
|
|
|
__attribute__ ((__format__ (__printf__, 1, 2)));
|
2002-03-10 00:29:33 +01:00
|
|
|
extern void output_standard_file_header( FILE *outfile );
|
2002-08-01 20:34:12 +02:00
|
|
|
extern FILE *open_input_file( const char *srcdir, const char *name );
|
|
|
|
extern void close_input_file( FILE *file );
|
2000-10-25 22:33:58 +02:00
|
|
|
extern void dump_bytes( FILE *outfile, const unsigned char *data, int len,
|
|
|
|
const char *label, int constant );
|
2004-02-17 21:36:16 +01:00
|
|
|
extern int remove_stdcall_decoration( char *name );
|
|
|
|
extern DLLSPEC *alloc_dll_spec(void);
|
|
|
|
extern void free_dll_spec( DLLSPEC *spec );
|
2002-05-14 22:54:58 +02:00
|
|
|
extern const char *make_c_identifier( const char *str );
|
2001-02-13 03:06:38 +01:00
|
|
|
extern int get_alignment(int alignBoundary);
|
|
|
|
|
2005-05-06 17:54:41 +02:00
|
|
|
extern void add_import_dll( const char *name, const char *filename );
|
|
|
|
extern void add_delayed_import( const char *name );
|
2000-12-14 23:18:22 +01:00
|
|
|
extern void add_ignore_symbol( const char *name );
|
2002-08-01 20:34:12 +02:00
|
|
|
extern void read_undef_symbols( char **argv );
|
2004-02-11 07:41:01 +01:00
|
|
|
extern int resolve_imports( DLLSPEC *spec );
|
2005-05-24 12:13:30 +02:00
|
|
|
extern int output_imports( FILE *outfile, DLLSPEC *spec, int *nb_delayed );
|
2004-02-11 07:41:01 +01:00
|
|
|
extern int load_res32_file( const char *name, DLLSPEC *spec );
|
|
|
|
extern void output_resources( FILE *outfile, DLLSPEC *spec );
|
|
|
|
extern void load_res16_file( const char *name, DLLSPEC *spec );
|
2005-05-20 21:19:01 +02:00
|
|
|
extern unsigned int get_res16_data_size( DLLSPEC *spec, unsigned int res_offset,
|
|
|
|
unsigned int alignment );
|
|
|
|
extern unsigned int output_res16_data( unsigned char **ret_buf, DLLSPEC *spec,
|
|
|
|
unsigned int res_offset, unsigned int alignment );
|
|
|
|
extern unsigned int get_res16_directory_size( DLLSPEC *spec );
|
|
|
|
extern unsigned int output_res16_directory( unsigned char **ret_buf, DLLSPEC *spec,
|
|
|
|
unsigned int res_offset, unsigned int alignment );
|
2002-06-15 01:42:53 +02:00
|
|
|
extern void output_dll_init( FILE *outfile, const char *constructor, const char *destructor );
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2001-12-11 01:50:33 +01:00
|
|
|
extern void BuildRelays16( FILE *outfile );
|
|
|
|
extern void BuildRelays32( FILE *outfile );
|
2004-02-11 07:41:01 +01:00
|
|
|
extern void BuildSpec16File( FILE *outfile, DLLSPEC *spec );
|
|
|
|
extern void BuildSpec32File( FILE *outfile, DLLSPEC *spec );
|
|
|
|
extern void BuildDef32File( FILE *outfile, DLLSPEC *spec );
|
2002-08-01 20:34:12 +02:00
|
|
|
extern void BuildDebugFile( FILE *outfile, const char *srcdir, char **argv );
|
2004-02-17 21:36:16 +01:00
|
|
|
|
|
|
|
extern int parse_spec_file( FILE *file, DLLSPEC *spec );
|
|
|
|
extern int parse_def_file( FILE *file, DLLSPEC *spec );
|
|
|
|
extern int parse_debug_channels( const char *srcdir, const char *filename );
|
2000-06-23 22:15:35 +02:00
|
|
|
|
|
|
|
/* global variables */
|
|
|
|
|
|
|
|
extern int current_line;
|
|
|
|
extern int UsePIC;
|
|
|
|
extern int debugging;
|
2000-11-05 05:49:13 +01:00
|
|
|
extern int nb_debug_channels;
|
2000-11-09 21:31:18 +01:00
|
|
|
extern int nb_lib_paths;
|
2003-03-18 06:30:54 +01:00
|
|
|
extern int nb_errors;
|
2002-03-21 02:38:53 +01:00
|
|
|
extern int display_warnings;
|
2002-12-12 05:06:28 +01:00
|
|
|
extern int kill_at;
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2002-08-01 20:34:12 +02:00
|
|
|
extern char *input_file_name;
|
2005-03-15 16:42:32 +01:00
|
|
|
extern char *spec_file_name;
|
2000-06-23 22:15:35 +02:00
|
|
|
extern const char *output_file_name;
|
2000-11-05 05:49:13 +01:00
|
|
|
extern char **debug_channels;
|
2000-11-09 21:31:18 +01:00
|
|
|
extern char **lib_path;
|
2000-06-23 22:15:35 +02:00
|
|
|
|
2004-10-08 23:11:18 +02:00
|
|
|
extern char *ld_command;
|
|
|
|
extern char *nm_command;
|
|
|
|
|
2000-06-23 22:15:35 +02:00
|
|
|
#endif /* __WINE_BUILD_H */
|