Release 960314
[wine.git] / include / module.h
blobc19f764aa4509004e72fe3ea4ab68cd57eac420b
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 (OFSTRUCT) */
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 /* In-memory segment table */
55 typedef struct
57 WORD filepos; /* Position in file, in sectors */
58 WORD size; /* Segment size on disk */
59 WORD flags; /* Segment flags */
60 WORD minsize; /* Min. size of segment in memory */
61 HANDLE selector; /* Selector of segment in memory */
62 } SEGTABLEENTRY;
64 /* Self-loading modules contain this structure in their first segment */
66 typedef struct
68 WORD version; /* Must be 0xA0 */
69 WORD reserved;
70 FARPROC BootApp; /* startup procedure */
71 FARPROC LoadAppSeg; /* procedure to load a segment */
72 FARPROC reserved2;
73 FARPROC MyAlloc; /* memory allocation procedure,
74 * wine must write this field */
75 FARPROC EntryAddrProc;
76 FARPROC ExitProc; /* exit procedure */
77 WORD reserved3[4];
78 FARPROC SetOwner; /* Set Owner procedure, exported by wine */
79 } SELFLOADHEADER;
81 /* Parameters for LoadModule() */
83 typedef struct
85 HANDLE hEnvironment; /* Environment segment */
86 SEGPTR cmdLine; /* Command-line */
87 SEGPTR showCmd; /* Code for ShowWindow() */
88 SEGPTR reserved;
89 } LOADPARAMS;
91 #define NE_SEG_TABLE(pModule) \
92 ((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->seg_table))
94 #define NE_MODULE_TABLE(pModule) \
95 ((WORD *)((char *)(pModule) + (pModule)->modref_table))
97 #define NE_MODULE_NAME(pModule) \
98 (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
100 #ifndef WINELIB
101 #pragma pack(4)
102 #endif
104 extern BOOL MODULE_Init(void);
105 extern int MODULE_OpenFile( HMODULE hModule );
106 extern LPSTR MODULE_GetModuleName( HMODULE hModule );
107 extern void MODULE_RegisterModule( HMODULE hModule );
108 extern WORD MODULE_GetOrdinal( HMODULE hModule, char *name );
109 extern SEGPTR MODULE_GetEntryPoint( HMODULE hModule, WORD ordinal );
110 extern BOOL MODULE_SetEntryPoint( HMODULE hModule, WORD ordinal, WORD offset );
111 extern LPSTR MODULE_GetEntryPointName( HMODULE hModule, WORD ordinal );
113 extern BOOL NE_LoadSegment( HMODULE hModule, WORD segnum );
114 extern void NE_FixupPrologs( HMODULE hModule );
115 extern void NE_InitializeDLLs( HMODULE hModule );
117 #endif /* _WINE_MODULE_H */