source: trunk/include/win/module.h@ 1566

Last change on this file since 1566 was 1566, checked in by achimha, 26 years ago

comctl32 merged with WINE 991031

File size: 9.4 KB
Line 
1/* $Id: module.h,v 1.4 1999-11-02 21:50:40 achimha Exp $ */
2
3/*
4 * Module definitions
5 *
6 * Copyright 1995 Alexandre Julliard
7 */
8
9#ifndef __WINE_MODULE_H
10#define __WINE_MODULE_H
11
12#include "windef.h"
13//#include "dosexe.h"
14#include "pe_image.h"
15
16#ifndef __WIN32OS2__
17 /* In-memory module structure. See 'Windows Internals' p. 219 */
18typedef struct _NE_MODULE
19{
20 WORD magic; /* 00 'NE' signature */
21 WORD count; /* 02 Usage count */
22 WORD entry_table; /* 04 Near ptr to entry table */
23 HMODULE16 next; /* 06 Selector to next module */
24 WORD dgroup_entry; /* 08 Near ptr to segment entry for DGROUP */
25 WORD fileinfo; /* 0a Near ptr to file info (OFSTRUCT) */
26 WORD flags; /* 0c Module flags */
27 WORD dgroup; /* 0e Logical segment for DGROUP */
28 WORD heap_size; /* 10 Initial heap size */
29 WORD stack_size; /* 12 Initial stack size */
30 WORD ip; /* 14 Initial ip */
31 WORD cs; /* 16 Initial cs (logical segment) */
32 WORD sp; /* 18 Initial stack pointer */
33 WORD ss; /* 1a Initial ss (logical segment) */
34 WORD seg_count; /* 1c Number of segments in segment table */
35 WORD modref_count; /* 1e Number of module references */
36 WORD nrname_size; /* 20 Size of non-resident names table */
37 WORD seg_table; /* 22 Near ptr to segment table */
38 WORD res_table; /* 24 Near ptr to resource table */
39 WORD name_table; /* 26 Near ptr to resident names table */
40 WORD modref_table; /* 28 Near ptr to module reference table */
41 WORD import_table; /* 2a Near ptr to imported names table */
42 DWORD nrname_fpos; /* 2c File offset of non-resident names table */
43 WORD moveable_entries; /* 30 Number of moveable entries in entry table*/
44 WORD alignment; /* 32 Alignment shift count */
45 WORD truetype; /* 34 Set to 2 if TrueType font */
46 BYTE os_flags; /* 36 Operating system flags */
47 BYTE misc_flags; /* 37 Misc. flags */
48 HANDLE16 dlls_to_init; /* 38 List of DLLs to initialize */
49 HANDLE16 nrname_handle; /* 3a Handle to non-resident name table */
50 WORD min_swap_area; /* 3c Min. swap area size */
51 WORD expected_version; /* 3e Expected Windows version */
52 /* From here, these are extra fields not present in normal Windows */
53 HMODULE module32; /* 40 PE module handle for Win32 modules */
54 HMODULE16 self; /* 44 Handle for this module */
55 WORD self_loading_sel; /* 46 Selector used for self-loading apps. */
56 LPDOSTASK lpDosTask;
57 LPVOID dos_image; /* pointer to DOS memory (for DOS apps) */
58 LPVOID hRsrcMap; /* HRSRC 16->32 map (for 32-bit modules) */
59} NE_MODULE;
60#endif
61
62typedef struct {
63 BYTE type;
64 BYTE flags;
65 BYTE segnum;
66 WORD offs WINE_PACKED;
67} ET_ENTRY;
68
69typedef struct {
70 WORD first; /* ordinal */
71 WORD last; /* ordinal */
72 WORD next; /* bundle */
73} ET_BUNDLE;
74
75
76 /* In-memory segment table */
77typedef struct
78{
79 WORD filepos; /* Position in file, in sectors */
80 WORD size; /* Segment size on disk */
81 WORD flags; /* Segment flags */
82 WORD minsize; /* Min. size of segment in memory */
83 HANDLE16 hSeg; /* Selector or handle (selector - 1) */
84 /* of segment in memory */
85} SEGTABLEENTRY;
86
87
88 /* Self-loading modules contain this structure in their first segment */
89
90#include "pshpack1.h"
91
92typedef struct
93{
94 WORD version; /* Must be "A0" (0x3041) */
95 WORD reserved;
96 FARPROC16 BootApp; /* startup procedure */
97 FARPROC16 LoadAppSeg; /* procedure to load a segment */
98 FARPROC16 reserved2;
99 FARPROC16 MyAlloc; /* memory allocation procedure,
100 * wine must write this field */
101 FARPROC16 EntryAddrProc;
102 FARPROC16 ExitProc; /* exit procedure */
103 WORD reserved3[4];
104 FARPROC16 SetOwner; /* Set Owner procedure, exported by wine */
105} SELFLOADHEADER;
106
107 /* Parameters for LoadModule() */
108typedef struct
109{
110 HGLOBAL16 hEnvironment; /* Environment segment */
111 SEGPTR cmdLine WINE_PACKED; /* Command-line */
112 SEGPTR showCmd WINE_PACKED; /* Code for ShowWindow() */
113 SEGPTR reserved WINE_PACKED;
114} LOADPARAMS16;
115
116typedef struct
117{
118 LPSTR lpEnvAddress;
119 LPSTR lpCmdLine;
120 UINT16 *lpCmdShow;
121 DWORD dwReserved;
122} LOADPARAMS;
123
124#include "poppack.h"
125
126/* internal representation of 32bit modules. per process. */
127typedef enum {
128 MODULE32_PE = 1,
129 MODULE32_ELF,
130 MODULE32_ELFDLL,
131 MODULE32_BI
132} MODULE32_TYPE;
133
134typedef struct _wine_modref
135{
136 struct _wine_modref *next;
137 struct _wine_modref *prev;
138 MODULE32_TYPE type;
139 union {
140 PE_MODREF pe;
141 ELF_MODREF elf;
142 } binfmt;
143
144 HMODULE module;
145
146 int nDeps;
147 struct _wine_modref **deps;
148
149 int flags;
150 int refCount;
151
152 char *modname;
153 char *shortname;
154 char *longname;
155} WINE_MODREF;
156
157#define WINE_MODREF_INTERNAL 0x00000001
158#define WINE_MODREF_NO_DLL_CALLS 0x00000002
159#define WINE_MODREF_PROCESS_ATTACHED 0x00000004
160#define WINE_MODREF_LOAD_AS_DATAFILE 0x00000010
161#define WINE_MODREF_DONT_RESOLVE_REFS 0x00000020
162#define WINE_MODREF_MARKER 0x80000000
163
164
165/* Resource types */
166typedef struct resource_typeinfo_s NE_TYPEINFO;
167typedef struct resource_nameinfo_s NE_NAMEINFO;
168
169#define NE_SEG_TABLE(pModule) \
170 ((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->seg_table))
171
172#define NE_MODULE_TABLE(pModule) \
173 ((WORD *)((char *)(pModule) + (pModule)->modref_table))
174
175#define NE_MODULE_NAME(pModule) \
176 (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
177#endif
178
179#ifndef __WIN32OS2__
180
181/* module.c */
182extern FARPROC MODULE_GetProcAddress( HMODULE hModule, LPCSTR function, BOOL snoop );
183extern WINE_MODREF *MODULE32_LookupHMODULE( HMODULE hModule );
184extern BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved );
185extern void MODULE_DllProcessDetach( BOOL bForceDetach, LPVOID lpReserved );
186extern void MODULE_DllThreadAttach( LPVOID lpReserved );
187extern void MODULE_DllThreadDetach( LPVOID lpReserved );
188extern WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags );
189extern BOOL MODULE_FreeLibrary( WINE_MODREF *wm );
190extern WINE_MODREF *MODULE_FindModule( LPCSTR path );
191extern HMODULE MODULE_CreateDummyModule( const OFSTRUCT *ofs, LPCSTR modName );
192extern FARPROC16 MODULE_GetWndProcEntry16( const char *name );
193extern FARPROC16 WINAPI WIN32_GetProcAddress16( HMODULE hmodule, LPCSTR name );
194extern SEGPTR WINAPI HasGPHandler16( SEGPTR address );
195
196/* resource.c */
197extern INT WINAPI AccessResource(HMODULE,HRSRC);
198
199#ifndef __WIN32OS2__
200/* loader/ne/module.c */
201extern NE_MODULE *NE_GetPtr( HMODULE16 hModule );
202extern void NE_DumpModule( HMODULE16 hModule );
203extern void NE_WalkModules(void);
204extern void NE_RegisterModule( NE_MODULE *pModule );
205extern WORD NE_GetOrdinal( HMODULE16 hModule, const char *name );
206extern FARPROC16 NE_GetEntryPoint( HMODULE16 hModule, WORD ordinal );
207extern FARPROC16 NE_GetEntryPointEx( HMODULE16 hModule, WORD ordinal, BOOL16 snoop );
208extern BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset );
209extern HANDLE NE_OpenFile( NE_MODULE *pModule );
210extern HINSTANCE16 MODULE_LoadModule16( LPCSTR name, BOOL implicit );
211extern BOOL NE_CreateProcess( HFILE hFile, OFSTRUCT *ofs, LPCSTR cmd_line, LPCSTR env,
212 LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
213 BOOL inherit, LPSTARTUPINFOA startup,
214 LPPROCESS_INFORMATION info );
215
216/* loader/ne/resource.c */
217extern HGLOBAL16 WINAPI NE_DefResourceHandler(HGLOBAL16,HMODULE16,HRSRC16);
218extern BOOL NE_InitResourceHandler( HMODULE16 hModule );
219extern HRSRC16 NE_FindResource( NE_MODULE *pModule, LPCSTR name, LPCSTR type );
220extern INT16 NE_AccessResource( NE_MODULE *pModule, HRSRC16 hRsrc );
221extern DWORD NE_SizeofResource( NE_MODULE *pModule, HRSRC16 hRsrc );
222extern HGLOBAL16 NE_LoadResource( NE_MODULE *pModule, HRSRC16 hRsrc );
223extern BOOL16 NE_FreeResource( NE_MODULE *pModule, HGLOBAL16 handle );
224extern NE_TYPEINFO *NE_FindTypeSection( LPBYTE pResTab, NE_TYPEINFO *pTypeInfo, LPCSTR typeId );
225extern NE_NAMEINFO *NE_FindResourceFromType( LPBYTE pResTab, NE_TYPEINFO *pTypeInfo, LPCSTR resId );
226
227/* loader/ne/segment.c */
228extern BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum );
229extern BOOL NE_LoadAllSegments( NE_MODULE *pModule );
230extern void NE_FixupPrologs( NE_MODULE *pModule );
231extern void NE_InitializeDLLs( HMODULE16 hModule );
232extern BOOL NE_CreateSegments( NE_MODULE *pModule );
233extern HINSTANCE16 NE_CreateInstance( NE_MODULE *pModule, HINSTANCE16 *prev,
234 BOOL lib_only );
235
236/* loader/ne/convert.c */
237HGLOBAL16 NE_LoadPEResource( NE_MODULE *pModule, WORD type, LPVOID bits, DWORD size );
238
239/* if1632/builtin.c */
240extern BOOL BUILTIN_Init(void);
241extern HMODULE16 BUILTIN_LoadModule( LPCSTR name, BOOL force );
242extern LPCSTR BUILTIN_GetEntryPoint16( WORD cs, WORD ip, WORD *pOrd );
243
244/* relay32/builtin.c */
245extern HMODULE BUILTIN32_LoadImage(LPCSTR name, OFSTRUCT *ofs);
246extern WINE_MODREF *BUILTIN32_LoadLibraryExA(LPCSTR name, DWORD flags, DWORD *err);
247extern void BUILTIN32_UnloadLibrary(WINE_MODREF *wm);
248
249/* if1632/builtin.c */
250extern HMODULE16 (*fnBUILTIN_LoadModule)(LPCSTR name, BOOL force);
251#endif
252
253#endif /* __WINE_MODULE_H */
Note: See TracBrowser for help on using the repository browser.