Do not create a window each time VGA_DoSetMode is called. The window
[wine/multimedia.git] / tools / winedump / winedump.h
blob58371feb3527aa820261ae3abafd6cdea842f0e5
1 /*
2 * Winedump - A Wine DLL tool
4 * Copyright 2000 Jon Griffiths
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * References:
21 * DLL symbol extraction based on file format from alib (anthonyw.cjb.net).
23 * Option processing shamelessly cadged from winebuild (www.winehq.com).
25 * All the cool functionality (prototyping, call tracing, forwarding)
26 * relies on Patrik Stridvall's 'function_grep.pl' script to work.
28 * http://msdn.microsoft.com/library/periodic/period96/msj/S330.htm
29 * This article provides both a description and freely downloadble
30 * implementation, in source code form, of how to extract symbols
31 * from Win32 PE executables/DLL's.
33 * http://www.kegel.com/mangle.html
34 * Gives information on the name mangling scheme used by MS compilers,
35 * used as the starting point for the code here. Contains a few
36 * mistakes and some incorrect assumptions, but the lists of types
37 * are pure gold.
39 #ifndef __WINE_WINEDUMP_H
40 #define __WINE_WINEDUMP_H
42 #include <stdlib.h>
43 #include <stdio.h>
44 #include <string.h>
45 #include <ctype.h>
46 #include <errno.h>
47 #include <assert.h>
48 #include <stdarg.h>
50 /* Argument type constants */
51 #define MAX_FUNCTION_ARGS 32
53 #define ARG_VOID 0x0
54 #define ARG_STRING 0x1
55 #define ARG_WIDE_STRING 0x2
56 #define ARG_POINTER 0x3
57 #define ARG_LONG 0x4
58 #define ARG_DOUBLE 0x5
59 #define ARG_STRUCT 0x6 /* By value */
60 #define ARG_FLOAT 0x7
61 #define ARG_VARARGS 0x8
63 /* Compound type flags */
64 #define CT_BY_REFERENCE 0x1
65 #define CT_VOLATILE 0x2
66 #define CT_CONST 0x4
67 #define CT_EXTENDED 0x8
69 /* symbol flags */
70 #define SYM_CDECL 0x1
71 #define SYM_STDCALL 0x2
72 #define SYM_THISCALL 0x4
73 #define SYM_DATA 0x8 /* Data, not a function */
75 typedef enum {NONE, DMGL, SPEC, DUMP} Mode;
77 /* Structure holding a parsed symbol */
78 typedef struct __parsed_symbol
80 char *symbol;
81 int ordinal;
82 char *return_text;
83 char return_type;
84 char *function_name;
85 unsigned int varargs;
86 unsigned int argc;
87 unsigned int flags;
88 char arg_type [MAX_FUNCTION_ARGS];
89 char arg_flag [MAX_FUNCTION_ARGS];
90 char *arg_text [MAX_FUNCTION_ARGS];
91 char *arg_name [MAX_FUNCTION_ARGS];
92 } parsed_symbol;
94 /* All globals */
95 typedef struct __globals
97 Mode mode; /* SPEC, DEMANGLE or DUMP */
99 /* Options: generic */
100 int do_quiet; /* -q */
101 int do_verbose; /* -v */
103 /* Option arguments: generic */
104 const char *input_name; /* */
105 const char *input_module; /* input module name generated after input_name according mode */
107 /* Options: spec mode */
108 int do_code; /* -c, -t, -f */
109 int do_trace; /* -t, -f */
110 int do_cdecl; /* -C */
111 int do_documentation; /* -D */
113 /* Options: dump mode */
114 int do_demangle; /* -d */
115 int do_dumpheader; /* -f */
117 /* Option arguments: spec mode */
118 int start_ordinal; /* -s */
119 int end_ordinal; /* -e */
120 const char *directory; /* -I */
121 const char *forward_dll; /* -f */
122 const char *dll_name; /* -o */
123 char *uc_dll_name; /* -o */
125 /* Option arguments: dump mode */
126 const char *dumpsect; /* -j */
128 /* internal options */
129 int do_ordinals;
130 } _globals;
132 extern _globals globals;
134 /* Names to use for output DLL */
135 #define OUTPUT_DLL_NAME \
136 (globals.dll_name ? globals.dll_name : (globals.input_module ? globals.input_module : globals.input_name))
137 #define OUTPUT_UC_DLL_NAME globals.uc_dll_name
139 /* Verbosity levels */
140 #define QUIET (globals.do_quiet)
141 #define NORMAL (!QUIET)
142 #define VERBOSE (globals.do_verbose)
144 /* Default calling convention */
145 #define CALLING_CONVENTION (globals.do_cdecl ? SYM_CDECL : SYM_STDCALL)
147 /* Image functions */
148 void dump_file(const char* name);
150 /* DLL functions */
151 void dll_open (const char *dll_name);
153 int dll_next_symbol (parsed_symbol * sym);
155 /* Symbol functions */
156 int symbol_init(parsed_symbol* symbol, const char* name);
158 int symbol_demangle (parsed_symbol *symbol);
160 int symbol_search (parsed_symbol *symbol);
162 void symbol_clear(parsed_symbol *sym);
164 int symbol_is_valid_c(const parsed_symbol *sym);
166 const char *symbol_get_call_convention(const parsed_symbol *sym);
168 const char *symbol_get_spec_type (const parsed_symbol *sym, size_t arg);
170 void symbol_clean_string (const char *string);
172 int symbol_get_type (const char *string);
174 /* Output functions */
175 void output_spec_preamble (void);
177 void output_spec_symbol (const parsed_symbol *sym);
179 void output_header_preamble (void);
181 void output_header_symbol (const parsed_symbol *sym);
183 void output_c_preamble (void);
185 void output_c_symbol (const parsed_symbol *sym);
187 void output_prototype (FILE *file, const parsed_symbol *sym);
189 void output_makefile (void);
191 void output_install_script (void);
193 /* Misc functions */
194 char *str_create (size_t num_str, ...);
196 char *str_create_num (size_t num_str, int num, ...);
198 char *str_substring(const char *start, const char *end);
200 char *str_replace (char *str, const char *oldstr, const char *newstr);
202 const char *str_match (const char *str, const char *match, int *found);
204 const char *str_find_set (const char *str, const char *findset);
206 char *str_toupper (char *str);
208 FILE *open_file (const char *name, const char *ext, const char *mode);
210 #ifdef __GNUC__
211 void do_usage (void) __attribute__ ((noreturn));
212 void fatal (const char *message) __attribute__ ((noreturn));
213 #else
214 void do_usage (void);
215 void fatal (const char *message);
216 #endif
220 #endif /* __WINE_WINEDUMP_H */