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

Last change on this file since 4 was 4, checked in by ktk, 26 years ago

Import

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