4 * Copyright 1995 Alexandre Julliard
7 #ifndef __WINE_MODULE_H
8 #define __WINE_MODULE_H
14 /* In-memory module structure. See 'Windows Internals' p. 219 */
15 typedef struct _NE_MODULE
17 WORD magic
; /* 00 'NE' signature */
18 WORD count
; /* 02 Usage count */
19 WORD entry_table
; /* 04 Near ptr to entry table */
20 HMODULE16 next
; /* 06 Selector to next module */
21 WORD dgroup_entry
; /* 08 Near ptr to segment entry for DGROUP */
22 WORD fileinfo
; /* 0a Near ptr to file info (OFSTRUCT) */
23 WORD flags
; /* 0c Module flags */
24 WORD dgroup
; /* 0e Logical segment for DGROUP */
25 WORD heap_size
; /* 10 Initial heap size */
26 WORD stack_size
; /* 12 Initial stack size */
27 WORD ip
; /* 14 Initial ip */
28 WORD cs
; /* 16 Initial cs (logical segment) */
29 WORD sp
; /* 18 Initial stack pointer */
30 WORD ss
; /* 1a Initial ss (logical segment) */
31 WORD seg_count
; /* 1c Number of segments in segment table */
32 WORD modref_count
; /* 1e Number of module references */
33 WORD nrname_size
; /* 20 Size of non-resident names table */
34 WORD seg_table
; /* 22 Near ptr to segment table */
35 WORD res_table
; /* 24 Near ptr to resource table */
36 WORD name_table
; /* 26 Near ptr to resident names table */
37 WORD modref_table
; /* 28 Near ptr to module reference table */
38 WORD import_table
; /* 2a Near ptr to imported names table */
39 DWORD nrname_fpos
; /* 2c File offset of non-resident names table */
40 WORD moveable_entries
; /* 30 Number of moveable entries in entry table*/
41 WORD alignment
; /* 32 Alignment shift count */
42 WORD truetype
; /* 34 Set to 2 if TrueType font */
43 BYTE os_flags
; /* 36 Operating system flags */
44 BYTE misc_flags
; /* 37 Misc. flags */
45 HANDLE16 dlls_to_init
; /* 38 List of DLLs to initialize */
46 HANDLE16 nrname_handle
; /* 3a Handle to non-resident name table */
47 WORD min_swap_area
; /* 3c Min. swap area size */
48 WORD expected_version
; /* 3e Expected Windows version */
49 /* From here, these are extra fields not present in normal Windows */
50 HMODULE32 module32
; /* 40 PE module handle for Win32 modules */
51 HMODULE16 self
; /* 44 Handle for this module */
52 WORD self_loading_sel
; /* 46 Selector used for self-loading apps. */
54 LPVOID dos_image
; /* pointer to DOS memory (for DOS apps) */
58 /* In-memory segment table */
61 WORD filepos
; /* Position in file, in sectors */
62 WORD size
; /* Segment size on disk */
63 WORD flags
; /* Segment flags */
64 WORD minsize
; /* Min. size of segment in memory */
65 HANDLE16 hSeg
; /* Selector or handle (selector - 1) */
66 /* of segment in memory */
70 /* Self-loading modules contain this structure in their first segment */
76 WORD version
; /* Must be "A0" (0x3041) */
78 FARPROC16 BootApp
; /* startup procedure */
79 FARPROC16 LoadAppSeg
; /* procedure to load a segment */
81 FARPROC16 MyAlloc
; /* memory allocation procedure,
82 * wine must write this field */
83 FARPROC16 EntryAddrProc
;
84 FARPROC16 ExitProc
; /* exit procedure */
86 FARPROC16 SetOwner
; /* Set Owner procedure, exported by wine */
89 /* Parameters for LoadModule() */
92 HGLOBAL16 hEnvironment
; /* Environment segment */
93 SEGPTR cmdLine WINE_PACKED
; /* Command-line */
94 SEGPTR showCmd WINE_PACKED
; /* Code for ShowWindow() */
95 SEGPTR reserved WINE_PACKED
;
108 /* internal representation of 32bit modules. per process. */
109 typedef enum { MODULE32_PE
=1, MODULE32_ELF
/* ,... */ } MODULE32_TYPE
;
110 typedef struct _wine_modref
112 struct _wine_modref
*next
;
122 struct _wine_modref
**deps
;
132 typedef struct resource_typeinfo_s NE_TYPEINFO
;
133 typedef struct resource_nameinfo_s NE_NAMEINFO
;
135 #define NE_SEG_TABLE(pModule) \
136 ((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->seg_table))
138 #define NE_MODULE_TABLE(pModule) \
139 ((WORD *)((char *)(pModule) + (pModule)->modref_table))
141 #define NE_MODULE_NAME(pModule) \
142 (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
145 extern FARPROC32
MODULE_GetProcAddress32( struct _PDB32
*pdb
,HMODULE32 hModule
,LPCSTR function
,BOOL32 snoop
);
146 extern WINE_MODREF
*MODULE32_LookupHMODULE( struct _PDB32
*process
, HMODULE32 hModule
);
147 extern void MODULE_InitializeDLLs( struct _PDB32
*process
, HMODULE32 root
, DWORD type
, LPVOID lpReserved
);
148 extern HMODULE32
MODULE_FindModule32( struct _PDB32
*process
, LPCSTR path
);
149 extern HMODULE32
MODULE_CreateDummyModule( const OFSTRUCT
*ofs
);
150 extern FARPROC16
MODULE_GetWndProcEntry16( const char *name
);
151 extern FARPROC16 WINAPI
WIN32_GetProcAddress16( HMODULE32 hmodule
, LPCSTR name
);
152 extern SEGPTR WINAPI
HasGPHandler( SEGPTR address
);
153 HMODULE32
MODULE_LoadLibraryEx32A(LPCSTR libname
,struct _PDB32
*process
,HFILE32 hfile
,DWORD flags
);
155 /* loader/ne/module.c */
156 extern NE_MODULE
*NE_GetPtr( HMODULE16 hModule
);
157 extern void NE_DumpModule( HMODULE16 hModule
);
158 extern void NE_WalkModules(void);
159 extern void NE_RegisterModule( NE_MODULE
*pModule
);
160 extern WORD
NE_GetOrdinal( HMODULE16 hModule
, const char *name
);
161 extern FARPROC16
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 int NE_OpenFile( NE_MODULE
*pModule
);
165 extern HINSTANCE16
NE_LoadModule( LPCSTR name
, HINSTANCE16
*hPrevInstance
,
166 BOOL32 implicit
, BOOL32 lib_only
);
168 /* loader/ne/resource.c */
169 extern HGLOBAL16 WINAPI
NE_DefResourceHandler(HGLOBAL16
,HMODULE16
,HRSRC16
);
170 extern BOOL32
NE_InitResourceHandler( HMODULE16 hModule
);
172 /* loader/ne/segment.c */
173 extern BOOL32
NE_LoadSegment( NE_MODULE
*pModule
, WORD segnum
);
174 extern BOOL32
NE_LoadAllSegments( NE_MODULE
*pModule
);
175 extern void NE_FixupPrologs( NE_MODULE
*pModule
);
176 extern void NE_InitializeDLLs( HMODULE16 hModule
);
177 extern BOOL32
NE_CreateSegments( NE_MODULE
*pModule
);
178 extern HINSTANCE16
NE_CreateInstance( NE_MODULE
*pModule
, HINSTANCE16
*prev
,
181 /* if1632/builtin.c */
182 extern BOOL32
BUILTIN_Init(void);
183 extern HMODULE16
BUILTIN_LoadModule( LPCSTR name
, BOOL32 force
);
184 extern LPCSTR
BUILTIN_GetEntryPoint16( WORD cs
, WORD ip
, WORD
*pOrd
);
185 extern BOOL32
BUILTIN_ParseDLLOptions( const char *str
);
186 extern void BUILTIN_PrintDLLs(void);
188 /* relay32/builtin.c */
189 extern HMODULE32
BUILTIN32_LoadModule( LPCSTR name
, BOOL32 force
,
190 struct _PDB32
*process
);
192 /* if1632/builtin.c */
193 extern HMODULE16 (*fnBUILTIN_LoadModule
)(LPCSTR name
, BOOL32 force
);
195 #endif /* __WINE_MODULE_H */