Release 960114
[wine/gsoc-2012-control.git] / include / module.h
blob16417541e09925562981c4f4011820c99f83e01a
1 /*
2 * Module definitions
4 * Copyright 1995 Alexandre Julliard
5 */
7 #ifndef _WINE_MODULE_H
8 #define _WINE_MODULE_H
10 #include "wintypes.h"
12 #ifndef WINELIB
13 #pragma pack(1)
14 #endif
16 /* In-memory module structure. See 'Windows Internals' p. 219 */
17 typedef struct
19 WORD magic; /* 'NE' signature */
20 WORD count; /* Usage count */
21 WORD entry_table; /* Near ptr to entry table */
22 HMODULE next; /* Selector to next module */
23 WORD dgroup_entry; /* Near ptr to segment entry for DGROUP */
24 WORD fileinfo; /* Near ptr to file info (LOADEDFILEINFO) */
25 WORD flags; /* Module flags */
26 WORD dgroup; /* Logical segment for DGROUP */
27 WORD heap_size; /* Initial heap size */
28 WORD stack_size; /* Initial stack size */
29 WORD ip; /* Initial ip */
30 WORD cs; /* Initial cs (logical segment) */
31 WORD sp; /* Initial stack pointer */
32 WORD ss; /* Initial ss (logical segment) */
33 WORD seg_count; /* Number of segments in segment table */
34 WORD modref_count; /* Number of module references */
35 WORD nrname_size; /* Size of non-resident names table */
36 WORD seg_table; /* Near ptr to segment table */
37 WORD res_table; /* Near ptr to resource table */
38 WORD name_table; /* Near ptr to resident names table */
39 WORD modref_table; /* Near ptr to module reference table */
40 WORD import_table; /* Near ptr to imported names table */
41 DWORD nrname_fpos; /* File offset of non-resident names table */
42 WORD moveable_entries; /* Number of moveable entries in entry table */
43 WORD alignment; /* Alignment shift count */
44 WORD truetype; /* Set to 2 if TrueType font */
45 BYTE os_flags; /* Operating system flags */
46 BYTE misc_flags; /* Misc. flags */
47 HANDLE dlls_to_init; /* List of DLLs to initialize */
48 HANDLE nrname_handle; /* Handle to non-resident name table in memory */
49 WORD min_swap_area; /* Min. swap area size */
50 WORD expected_version; /* Expected Windows version */
51 WORD self_loading_sel; /* Selector used for self-loading apps. procs */
52 } NE_MODULE;
54 /* Loaded file info */
55 typedef struct
57 BYTE length; /* Length of the structure, not counting this byte */
58 BYTE fixed_media; /* File is on removable media */
59 WORD error; /* Error code (?) */
60 WORD date; /* File date in MS-DOS format */
61 WORD time; /* File time in MS-DOS format */
62 char filename[1]; /* File name */
63 } LOADEDFILEINFO;
65 /* In-memory segment table */
66 typedef struct
68 WORD filepos; /* Position in file, in sectors */
69 WORD size; /* Segment size on disk */
70 WORD flags; /* Segment flags */
71 WORD minsize; /* Min. size of segment in memory */
72 HANDLE selector; /* Selector of segment in memory */
73 } SEGTABLEENTRY;
75 /* Self-loading modules contain this structure in their first segment */
77 typedef struct
79 WORD version; /* Must be 0xA0 */
80 WORD reserved;
81 FARPROC BootApp; /* startup procedure */
82 FARPROC LoadAppSeg; /* procedure to load a segment */
83 FARPROC reserved2;
84 FARPROC MyAlloc; /* memory allocation procedure,
85 * wine must write this field */
86 FARPROC EntryAddrProc;
87 FARPROC ExitProc; /* exit procedure */
88 WORD reserved3[4];
89 FARPROC SetOwner; /* Set Owner procedure, exported by wine */
90 } SELFLOADHEADER;
92 /* Parameters for LoadModule() */
94 typedef struct
96 HANDLE hEnvironment; /* Environment segment */
97 SEGPTR cmdLine; /* Command-line */
98 SEGPTR showCmd; /* Code for ShowWindow() */
99 SEGPTR reserved;
100 } LOADPARAMS;
102 #define NE_SEG_TABLE(pModule) \
103 ((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->seg_table))
105 #define NE_MODULE_TABLE(pModule) \
106 ((WORD *)((char *)(pModule) + (pModule)->modref_table))
108 #ifndef WINELIB
109 #pragma pack(4)
110 #endif
112 extern BOOL MODULE_Init(void);
113 extern int MODULE_OpenFile( HMODULE hModule );
114 extern LPSTR MODULE_GetModuleName( HMODULE hModule );
115 extern void MODULE_RegisterModule( HMODULE hModule );
116 extern WORD MODULE_GetOrdinal( HMODULE hModule, char *name );
117 extern SEGPTR MODULE_GetEntryPoint( HMODULE hModule, WORD ordinal );
118 extern BOOL MODULE_SetEntryPoint( HMODULE hModule, WORD ordinal, WORD offset );
119 extern LPSTR MODULE_GetEntryPointName( HMODULE hModule, WORD ordinal );
121 extern BOOL NE_LoadSegment( HMODULE hModule, WORD segnum );
122 extern void NE_FixupPrologs( HMODULE hModule );
123 extern void NE_InitializeDLLs( HMODULE hModule );
125 #endif /* _WINE_MODULE_H */