Well, SetParent doesn't work properly at all, but at least it must preserve
[wine.git] / include / module.h
blob5844b0288afdb9a5f16e71c18b9dad96b3196abb
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 "dosexe.h"
12 #include "pe_image.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 LPDOSTASK lpDosTask;
54 LPVOID dos_image; /* pointer to DOS memory (for DOS apps) */
55 LPVOID hRsrcMap; /* HRSRC 16->32 map (for 32-bit modules) */
56 } NE_MODULE;
59 typedef struct {
60 BYTE type;
61 BYTE flags;
62 BYTE segnum;
63 WORD offs WINE_PACKED;
64 } ET_ENTRY;
66 typedef struct {
67 WORD first; /* ordinal */
68 WORD last; /* ordinal */
69 WORD next; /* bundle */
70 } ET_BUNDLE;
73 /* In-memory segment table */
74 typedef struct
76 WORD filepos; /* Position in file, in sectors */
77 WORD size; /* Segment size on disk */
78 WORD flags; /* Segment flags */
79 WORD minsize; /* Min. size of segment in memory */
80 HANDLE16 hSeg; /* Selector or handle (selector - 1) */
81 /* of segment in memory */
82 } SEGTABLEENTRY;
85 /* Self-loading modules contain this structure in their first segment */
87 #include "pshpack1.h"
89 typedef struct
91 WORD version; /* Must be "A0" (0x3041) */
92 WORD reserved;
93 FARPROC16 BootApp; /* startup procedure */
94 FARPROC16 LoadAppSeg; /* procedure to load a segment */
95 FARPROC16 reserved2;
96 FARPROC16 MyAlloc; /* memory allocation procedure,
97 * wine must write this field */
98 FARPROC16 EntryAddrProc;
99 FARPROC16 ExitProc; /* exit procedure */
100 WORD reserved3[4];
101 FARPROC16 SetOwner; /* Set Owner procedure, exported by wine */
102 } SELFLOADHEADER;
104 /* Parameters for LoadModule() */
105 typedef struct
107 HGLOBAL16 hEnvironment; /* Environment segment */
108 SEGPTR cmdLine WINE_PACKED; /* Command-line */
109 SEGPTR showCmd WINE_PACKED; /* Code for ShowWindow() */
110 SEGPTR reserved WINE_PACKED;
111 } LOADPARAMS16;
113 typedef struct
115 LPSTR lpEnvAddress;
116 LPSTR lpCmdLine;
117 UINT16 *lpCmdShow;
118 DWORD dwReserved;
119 } LOADPARAMS;
121 #include "poppack.h"
123 /* internal representation of 32bit modules. per process. */
124 typedef enum {
125 MODULE32_PE = 1,
126 MODULE32_ELF,
127 MODULE32_ELFDLL
128 } MODULE32_TYPE;
130 typedef struct _wine_modref
132 struct _wine_modref *next;
133 struct _wine_modref *prev;
134 MODULE32_TYPE type;
135 union {
136 PE_MODREF pe;
137 ELF_MODREF elf;
138 } binfmt;
140 HMODULE module;
142 int nDeps;
143 struct _wine_modref **deps;
145 int flags;
146 int refCount;
148 char *filename;
149 char *modname;
150 char *short_filename;
151 char *short_modname;
152 } WINE_MODREF;
154 #define WINE_MODREF_INTERNAL 0x00000001
155 #define WINE_MODREF_NO_DLL_CALLS 0x00000002
156 #define WINE_MODREF_PROCESS_ATTACHED 0x00000004
157 #define WINE_MODREF_LOAD_AS_DATAFILE 0x00000010
158 #define WINE_MODREF_DONT_RESOLVE_REFS 0x00000020
159 #define WINE_MODREF_MARKER 0x80000000
163 /* Resource types */
164 typedef struct resource_typeinfo_s NE_TYPEINFO;
165 typedef struct resource_nameinfo_s NE_NAMEINFO;
167 #define NE_SEG_TABLE(pModule) \
168 ((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->seg_table))
170 #define NE_MODULE_TABLE(pModule) \
171 ((WORD *)((char *)(pModule) + (pModule)->modref_table))
173 #define NE_MODULE_NAME(pModule) \
174 (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
176 /* module.c */
177 extern FARPROC MODULE_GetProcAddress( HMODULE hModule, LPCSTR function, BOOL snoop );
178 extern WINE_MODREF *MODULE32_LookupHMODULE( HMODULE hModule );
179 extern BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved );
180 extern void MODULE_DllProcessDetach( BOOL bForceDetach, LPVOID lpReserved );
181 extern void MODULE_DllThreadAttach( LPVOID lpReserved );
182 extern void MODULE_DllThreadDetach( LPVOID lpReserved );
183 extern WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags );
184 extern BOOL MODULE_FreeLibrary( WINE_MODREF *wm );
185 extern WINE_MODREF *MODULE_FindModule( LPCSTR path );
186 extern BOOL MODULE_GetBinaryType( HANDLE hfile, LPCSTR filename, LPDWORD lpBinaryType );
187 extern HMODULE MODULE_CreateDummyModule( LPCSTR filename, HMODULE module32 );
188 extern FARPROC16 WINAPI WIN32_GetProcAddress16( HMODULE hmodule, LPCSTR name );
189 extern SEGPTR WINAPI HasGPHandler16( SEGPTR address );
190 extern void MODULE_WalkModref( DWORD id );
192 /* resource.c */
193 extern INT WINAPI AccessResource(HMODULE,HRSRC);
195 /* loader/ne/module.c */
196 extern NE_MODULE *NE_GetPtr( HMODULE16 hModule );
197 extern void NE_DumpModule( HMODULE16 hModule );
198 extern void NE_WalkModules(void);
199 extern void NE_RegisterModule( NE_MODULE *pModule );
200 extern WORD NE_GetOrdinal( HMODULE16 hModule, const char *name );
201 extern FARPROC16 WINAPI NE_GetEntryPoint( HMODULE16 hModule, WORD ordinal );
202 extern FARPROC16 NE_GetEntryPointEx( HMODULE16 hModule, WORD ordinal, BOOL16 snoop );
203 extern BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset );
204 extern HANDLE NE_OpenFile( NE_MODULE *pModule );
206 /* loader/ne/resource.c */
207 extern HGLOBAL16 WINAPI NE_DefResourceHandler(HGLOBAL16,HMODULE16,HRSRC16);
208 extern BOOL NE_InitResourceHandler( HMODULE16 hModule );
209 extern HRSRC16 NE_FindResource( NE_MODULE *pModule, LPCSTR name, LPCSTR type );
210 extern INT16 NE_AccessResource( NE_MODULE *pModule, HRSRC16 hRsrc );
211 extern DWORD NE_SizeofResource( NE_MODULE *pModule, HRSRC16 hRsrc );
212 extern HGLOBAL16 NE_LoadResource( NE_MODULE *pModule, HRSRC16 hRsrc );
213 extern BOOL16 NE_FreeResource( NE_MODULE *pModule, HGLOBAL16 handle );
214 extern NE_TYPEINFO *NE_FindTypeSection( LPBYTE pResTab, NE_TYPEINFO *pTypeInfo, LPCSTR typeId );
215 extern NE_NAMEINFO *NE_FindResourceFromType( LPBYTE pResTab, NE_TYPEINFO *pTypeInfo, LPCSTR resId );
217 /* loader/ne/segment.c */
218 extern BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum );
219 extern BOOL NE_LoadAllSegments( NE_MODULE *pModule );
220 extern BOOL NE_CreateSegment( NE_MODULE *pModule, int segnum );
221 extern BOOL NE_CreateAllSegments( NE_MODULE *pModule );
222 extern HINSTANCE16 NE_GetInstance( NE_MODULE *pModule );
223 extern void NE_InitializeDLLs( HMODULE16 hModule );
224 extern void NE_DllProcessAttach( HMODULE16 hModule );
226 /* loader/ne/convert.c */
227 HGLOBAL16 NE_LoadPEResource( NE_MODULE *pModule, WORD type, LPVOID bits, DWORD size );
229 /* relay32/builtin.c */
230 extern WINE_MODREF *BUILTIN32_LoadLibraryExA(LPCSTR name, DWORD flags);
231 extern HMODULE BUILTIN32_LoadExeModule( LPCSTR *filename );
232 extern void BUILTIN32_UnloadLibrary(WINE_MODREF *wm);
233 extern void *BUILTIN32_dlopen( const char *name );
234 extern int BUILTIN32_dlclose( void *handle );
236 #endif /* __WINE_MODULE_H */