1
|
1 /*
|
|
2 * Module definitions
|
|
3 *
|
|
4 * Copyright 1995 Alexandre Julliard
|
|
5 */
|
|
6
|
|
7 #ifndef __WINE_MODULE_H
|
|
8 #define __WINE_MODULE_H
|
|
9
|
|
10 #include "windef.h"
|
|
11 //#include "dosexe.h"
|
|
12 #include "pe_image.h"
|
|
13
|
|
14
|
|
15
|
|
16 typedef struct {
|
|
17 BYTE type;
|
|
18 BYTE flags;
|
|
19 BYTE segnum;
|
|
20 WORD offs WINE_PACKED;
|
|
21 } ET_ENTRY;
|
|
22
|
|
23 typedef struct {
|
|
24 WORD first; /* ordinal */
|
|
25 WORD last; /* ordinal */
|
|
26 WORD next; /* bundle */
|
|
27 } ET_BUNDLE;
|
|
28
|
|
29
|
|
30 /* In-memory segment table */
|
|
31 typedef struct
|
|
32 {
|
|
33 WORD filepos; /* Position in file, in sectors */
|
|
34 WORD size; /* Segment size on disk */
|
|
35 WORD flags; /* Segment flags */
|
|
36 WORD minsize; /* Min. size of segment in memory */
|
|
37 HANDLE16 hSeg; /* Selector or handle (selector - 1) */
|
|
38 /* of segment in memory */
|
|
39 } SEGTABLEENTRY;
|
|
40
|
|
41
|
|
42 /* Self-loading modules contain this structure in their first segment */
|
|
43
|
|
44 #include "pshpack1.h"
|
|
45
|
|
46 typedef struct
|
|
47 {
|
|
48 WORD version; /* Must be "A0" (0x3041) */
|
|
49 WORD reserved;
|
|
50 FARPROC16 BootApp; /* startup procedure */
|
|
51 FARPROC16 LoadAppSeg; /* procedure to load a segment */
|
|
52 FARPROC16 reserved2;
|
|
53 FARPROC16 MyAlloc; /* memory allocation procedure,
|
|
54 * wine must write this field */
|
|
55 FARPROC16 EntryAddrProc;
|
|
56 FARPROC16 ExitProc; /* exit procedure */
|
|
57 WORD reserved3[4];
|
|
58 FARPROC16 SetOwner; /* Set Owner procedure, exported by wine */
|
|
59 } SELFLOADHEADER;
|
|
60
|
|
61 /* Parameters for LoadModule() */
|
|
62 typedef struct
|
|
63 {
|
|
64 HGLOBAL16 hEnvironment; /* Environment segment */
|
|
65 SEGPTR cmdLine WINE_PACKED; /* Command-line */
|
|
66 SEGPTR showCmd WINE_PACKED; /* Code for ShowWindow() */
|
|
67 SEGPTR reserved WINE_PACKED;
|
|
68 } LOADPARAMS16;
|
|
69
|
|
70 typedef struct
|
|
71 {
|
|
72 LPSTR lpEnvAddress;
|
|
73 LPSTR lpCmdLine;
|
|
74 UINT16 *lpCmdShow;
|
|
75 DWORD dwReserved;
|
|
76 } LOADPARAMS;
|
|
77
|
|
78 #include "poppack.h"
|
|
79
|
|
80 /* internal representation of 32bit modules. per process. */
|
|
81 typedef enum {
|
|
82 MODULE32_PE = 1,
|
|
83 MODULE32_ELF,
|
|
84 MODULE32_ELFDLL
|
|
85 } MODULE32_TYPE;
|
|
86
|
|
87 typedef struct _wine_modref
|
|
88 {
|
|
89 struct _wine_modref *next;
|
|
90 struct _wine_modref *prev;
|
|
91 MODULE32_TYPE type;
|
|
92 union {
|
|
93 PE_MODREF pe;
|
|
94 ELF_MODREF elf;
|
|
95 } binfmt;
|
|
96
|
|
97 HMODULE module;
|
|
98
|
|
99 int nDeps;
|
|
100 struct _wine_modref **deps;
|
|
101
|
|
102 int flags;
|
|
103 int refCount;
|
|
104
|
|
105 char *filename;
|
|
106 char *modname;
|
|
107 char *short_filename;
|
|
108 char *short_modname;
|
|
109 } WINE_MODREF;
|
|
110
|
|
111 #define WINE_MODREF_INTERNAL 0x00000001
|
|
112 #define WINE_MODREF_NO_DLL_CALLS 0x00000002
|
|
113 #define WINE_MODREF_PROCESS_ATTACHED 0x00000004
|
|
114 #define WINE_MODREF_LOAD_AS_DATAFILE 0x00000010
|
|
115 #define WINE_MODREF_DONT_RESOLVE_REFS 0x00000020
|
|
116 #define WINE_MODREF_MARKER 0x80000000
|
|
117
|
|
118
|
|
119
|
|
120 /* Resource types */
|
|
121 typedef struct resource_typeinfo_s NE_TYPEINFO;
|
|
122 typedef struct resource_nameinfo_s NE_NAMEINFO;
|
|
123
|
|
124 #define NE_SEG_TABLE(pModule) \
|
|
125 ((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->seg_table))
|
|
126
|
|
127 #define NE_MODULE_TABLE(pModule) \
|
|
128 ((WORD *)((char *)(pModule) + (pModule)->modref_table))
|
|
129
|
|
130 #define NE_MODULE_NAME(pModule) \
|
|
131 (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
|
|
132
|
|
133 /* module.c */
|
|
134 extern FARPROC MODULE_GetProcAddress( HMODULE hModule, LPCSTR function, WIN_BOOL snoop );
|
|
135 extern WINE_MODREF *MODULE32_LookupHMODULE( HMODULE hModule );
|
|
136 extern WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved );
|
|
137 extern void MODULE_DllProcessDetach( WINE_MODREF *wm, WIN_BOOL bForceDetach, LPVOID lpReserved );
|
|
138 extern void MODULE_DllThreadAttach( LPVOID lpReserved );
|
|
139 extern void MODULE_DllThreadDetach( LPVOID lpReserved );
|
|
140 extern WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags );
|
|
141 extern WIN_BOOL MODULE_FreeLibrary( WINE_MODREF *wm );
|
|
142 extern WINE_MODREF *MODULE_FindModule( LPCSTR path );
|
|
143 extern HMODULE MODULE_CreateDummyModule( LPCSTR filename, HMODULE module32 );
|
|
144 extern FARPROC16 WINAPI WIN32_GetProcAddress16( HMODULE hmodule, LPCSTR name );
|
|
145 extern SEGPTR WINAPI HasGPHandler16( SEGPTR address );
|
|
146 extern void MODULE_WalkModref( DWORD id );
|
|
147
|
|
148 /* resource.c */
|
|
149 extern INT WINAPI AccessResource(HMODULE,HRSRC);
|
|
150 /*
|
|
151 / loader/ne/module.c
|
|
152 extern NE_MODULE *NE_GetPtr( HMODULE16 hModule );
|
|
153 extern void NE_DumpModule( HMODULE16 hModule );
|
|
154 extern void NE_WalkModules(void);
|
|
155 extern void NE_RegisterModule( NE_MODULE *pModule );
|
|
156 extern WORD NE_GetOrdinal( HMODULE16 hModule, const char *name );
|
|
157 extern FARPROC16 WINAPI NE_GetEntryPoint( HMODULE16 hModule, WORD ordinal );
|
|
158 extern FARPROC16 NE_GetEntryPointEx( HMODULE16 hModule, WORD ordinal, WIN_BOOL16 snoop );
|
|
159 extern WIN_BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset );
|
|
160 extern int NE_OpenFile( NE_MODULE *pModule );
|
|
161 extern WIN_BOOL NE_CreateProcess( HANDLE hFile, LPCSTR filename, LPCSTR cmd_line, LPCSTR env,
|
|
162 LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
|
|
163 WIN_BOOL inherit, DWORD flags, LPSTARTUPINFOA startup,
|
|
164 LPPROCESS_INFORMATION info );
|
|
165 extern WIN_BOOL NE_InitProcess( NE_MODULE *pModule );
|
|
166
|
|
167
|
|
168 / loader/ne/resource.c
|
|
169 extern HGLOBAL16 WINAPI NE_DefResourceHandler(HGLOBAL16,HMODULE16,HRSRC16);
|
|
170 extern WIN_BOOL NE_InitResourceHandler( HMODULE16 hModule );
|
|
171 extern HRSRC16 NE_FindResource( NE_MODULE *pModule, LPCSTR name, LPCSTR type );
|
|
172 extern INT16 NE_AccessResource( NE_MODULE *pModule, HRSRC16 hRsrc );
|
|
173 extern DWORD NE_SizeofResource( NE_MODULE *pModule, HRSRC16 hRsrc );
|
|
174 extern HGLOBAL16 NE_LoadResource( NE_MODULE *pModule, HRSRC16 hRsrc );
|
|
175 extern WIN_BOOL16 NE_FreeResource( NE_MODULE *pModule, HGLOBAL16 handle );
|
|
176 extern NE_TYPEINFO *NE_FindTypeSection( LPBYTE pResTab, NE_TYPEINFO *pTypeInfo, LPCSTR typeId );
|
|
177 extern NE_NAMEINFO *NE_FindResourceFromType( LPBYTE pResTab, NE_TYPEINFO *pTypeInfo, LPCSTR resId );
|
|
178
|
|
179 // loader/ne/segment.c
|
|
180 extern WIN_BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum );
|
|
181 extern WIN_BOOL NE_LoadAllSegments( NE_MODULE *pModule );
|
|
182 extern WIN_BOOL NE_CreateSegment( NE_MODULE *pModule, int segnum );
|
|
183 extern WIN_BOOL NE_CreateAllSegments( NE_MODULE *pModule );
|
|
184 extern HINSTANCE16 NE_GetInstance( NE_MODULE *pModule );
|
|
185 extern void NE_InitializeDLLs( HMODULE16 hModule );
|
|
186 extern void NE_DllProcessAttach( HMODULE16 hModule );
|
|
187
|
|
188 // loader/ne/convert.c
|
|
189 HGLOBAL16 NE_LoadPEResource( NE_MODULE *pModule, WORD type, LPVOID bits, DWORD size );
|
|
190 */
|
|
191 /* relay32/builtin.c */
|
|
192 extern WINE_MODREF *BUILTIN32_LoadLibraryExA(LPCSTR name, DWORD flags);
|
|
193 extern HMODULE BUILTIN32_LoadExeModule( LPCSTR *filename );
|
|
194 extern void BUILTIN32_UnloadLibrary(WINE_MODREF *wm);
|
|
195 extern void *BUILTIN32_dlopen( const char *name );
|
|
196 extern int BUILTIN32_dlclose( void *handle );
|
|
197
|
|
198 #endif /* __WINE_MODULE_H */
|