Fix the case of product and company names.
[wine] / include / module.h
1 /*
2  * Module definitions
3  *
4  * Copyright 1995 Alexandre Julliard
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #ifndef __WINE_MODULE_H
22 #define __WINE_MODULE_H
23
24 #include <stdarg.h>
25 #include <windef.h>
26 #include <winbase.h>
27 #include <winreg.h>
28 #include <wine/windef16.h>
29 #include <wine/winbase16.h>
30 #include <winternl.h>
31
32   /* In-memory module structure. See 'Windows Internals' p. 219 */
33 typedef struct _NE_MODULE
34 {
35     WORD    magic;            /* 00 'NE' signature */
36     WORD    count;            /* 02 Usage count */
37     WORD    entry_table;      /* 04 Near ptr to entry table */
38     HMODULE16  next;          /* 06 Selector to next module */
39     WORD    dgroup_entry;     /* 08 Near ptr to segment entry for DGROUP */
40     WORD    fileinfo;         /* 0a Near ptr to file info (OFSTRUCT) */
41     WORD    flags;            /* 0c Module flags */
42     WORD    dgroup;           /* 0e Logical segment for DGROUP */
43     WORD    heap_size;        /* 10 Initial heap size */
44     WORD    stack_size;       /* 12 Initial stack size */
45     WORD    ip;               /* 14 Initial ip */
46     WORD    cs;               /* 16 Initial cs (logical segment) */
47     WORD    sp;               /* 18 Initial stack pointer */
48     WORD    ss;               /* 1a Initial ss (logical segment) */
49     WORD    seg_count;        /* 1c Number of segments in segment table */
50     WORD    modref_count;     /* 1e Number of module references */
51     WORD    nrname_size;      /* 20 Size of non-resident names table */
52     WORD    seg_table;        /* 22 Near ptr to segment table */
53     WORD    res_table;        /* 24 Near ptr to resource table */
54     WORD    name_table;       /* 26 Near ptr to resident names table */
55     WORD    modref_table;     /* 28 Near ptr to module reference table */
56     WORD    import_table;     /* 2a Near ptr to imported names table */
57     DWORD   nrname_fpos;      /* 2c File offset of non-resident names table */
58     WORD    moveable_entries; /* 30 Number of moveable entries in entry table*/
59     WORD    alignment;        /* 32 Alignment shift count */
60     WORD    truetype;         /* 34 Set to 2 if TrueType font */
61     BYTE    os_flags;         /* 36 Operating system flags */
62     BYTE    misc_flags;       /* 37 Misc. flags */
63     HANDLE16   dlls_to_init;  /* 38 List of DLLs to initialize */
64     HANDLE16   nrname_handle; /* 3a Handle to non-resident name table */
65     WORD    min_swap_area;    /* 3c Min. swap area size */
66     WORD    expected_version; /* 3e Expected Windows version */
67     /* From here, these are extra fields not present in normal Windows */
68     HMODULE  module32;      /* 40 PE module handle for Win32 modules */
69     HMODULE16  self;          /* 44 Handle for this module */
70     WORD    self_loading_sel; /* 46 Selector used for self-loading apps. */
71     LPVOID  hRsrcMap;         /* HRSRC 16->32 map (for 32-bit modules) */
72 } NE_MODULE;
73
74
75 typedef struct {
76     BYTE type;
77     BYTE flags;
78     BYTE segnum;
79     WORD offs WINE_PACKED;
80 } ET_ENTRY;
81
82 typedef struct {
83     WORD first; /* ordinal */
84     WORD last; /* ordinal */
85     WORD next; /* bundle */
86 } ET_BUNDLE;
87
88
89   /* In-memory segment table */
90 typedef struct
91 {
92     WORD      filepos;   /* Position in file, in sectors */
93     WORD      size;      /* Segment size on disk */
94     WORD      flags;     /* Segment flags */
95     WORD      minsize;   /* Min. size of segment in memory */
96     HANDLE16  hSeg;      /* Selector or handle (selector - 1) */
97                          /* of segment in memory */
98 } SEGTABLEENTRY;
99
100
101   /* Self-loading modules contain this structure in their first segment */
102
103 #include <pshpack1.h>
104
105 typedef struct
106 {
107     WORD      version;       /* Must be "A0" (0x3041) */
108     WORD      reserved;
109     FARPROC16 BootApp;       /* startup procedure */
110     FARPROC16 LoadAppSeg;    /* procedure to load a segment */
111     FARPROC16 reserved2;
112     FARPROC16 MyAlloc;       /* memory allocation procedure,
113                               * wine must write this field */
114     FARPROC16 EntryAddrProc;
115     FARPROC16 ExitProc;      /* exit procedure */
116     WORD      reserved3[4];
117     FARPROC16 SetOwner;      /* Set Owner procedure, exported by wine */
118 } SELFLOADHEADER;
119
120 typedef struct
121 {
122     LPSTR lpEnvAddress;
123     LPSTR lpCmdLine;
124     UINT16 *lpCmdShow;
125     DWORD dwReserved;
126 } LOADPARAMS;
127
128 #include <poppack.h>
129
130 /* internal representation of 32bit modules. per process. */
131 typedef struct _wine_modref
132 {
133         void                *dlhandle;  /* handle returned by dlopen() */
134         LDR_MODULE           ldr;
135
136         int                     nDeps;
137         struct _wine_modref     **deps;
138
139         char                    *filename;
140         char                    *modname;
141         char                    *short_filename;
142         char                    *short_modname;
143
144     char data[1];  /* space for storing filename and short_filename */
145 } WINE_MODREF;
146
147 /* Resource types */
148
149 #define NE_SEG_TABLE(pModule) \
150     ((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->seg_table))
151
152 #define NE_MODULE_TABLE(pModule) \
153     ((WORD *)((char *)(pModule) + (pModule)->modref_table))
154
155 #define NE_MODULE_NAME(pModule) \
156     (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
157
158
159 enum loadorder_type
160 {
161     LOADORDER_INVALID = 0, /* Must be 0 */
162     LOADORDER_DLL,         /* Native DLLs */
163     LOADORDER_BI,          /* Built-in modules */
164     LOADORDER_NTYPES
165 };
166
167 /* return values for MODULE_GetBinaryType */
168 enum binary_type
169 {
170     BINARY_UNKNOWN,
171     BINARY_PE_EXE,
172     BINARY_PE_DLL,
173     BINARY_WIN16,
174     BINARY_OS216,
175     BINARY_DOS,
176     BINARY_UNIX_EXE,
177     BINARY_UNIX_LIB
178 };
179
180 /* module.c */
181 extern NTSTATUS MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved );
182 extern NTSTATUS MODULE_DllThreadAttach( LPVOID lpReserved );
183 extern WINE_MODREF *MODULE_FindModule( LPCSTR path );
184 extern enum binary_type MODULE_GetBinaryType( HANDLE hfile );
185 extern FARPROC16 WINAPI WIN32_GetProcAddress16( HMODULE hmodule, LPCSTR name );
186 extern void MODULE_WalkModref( DWORD id );
187
188 /* loader/ne/module.c */
189 extern NE_MODULE *NE_GetPtr( HMODULE16 hModule );
190 extern void NE_DumpModule( HMODULE16 hModule );
191 extern void NE_WalkModules(void);
192 extern void NE_InitResourceHandler( NE_MODULE *pModule );
193 extern void NE_RegisterModule( NE_MODULE *pModule );
194 extern WORD NE_GetOrdinal( HMODULE16 hModule, const char *name );
195 extern FARPROC16 WINAPI NE_GetEntryPoint( HMODULE16 hModule, WORD ordinal );
196 extern FARPROC16 NE_GetEntryPointEx( HMODULE16 hModule, WORD ordinal, BOOL16 snoop );
197 extern BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset );
198 extern HANDLE NE_OpenFile( NE_MODULE *pModule );
199 extern DWORD NE_StartTask(void);
200
201 /* loader/ne/resource.c */
202 extern HGLOBAL16 WINAPI NE_DefResourceHandler(HGLOBAL16,HMODULE16,HRSRC16);
203
204 /* loader/ne/segment.c */
205 extern BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum );
206 extern BOOL NE_LoadAllSegments( NE_MODULE *pModule );
207 extern BOOL NE_CreateSegment( NE_MODULE *pModule, int segnum );
208 extern BOOL NE_CreateAllSegments( NE_MODULE *pModule );
209 extern HINSTANCE16 NE_GetInstance( NE_MODULE *pModule );
210 extern void NE_InitializeDLLs( HMODULE16 hModule );
211 extern void NE_DllProcessAttach( HMODULE16 hModule );
212 extern void NE_CallUserSignalProc( HMODULE16 hModule, UINT16 code );
213
214 /* loader/pe_resource.c */
215 extern HRSRC PE_FindResourceW(HMODULE,LPCWSTR,LPCWSTR);
216 extern HRSRC PE_FindResourceExW(HMODULE,LPCWSTR,LPCWSTR,WORD);
217
218 /* loader/pe_image.c */
219 extern NTSTATUS PE_LoadLibraryExA(LPCSTR, DWORD, WINE_MODREF**);
220 extern HMODULE PE_LoadImage( HANDLE hFile, LPCSTR filename, DWORD flags );
221 extern WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename,
222                                      DWORD flags, HANDLE hFile, BOOL builtin );
223 extern DWORD PE_fixup_imports(WINE_MODREF *wm);
224
225 /* loader/loadorder.c */
226 extern BOOL MODULE_GetBuiltinPath( const char *libname, const char *ext, char *filename, UINT size );
227 extern void MODULE_GetLoadOrder( enum loadorder_type plo[], const char *path, BOOL win32 );
228 extern void MODULE_AddLoadOrderOption( const char *option );
229
230 /* relay32/builtin.c */
231 extern NTSTATUS BUILTIN32_LoadLibraryExA(LPCSTR name, DWORD flags, WINE_MODREF**);
232 extern HMODULE BUILTIN32_LoadExeModule( HMODULE main );
233
234 #endif  /* __WINE_MODULE_H */