4 * Copyright 1995 Alexandre Julliard
7 #ifndef __WINE_MODULE_H
8 #define __WINE_MODULE_H
13 /* In-memory module structure. See 'Windows Internals' p. 219 */
14 typedef struct _NE_MODULE
16 WORD magic
; /* 00 'NE' signature */
17 WORD count
; /* 02 Usage count */
18 WORD entry_table
; /* 04 Near ptr to entry table */
19 HMODULE16 next
; /* 06 Selector to next module */
20 WORD dgroup_entry
; /* 08 Near ptr to segment entry for DGROUP */
21 WORD fileinfo
; /* 0a Near ptr to file info (OFSTRUCT) */
22 WORD flags
; /* 0c Module flags */
23 WORD dgroup
; /* 0e Logical segment for DGROUP */
24 WORD heap_size
; /* 10 Initial heap size */
25 WORD stack_size
; /* 12 Initial stack size */
26 WORD ip
; /* 14 Initial ip */
27 WORD cs
; /* 16 Initial cs (logical segment) */
28 WORD sp
; /* 18 Initial stack pointer */
29 WORD ss
; /* 1a Initial ss (logical segment) */
30 WORD seg_count
; /* 1c Number of segments in segment table */
31 WORD modref_count
; /* 1e Number of module references */
32 WORD nrname_size
; /* 20 Size of non-resident names table */
33 WORD seg_table
; /* 22 Near ptr to segment table */
34 WORD res_table
; /* 24 Near ptr to resource table */
35 WORD name_table
; /* 26 Near ptr to resident names table */
36 WORD modref_table
; /* 28 Near ptr to module reference table */
37 WORD import_table
; /* 2a Near ptr to imported names table */
38 DWORD nrname_fpos
; /* 2c File offset of non-resident names table */
39 WORD moveable_entries
; /* 30 Number of moveable entries in entry table*/
40 WORD alignment
; /* 32 Alignment shift count */
41 WORD truetype
; /* 34 Set to 2 if TrueType font */
42 BYTE os_flags
; /* 36 Operating system flags */
43 BYTE misc_flags
; /* 37 Misc. flags */
44 HANDLE16 dlls_to_init
; /* 38 List of DLLs to initialize */
45 HANDLE16 nrname_handle
; /* 3a Handle to non-resident name table */
46 WORD min_swap_area
; /* 3c Min. swap area size */
47 WORD expected_version
; /* 3e Expected Windows version */
48 /* From here, these are extra fields not present in normal Windows */
49 HMODULE32 module32
; /* 40 PE module handle for Win32 modules */
50 HMODULE16 self
; /* 44 Handle for this module */
51 WORD self_loading_sel
; /* 46 Selector used for self-loading apps. */
55 /* In-memory segment table */
58 WORD filepos
; /* Position in file, in sectors */
59 WORD size
; /* Segment size on disk */
60 WORD flags
; /* Segment flags */
61 WORD minsize
; /* Min. size of segment in memory */
62 HANDLE16 selector
; /* Selector of segment in memory */
66 /* Self-loading modules contain this structure in their first segment */
72 WORD version
; /* Must be 0xA0 */
74 FARPROC16 BootApp
; /* startup procedure */
75 FARPROC16 LoadAppSeg
; /* procedure to load a segment */
77 FARPROC16 MyAlloc
; /* memory allocation procedure,
78 * wine must write this field */
79 FARPROC16 EntryAddrProc
;
80 FARPROC16 ExitProc
; /* exit procedure */
82 FARPROC16 SetOwner
; /* Set Owner procedure, exported by wine */
85 /* Parameters for LoadModule() */
88 HGLOBAL16 hEnvironment
; /* Environment segment */
89 SEGPTR cmdLine WINE_PACKED
; /* Command-line */
90 SEGPTR showCmd WINE_PACKED
; /* Code for ShowWindow() */
91 SEGPTR reserved WINE_PACKED
;
104 /* internal representation of 32bit modules. per process. */
105 typedef enum { MODULE32_PE
=1, MODULE32_ELF
/* ,... */ } MODULE32_TYPE
;
106 typedef struct _wine_modref
108 struct _wine_modref
*next
;
112 /* ELF_MODREF elf; */
123 typedef struct resource_typeinfo_s NE_TYPEINFO
;
124 typedef struct resource_nameinfo_s NE_NAMEINFO
;
126 #define NE_SEG_TABLE(pModule) \
127 ((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->seg_table))
129 #define NE_MODULE_TABLE(pModule) \
130 ((WORD *)((char *)(pModule) + (pModule)->modref_table))
132 #define NE_MODULE_NAME(pModule) \
133 (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
136 extern FARPROC32
MODULE_GetProcAddress32( struct _PDB32
*pdb
,HMODULE32 hModule
,LPCSTR function
);
137 extern WINE_MODREF
*MODULE32_LookupHMODULE( struct _PDB32
*process
, HMODULE32 hModule
);
138 extern HMODULE32
MODULE_FindModule32( struct _PDB32
*process
, LPCSTR path
);
139 extern HMODULE32
MODULE_CreateDummyModule( const OFSTRUCT
*ofs
);
140 extern HINSTANCE16
MODULE_Load( LPCSTR name
, BOOL32 implicit
, LPCSTR cmd_line
,
141 LPCSTR env
, UINT32 show_cmd
);
142 extern FARPROC16
MODULE_GetWndProcEntry16( const char *name
);
143 extern FARPROC16 WINAPI
WIN32_GetProcAddress16( HMODULE32 hmodule
, LPCSTR name
);
145 /* loader/ne/module.c */
146 extern NE_MODULE
*NE_GetPtr( HMODULE16 hModule
);
147 extern void NE_DumpModule( HMODULE16 hModule
);
148 extern void NE_WalkModules(void);
149 extern void NE_RegisterModule( NE_MODULE
*pModule
);
150 extern WORD
NE_GetOrdinal( HMODULE16 hModule
, const char *name
);
151 extern FARPROC16
NE_GetEntryPoint( HMODULE16 hModule
, WORD ordinal
);
152 extern BOOL16
NE_SetEntryPoint( HMODULE16 hModule
, WORD ordinal
, WORD offset
);
153 extern int NE_OpenFile( NE_MODULE
*pModule
);
154 extern HINSTANCE16
NE_LoadModule( LPCSTR name
, HINSTANCE16
*hPrevInstance
,
155 BOOL32 implicit
, BOOL32 lib_only
);
157 /* loader/ne/resource.c */
158 extern HGLOBAL16 WINAPI
NE_DefResourceHandler(HGLOBAL16
,HMODULE16
,HRSRC16
);
159 extern BOOL32
NE_InitResourceHandler( HMODULE16 hModule
);
161 /* loader/ne/segment.c */
162 extern BOOL32
NE_LoadSegment( NE_MODULE
*pModule
, WORD segnum
);
163 extern BOOL32
NE_LoadAllSegments( NE_MODULE
*pModule
);
164 extern void NE_FixupPrologs( NE_MODULE
*pModule
);
165 extern void NE_InitializeDLLs( HMODULE16 hModule
);
166 extern BOOL32
NE_CreateSegments( NE_MODULE
*pModule
);
167 extern HINSTANCE16
NE_CreateInstance( NE_MODULE
*pModule
, HINSTANCE16
*prev
,
170 /* if1632/builtin.c */
171 extern BOOL32
BUILTIN_Init(void);
172 extern HMODULE16
BUILTIN_LoadModule( LPCSTR name
, BOOL32 force
);
173 extern LPCSTR
BUILTIN_GetEntryPoint16( WORD cs
, WORD ip
, WORD
*pOrd
);
174 extern BOOL32
BUILTIN_ParseDLLOptions( const char *str
);
175 extern void BUILTIN_PrintDLLs(void);
177 /* relay32/builtin.c */
178 extern HMODULE32
BUILTIN32_LoadModule( LPCSTR name
, BOOL32 force
,
179 struct _PDB32
*process
);
181 /* if1632/builtin.c */
182 extern HMODULE16 (*fnBUILTIN_LoadModule
)(LPCSTR name
, BOOL32 force
);
184 #endif /* __WINE_MODULE_H */