Converted the global screen buffer list to a standard list.
[wine.git] / include / module.h
blobfbc7ed58a3305f505d2620e7ac318c680cc95a86
1 /*
2 * Module definitions
4 * Copyright 1995 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __WINE_MODULE_H
22 #define __WINE_MODULE_H
24 #include <stdarg.h>
25 #include <windef.h>
26 #include <winbase.h>
27 #include <winreg.h>
28 #include <wine/windef16.h>
29 #include <wine/winbase16.h>
30 #include <winternl.h>
32 #include <pshpack1.h>
34 /* In-memory module structure. See 'Windows Internals' p. 219 */
35 typedef struct _NE_MODULE
37 WORD magic; /* 00 'NE' signature */
38 WORD count; /* 02 Usage count */
39 WORD entry_table; /* 04 Near ptr to entry table */
40 HMODULE16 next; /* 06 Selector to next module */
41 WORD dgroup_entry; /* 08 Near ptr to segment entry for DGROUP */
42 WORD fileinfo; /* 0a Near ptr to file info (OFSTRUCT) */
43 WORD flags; /* 0c Module flags */
44 WORD dgroup; /* 0e Logical segment for DGROUP */
45 WORD heap_size; /* 10 Initial heap size */
46 WORD stack_size; /* 12 Initial stack size */
47 WORD ip; /* 14 Initial ip */
48 WORD cs; /* 16 Initial cs (logical segment) */
49 WORD sp; /* 18 Initial stack pointer */
50 WORD ss; /* 1a Initial ss (logical segment) */
51 WORD seg_count; /* 1c Number of segments in segment table */
52 WORD modref_count; /* 1e Number of module references */
53 WORD nrname_size; /* 20 Size of non-resident names table */
54 WORD seg_table; /* 22 Near ptr to segment table */
55 WORD res_table; /* 24 Near ptr to resource table */
56 WORD name_table; /* 26 Near ptr to resident names table */
57 WORD modref_table; /* 28 Near ptr to module reference table */
58 WORD import_table; /* 2a Near ptr to imported names table */
59 DWORD nrname_fpos; /* 2c File offset of non-resident names table */
60 WORD moveable_entries; /* 30 Number of moveable entries in entry table*/
61 WORD alignment; /* 32 Alignment shift count */
62 WORD truetype; /* 34 Set to 2 if TrueType font */
63 BYTE os_flags; /* 36 Operating system flags */
64 BYTE misc_flags; /* 37 Misc. flags */
65 HANDLE16 dlls_to_init; /* 38 List of DLLs to initialize */
66 HANDLE16 nrname_handle; /* 3a Handle to non-resident name table */
67 WORD min_swap_area; /* 3c Min. swap area size */
68 WORD expected_version; /* 3e Expected Windows version */
69 /* From here, these are extra fields not present in normal Windows */
70 HMODULE module32; /* 40 PE module handle for Win32 modules */
71 HMODULE16 self; /* 44 Handle for this module */
72 WORD self_loading_sel; /* 46 Selector used for self-loading apps. */
73 LPVOID hRsrcMap; /* HRSRC 16->32 map (for 32-bit modules) */
74 HANDLE fd; /* handle to the binary file */
75 } NE_MODULE;
78 typedef struct {
79 BYTE type;
80 BYTE flags;
81 BYTE segnum;
82 WORD offs;
83 } ET_ENTRY;
85 typedef struct {
86 WORD first; /* ordinal */
87 WORD last; /* ordinal */
88 WORD next; /* bundle */
89 } ET_BUNDLE;
92 /* In-memory segment table */
93 typedef struct
95 WORD filepos; /* Position in file, in sectors */
96 WORD size; /* Segment size on disk */
97 WORD flags; /* Segment flags */
98 WORD minsize; /* Min. size of segment in memory */
99 HANDLE16 hSeg; /* Selector or handle (selector - 1) */
100 /* of segment in memory */
101 } SEGTABLEENTRY;
104 /* THHOOK Kernel Data Structure */
105 typedef struct _THHOOK
107 HANDLE16 hGlobalHeap; /* 00 (handle BURGERMASTER) */
108 WORD pGlobalHeap; /* 02 (selector BURGERMASTER) */
109 HMODULE16 hExeHead; /* 04 hFirstModule */
110 HMODULE16 hExeSweep; /* 06 (unused) */
111 HANDLE16 TopPDB; /* 08 (handle of KERNEL PDB) */
112 HANDLE16 HeadPDB; /* 0A (first PDB in list) */
113 HANDLE16 TopSizePDB; /* 0C (unused) */
114 HTASK16 HeadTDB; /* 0E hFirstTask */
115 HTASK16 CurTDB; /* 10 hCurrentTask */
116 HTASK16 LoadTDB; /* 12 (unused) */
117 HTASK16 LockTDB; /* 14 hLockedTask */
118 } THHOOK;
120 extern THHOOK *pThhook;
122 #include <poppack.h>
124 /* Resource types */
126 #define NE_SEG_TABLE(pModule) \
127 ((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->seg_table))
129 #define NE_MODULE_NAME(pModule) \
130 (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
133 enum loadorder_type
135 LOADORDER_INVALID = 0, /* Must be 0 */
136 LOADORDER_DLL, /* Native DLLs */
137 LOADORDER_BI, /* Built-in modules */
138 LOADORDER_NTYPES
141 /* return values for MODULE_GetBinaryType */
142 enum binary_type
144 BINARY_UNKNOWN,
145 BINARY_PE_EXE,
146 BINARY_PE_DLL,
147 BINARY_WIN16,
148 BINARY_OS216,
149 BINARY_DOS,
150 BINARY_UNIX_EXE,
151 BINARY_UNIX_LIB
154 /* module.c */
155 extern NTSTATUS MODULE_DllThreadAttach( LPVOID lpReserved );
156 extern enum binary_type MODULE_GetBinaryType( HANDLE hfile, void **res_start, void **res_end );
158 /* ne_module.c */
159 extern NE_MODULE *NE_GetPtr( HMODULE16 hModule );
160 extern WORD NE_GetOrdinal( HMODULE16 hModule, const char *name );
161 extern FARPROC16 WINAPI NE_GetEntryPoint( HMODULE16 hModule, WORD ordinal );
162 extern FARPROC16 NE_GetEntryPointEx( HMODULE16 hModule, WORD ordinal, BOOL16 snoop );
163 extern BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset );
164 extern HANDLE NE_OpenFile( NE_MODULE *pModule );
165 extern DWORD NE_StartTask(void);
167 /* resource16.c */
168 extern HGLOBAL16 WINAPI NE_DefResourceHandler(HGLOBAL16,HMODULE16,HRSRC16);
170 /* ne_segment.c */
171 extern BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum );
172 extern BOOL NE_LoadAllSegments( NE_MODULE *pModule );
173 extern BOOL NE_CreateSegment( NE_MODULE *pModule, int segnum );
174 extern BOOL NE_CreateAllSegments( NE_MODULE *pModule );
175 extern HINSTANCE16 NE_GetInstance( NE_MODULE *pModule );
176 extern void NE_InitializeDLLs( HMODULE16 hModule );
177 extern void NE_DllProcessAttach( HMODULE16 hModule );
178 extern void NE_CallUserSignalProc( HMODULE16 hModule, UINT16 code );
180 /* task.c */
181 extern void TASK_CreateMainTask(void);
182 extern HTASK16 TASK_SpawnTask( NE_MODULE *pModule, WORD cmdShow,
183 LPCSTR cmdline, BYTE len, HANDLE *hThread );
184 extern void TASK_ExitTask(void);
185 extern HTASK16 TASK_GetTaskFromThread( DWORD thread );
186 extern TDB *TASK_GetCurrent(void);
187 extern void TASK_InstallTHHook( THHOOK *pNewThook );
189 /* loadorder.c */
190 extern void MODULE_GetLoadOrderW( enum loadorder_type plo[], const WCHAR *app_name,
191 const WCHAR *path );
193 #endif /* __WINE_MODULE_H */