Removed "elfdll" load order option and updated documentation.
[wine/multimedia.git] / include / module.h
blobef9bec2f70f739999183724948366a14465dfafa
1 /*
2 * Module definitions
4 * Copyright 1995 Alexandre Julliard
5 */
7 #ifndef __WINE_MODULE_H
8 #define __WINE_MODULE_H
10 #include "windef.h"
11 #include "winbase.h"
12 #include "wine/windef16.h"
14 /* In-memory module structure. See 'Windows Internals' p. 219 */
15 typedef struct _NE_MODULE
17 WORD magic; /* 00 'NE' signature */
18 WORD count; /* 02 Usage count */
19 WORD entry_table; /* 04 Near ptr to entry table */
20 HMODULE16 next; /* 06 Selector to next module */
21 WORD dgroup_entry; /* 08 Near ptr to segment entry for DGROUP */
22 WORD fileinfo; /* 0a Near ptr to file info (OFSTRUCT) */
23 WORD flags; /* 0c Module flags */
24 WORD dgroup; /* 0e Logical segment for DGROUP */
25 WORD heap_size; /* 10 Initial heap size */
26 WORD stack_size; /* 12 Initial stack size */
27 WORD ip; /* 14 Initial ip */
28 WORD cs; /* 16 Initial cs (logical segment) */
29 WORD sp; /* 18 Initial stack pointer */
30 WORD ss; /* 1a Initial ss (logical segment) */
31 WORD seg_count; /* 1c Number of segments in segment table */
32 WORD modref_count; /* 1e Number of module references */
33 WORD nrname_size; /* 20 Size of non-resident names table */
34 WORD seg_table; /* 22 Near ptr to segment table */
35 WORD res_table; /* 24 Near ptr to resource table */
36 WORD name_table; /* 26 Near ptr to resident names table */
37 WORD modref_table; /* 28 Near ptr to module reference table */
38 WORD import_table; /* 2a Near ptr to imported names table */
39 DWORD nrname_fpos; /* 2c File offset of non-resident names table */
40 WORD moveable_entries; /* 30 Number of moveable entries in entry table*/
41 WORD alignment; /* 32 Alignment shift count */
42 WORD truetype; /* 34 Set to 2 if TrueType font */
43 BYTE os_flags; /* 36 Operating system flags */
44 BYTE misc_flags; /* 37 Misc. flags */
45 HANDLE16 dlls_to_init; /* 38 List of DLLs to initialize */
46 HANDLE16 nrname_handle; /* 3a Handle to non-resident name table */
47 WORD min_swap_area; /* 3c Min. swap area size */
48 WORD expected_version; /* 3e Expected Windows version */
49 /* From here, these are extra fields not present in normal Windows */
50 HMODULE module32; /* 40 PE module handle for Win32 modules */
51 HMODULE16 self; /* 44 Handle for this module */
52 WORD self_loading_sel; /* 46 Selector used for self-loading apps. */
53 LPVOID hRsrcMap; /* HRSRC 16->32 map (for 32-bit modules) */
54 } NE_MODULE;
57 typedef struct {
58 BYTE type;
59 BYTE flags;
60 BYTE segnum;
61 WORD offs WINE_PACKED;
62 } ET_ENTRY;
64 typedef struct {
65 WORD first; /* ordinal */
66 WORD last; /* ordinal */
67 WORD next; /* bundle */
68 } ET_BUNDLE;
71 /* In-memory segment table */
72 typedef struct
74 WORD filepos; /* Position in file, in sectors */
75 WORD size; /* Segment size on disk */
76 WORD flags; /* Segment flags */
77 WORD minsize; /* Min. size of segment in memory */
78 HANDLE16 hSeg; /* Selector or handle (selector - 1) */
79 /* of segment in memory */
80 } SEGTABLEENTRY;
83 /* Self-loading modules contain this structure in their first segment */
85 #include "pshpack1.h"
87 typedef struct
89 WORD version; /* Must be "A0" (0x3041) */
90 WORD reserved;
91 FARPROC16 BootApp; /* startup procedure */
92 FARPROC16 LoadAppSeg; /* procedure to load a segment */
93 FARPROC16 reserved2;
94 FARPROC16 MyAlloc; /* memory allocation procedure,
95 * wine must write this field */
96 FARPROC16 EntryAddrProc;
97 FARPROC16 ExitProc; /* exit procedure */
98 WORD reserved3[4];
99 FARPROC16 SetOwner; /* Set Owner procedure, exported by wine */
100 } SELFLOADHEADER;
102 /* Parameters for LoadModule() */
103 typedef struct
105 HGLOBAL16 hEnvironment; /* Environment segment */
106 SEGPTR cmdLine WINE_PACKED; /* Command-line */
107 SEGPTR showCmd WINE_PACKED; /* Code for ShowWindow() */
108 SEGPTR reserved WINE_PACKED;
109 } LOADPARAMS16;
111 typedef struct
113 LPSTR lpEnvAddress;
114 LPSTR lpCmdLine;
115 UINT16 *lpCmdShow;
116 DWORD dwReserved;
117 } LOADPARAMS;
119 #include "poppack.h"
121 /* internal representation of 32bit modules. per process. */
122 typedef struct _wine_modref
124 struct _wine_modref *next;
125 struct _wine_modref *prev;
126 HMODULE module;
127 HMODULE16 hDummyMod; /* Win16 dummy module */
128 void *dlhandle; /* handle returned by dlopen() */
129 int tlsindex; /* TLS index or -1 if none */
131 FARPROC (*find_export)( struct _wine_modref *wm, LPCSTR func, BOOL snoop );
133 int nDeps;
134 struct _wine_modref **deps;
136 int flags;
137 int refCount;
139 char *filename;
140 char *modname;
141 char *short_filename;
142 char *short_modname;
143 } WINE_MODREF;
145 #define WINE_MODREF_INTERNAL 0x00000001
146 #define WINE_MODREF_NO_DLL_CALLS 0x00000002
147 #define WINE_MODREF_PROCESS_ATTACHED 0x00000004
148 #define WINE_MODREF_DONT_RESOLVE_REFS 0x00000020
149 #define WINE_MODREF_MARKER 0x80000000
152 /* Resource types */
153 typedef struct resource_typeinfo_s NE_TYPEINFO;
154 typedef struct resource_nameinfo_s NE_NAMEINFO;
156 #define NE_SEG_TABLE(pModule) \
157 ((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->seg_table))
159 #define NE_MODULE_TABLE(pModule) \
160 ((WORD *)((char *)(pModule) + (pModule)->modref_table))
162 #define NE_MODULE_NAME(pModule) \
163 (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
165 #define PE_HEADER(module) \
166 ((IMAGE_NT_HEADERS*)((LPBYTE)(module) + \
167 (((IMAGE_DOS_HEADER*)(module))->e_lfanew)))
169 #define PE_SECTIONS(module) \
170 ((IMAGE_SECTION_HEADER*)((LPBYTE)&PE_HEADER(module)->OptionalHeader + \
171 PE_HEADER(module)->FileHeader.SizeOfOptionalHeader))
173 /* module.c */
174 extern WINE_MODREF *MODULE_AllocModRef( HMODULE hModule, LPCSTR filename );
175 extern FARPROC MODULE_GetProcAddress( HMODULE hModule, LPCSTR function, BOOL snoop );
176 extern BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved );
177 extern void MODULE_DllProcessDetach( BOOL bForceDetach, LPVOID lpReserved );
178 extern void MODULE_DllThreadAttach( LPVOID lpReserved );
179 extern void MODULE_DllThreadDetach( LPVOID lpReserved );
180 extern WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags );
181 extern BOOL MODULE_FreeLibrary( WINE_MODREF *wm );
182 extern WINE_MODREF *MODULE_FindModule( LPCSTR path );
183 extern HMODULE MODULE_CreateDummyModule( LPCSTR filename, HMODULE module32 );
184 extern FARPROC16 WINAPI WIN32_GetProcAddress16( HMODULE hmodule, LPCSTR name );
185 extern SEGPTR WINAPI HasGPHandler16( SEGPTR address );
186 extern void MODULE_WalkModref( DWORD id );
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_RegisterModule( NE_MODULE *pModule );
193 extern WORD NE_GetOrdinal( HMODULE16 hModule, const char *name );
194 extern FARPROC16 WINAPI NE_GetEntryPoint( HMODULE16 hModule, WORD ordinal );
195 extern FARPROC16 NE_GetEntryPointEx( HMODULE16 hModule, WORD ordinal, BOOL16 snoop );
196 extern BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset );
197 extern HANDLE NE_OpenFile( NE_MODULE *pModule );
199 /* loader/ne/resource.c */
200 extern HGLOBAL16 WINAPI NE_DefResourceHandler(HGLOBAL16,HMODULE16,HRSRC16);
201 extern BOOL NE_InitResourceHandler( HMODULE16 hModule );
202 extern HRSRC16 NE_FindResource( NE_MODULE *pModule, LPCSTR name, LPCSTR type );
203 extern DWORD NE_SizeofResource( NE_MODULE *pModule, HRSRC16 hRsrc );
204 extern HGLOBAL16 NE_LoadResource( NE_MODULE *pModule, HRSRC16 hRsrc );
205 extern BOOL16 NE_FreeResource( NE_MODULE *pModule, HGLOBAL16 handle );
206 extern NE_TYPEINFO *NE_FindTypeSection( LPBYTE pResTab, NE_TYPEINFO *pTypeInfo, LPCSTR typeId );
207 extern NE_NAMEINFO *NE_FindResourceFromType( LPBYTE pResTab, NE_TYPEINFO *pTypeInfo, LPCSTR resId );
209 /* loader/ne/segment.c */
210 extern BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum );
211 extern BOOL NE_LoadAllSegments( NE_MODULE *pModule );
212 extern BOOL NE_CreateSegment( NE_MODULE *pModule, int segnum );
213 extern BOOL NE_CreateAllSegments( NE_MODULE *pModule );
214 extern HINSTANCE16 NE_GetInstance( NE_MODULE *pModule );
215 extern void NE_InitializeDLLs( HMODULE16 hModule );
216 extern void NE_DllProcessAttach( HMODULE16 hModule );
218 /* loader/ne/convert.c */
219 HGLOBAL16 NE_LoadPEResource( NE_MODULE *pModule, WORD type, LPVOID bits, DWORD size );
221 /* loader/pe_resource.c */
222 extern HRSRC PE_FindResourceW(HMODULE,LPCWSTR,LPCWSTR);
223 extern HRSRC PE_FindResourceExW(HMODULE,LPCWSTR,LPCWSTR,WORD);
224 extern DWORD PE_SizeofResource(HRSRC);
225 extern HGLOBAL PE_LoadResource(HMODULE,HRSRC);
227 /* loader/pe_image.c */
228 extern WINE_MODREF *PE_LoadLibraryExA(LPCSTR, DWORD);
229 extern HMODULE PE_LoadImage( HANDLE hFile, LPCSTR filename, DWORD flags );
230 extern WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename,
231 DWORD flags, HFILE hFile, BOOL builtin );
232 extern void PE_InitTls(void);
233 extern BOOL PE_InitDLL( HMODULE module, DWORD type, LPVOID lpReserved );
235 /* loader/elf.c */
236 extern WINE_MODREF *ELF_LoadLibraryExA( LPCSTR libname, DWORD flags);
238 /* relay32/builtin.c */
239 extern WINE_MODREF *BUILTIN32_LoadLibraryExA(LPCSTR name, DWORD flags);
240 extern HMODULE BUILTIN32_LoadExeModule( HMODULE main );
241 extern void *BUILTIN32_dlopen( const char *name );
242 extern int BUILTIN32_dlclose( void *handle );
244 #endif /* __WINE_MODULE_H */