Release 980927
[wine.git] / include / module.h
blob96ca217eb8d4756b955818f7317eb7ffce4130d7
1 /*
2 * Module definitions
4 * Copyright 1995 Alexandre Julliard
5 */
7 #ifndef __WINE_MODULE_H
8 #define __WINE_MODULE_H
10 #include "wintypes.h"
11 #include "pe_image.h"
13 struct _DOSTASK;
15 /* In-memory module structure. See 'Windows Internals' p. 219 */
16 typedef struct _NE_MODULE
18 WORD magic; /* 00 'NE' signature */
19 WORD count; /* 02 Usage count */
20 WORD entry_table; /* 04 Near ptr to entry table */
21 HMODULE16 next; /* 06 Selector to next module */
22 WORD dgroup_entry; /* 08 Near ptr to segment entry for DGROUP */
23 WORD fileinfo; /* 0a Near ptr to file info (OFSTRUCT) */
24 WORD flags; /* 0c Module flags */
25 WORD dgroup; /* 0e Logical segment for DGROUP */
26 WORD heap_size; /* 10 Initial heap size */
27 WORD stack_size; /* 12 Initial stack size */
28 WORD ip; /* 14 Initial ip */
29 WORD cs; /* 16 Initial cs (logical segment) */
30 WORD sp; /* 18 Initial stack pointer */
31 WORD ss; /* 1a Initial ss (logical segment) */
32 WORD seg_count; /* 1c Number of segments in segment table */
33 WORD modref_count; /* 1e Number of module references */
34 WORD nrname_size; /* 20 Size of non-resident names table */
35 WORD seg_table; /* 22 Near ptr to segment table */
36 WORD res_table; /* 24 Near ptr to resource table */
37 WORD name_table; /* 26 Near ptr to resident names table */
38 WORD modref_table; /* 28 Near ptr to module reference table */
39 WORD import_table; /* 2a Near ptr to imported names table */
40 DWORD nrname_fpos; /* 2c File offset of non-resident names table */
41 WORD moveable_entries; /* 30 Number of moveable entries in entry table*/
42 WORD alignment; /* 32 Alignment shift count */
43 WORD truetype; /* 34 Set to 2 if TrueType font */
44 BYTE os_flags; /* 36 Operating system flags */
45 BYTE misc_flags; /* 37 Misc. flags */
46 HANDLE16 dlls_to_init; /* 38 List of DLLs to initialize */
47 HANDLE16 nrname_handle; /* 3a Handle to non-resident name table */
48 WORD min_swap_area; /* 3c Min. swap area size */
49 WORD expected_version; /* 3e Expected Windows version */
50 /* From here, these are extra fields not present in normal Windows */
51 HMODULE32 module32; /* 40 PE module handle for Win32 modules */
52 HMODULE16 self; /* 44 Handle for this module */
53 WORD self_loading_sel; /* 46 Selector used for self-loading apps. */
54 struct _DOSTASK *lpDosTask;
55 LPVOID dos_image; /* pointer to DOS memory (for DOS apps) */
56 } NE_MODULE;
59 /* In-memory segment table */
60 typedef struct
62 WORD filepos; /* Position in file, in sectors */
63 WORD size; /* Segment size on disk */
64 WORD flags; /* Segment flags */
65 WORD minsize; /* Min. size of segment in memory */
66 HANDLE16 hSeg; /* Selector or handle (selector - 1) */
67 /* of segment in memory */
68 } SEGTABLEENTRY;
71 /* Self-loading modules contain this structure in their first segment */
73 #pragma pack(1)
75 typedef struct
77 WORD version; /* Must be 0xA0 */
78 WORD reserved;
79 FARPROC16 BootApp; /* startup procedure */
80 FARPROC16 LoadAppSeg; /* procedure to load a segment */
81 FARPROC16 reserved2;
82 FARPROC16 MyAlloc; /* memory allocation procedure,
83 * wine must write this field */
84 FARPROC16 EntryAddrProc;
85 FARPROC16 ExitProc; /* exit procedure */
86 WORD reserved3[4];
87 FARPROC16 SetOwner; /* Set Owner procedure, exported by wine */
88 } SELFLOADHEADER;
90 /* Parameters for LoadModule() */
91 typedef struct
93 HGLOBAL16 hEnvironment; /* Environment segment */
94 SEGPTR cmdLine WINE_PACKED; /* Command-line */
95 SEGPTR showCmd WINE_PACKED; /* Code for ShowWindow() */
96 SEGPTR reserved WINE_PACKED;
97 } LOADPARAMS;
99 typedef struct
101 LPSTR lpEnvAddress;
102 LPSTR lpCmdLine;
103 UINT16 *lpCmdShow;
104 DWORD dwReserved;
105 } LOADPARAMS32;
107 #pragma pack(4)
109 /* internal representation of 32bit modules. per process. */
110 typedef enum { MODULE32_PE=1, MODULE32_ELF /* ,... */ } MODULE32_TYPE;
111 typedef struct _wine_modref
113 struct _wine_modref *next;
114 MODULE32_TYPE type;
115 union {
116 PE_MODREF pe;
117 /* ELF_MODREF elf; */
118 } binfmt;
120 HMODULE32 module;
122 char *modname;
123 char *shortname;
124 char *longname;
125 } WINE_MODREF;
127 /* Resource types */
128 typedef struct resource_typeinfo_s NE_TYPEINFO;
129 typedef struct resource_nameinfo_s NE_NAMEINFO;
131 #define NE_SEG_TABLE(pModule) \
132 ((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->seg_table))
134 #define NE_MODULE_TABLE(pModule) \
135 ((WORD *)((char *)(pModule) + (pModule)->modref_table))
137 #define NE_MODULE_NAME(pModule) \
138 (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
140 /* module.c */
141 extern FARPROC32 MODULE_GetProcAddress32( struct _PDB32*pdb,HMODULE32 hModule,LPCSTR function );
142 extern WINE_MODREF *MODULE32_LookupHMODULE( struct _PDB32 *process, HMODULE32 hModule );
143 extern HMODULE32 MODULE_FindModule32( struct _PDB32 *process, LPCSTR path );
144 extern HMODULE32 MODULE_CreateDummyModule( const OFSTRUCT *ofs );
145 extern FARPROC16 MODULE_GetWndProcEntry16( const char *name );
146 extern FARPROC16 WINAPI WIN32_GetProcAddress16( HMODULE32 hmodule, LPCSTR name );
147 extern SEGPTR WINAPI HasGPHandler( SEGPTR address );
149 /* loader/ne/module.c */
150 extern NE_MODULE *NE_GetPtr( HMODULE16 hModule );
151 extern void NE_DumpModule( HMODULE16 hModule );
152 extern void NE_WalkModules(void);
153 extern void NE_RegisterModule( NE_MODULE *pModule );
154 extern WORD NE_GetOrdinal( HMODULE16 hModule, const char *name );
155 extern FARPROC16 NE_GetEntryPoint( HMODULE16 hModule, WORD ordinal );
156 extern BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset );
157 extern int NE_OpenFile( NE_MODULE *pModule );
158 extern HINSTANCE16 NE_LoadModule( LPCSTR name, HINSTANCE16 *hPrevInstance,
159 BOOL32 implicit, BOOL32 lib_only );
161 /* loader/ne/resource.c */
162 extern HGLOBAL16 WINAPI NE_DefResourceHandler(HGLOBAL16,HMODULE16,HRSRC16);
163 extern BOOL32 NE_InitResourceHandler( HMODULE16 hModule );
165 /* loader/ne/segment.c */
166 extern BOOL32 NE_LoadSegment( NE_MODULE *pModule, WORD segnum );
167 extern BOOL32 NE_LoadAllSegments( NE_MODULE *pModule );
168 extern void NE_FixupPrologs( NE_MODULE *pModule );
169 extern void NE_InitializeDLLs( HMODULE16 hModule );
170 extern BOOL32 NE_CreateSegments( NE_MODULE *pModule );
171 extern HINSTANCE16 NE_CreateInstance( NE_MODULE *pModule, HINSTANCE16 *prev,
172 BOOL32 lib_only );
174 /* if1632/builtin.c */
175 extern BOOL32 BUILTIN_Init(void);
176 extern HMODULE16 BUILTIN_LoadModule( LPCSTR name, BOOL32 force );
177 extern LPCSTR BUILTIN_GetEntryPoint16( WORD cs, WORD ip, WORD *pOrd );
178 extern BOOL32 BUILTIN_ParseDLLOptions( const char *str );
179 extern void BUILTIN_PrintDLLs(void);
181 /* relay32/builtin.c */
182 extern HMODULE32 BUILTIN32_LoadModule( LPCSTR name, BOOL32 force,
183 struct _PDB32 *process );
185 /* if1632/builtin.c */
186 extern HMODULE16 (*fnBUILTIN_LoadModule)(LPCSTR name, BOOL32 force);
188 #endif /* __WINE_MODULE_H */