[1566] | 1 | /* $Id: module.h,v 1.4 1999-11-02 21:50:40 achimha Exp $ */
|
---|
[4] | 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"
|
---|
[123] | 13 | //#include "dosexe.h"
|
---|
[4] | 14 | #include "pe_image.h"
|
---|
| 15 |
|
---|
[123] | 16 | #ifndef __WIN32OS2__
|
---|
[4] | 17 | /* In-memory module structure. See 'Windows Internals' p. 219 */
|
---|
| 18 | typedef 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;
|
---|
[123] | 60 | #endif
|
---|
[4] | 61 |
|
---|
| 62 | typedef struct {
|
---|
| 63 | BYTE type;
|
---|
| 64 | BYTE flags;
|
---|
| 65 | BYTE segnum;
|
---|
| 66 | WORD offs WINE_PACKED;
|
---|
| 67 | } ET_ENTRY;
|
---|
| 68 |
|
---|
| 69 | typedef struct {
|
---|
| 70 | WORD first; /* ordinal */
|
---|
| 71 | WORD last; /* ordinal */
|
---|
| 72 | WORD next; /* bundle */
|
---|
| 73 | } ET_BUNDLE;
|
---|
| 74 |
|
---|
| 75 |
|
---|
| 76 | /* In-memory segment table */
|
---|
| 77 | typedef 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 |
|
---|
| 92 | typedef 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;
|
---|
[796] | 99 | FARPROC16 MyAlloc; /* memory allocation procedure,
|
---|
[4] | 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() */
|
---|
| 108 | typedef 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 |
|
---|
[796] | 116 | typedef struct
|
---|
[4] | 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. */
|
---|
| 127 | typedef enum {
|
---|
| 128 | MODULE32_PE = 1,
|
---|
| 129 | MODULE32_ELF,
|
---|
| 130 | MODULE32_ELFDLL,
|
---|
| 131 | MODULE32_BI
|
---|
| 132 | } MODULE32_TYPE;
|
---|
| 133 |
|
---|
| 134 | typedef 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 */
|
---|
| 166 | typedef struct resource_typeinfo_s NE_TYPEINFO;
|
---|
| 167 | typedef 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)
|
---|
[796] | 177 | #endif
|
---|
[4] | 178 |
|
---|
[1566] | 179 | #ifndef __WIN32OS2__
|
---|
| 180 |
|
---|
[4] | 181 | /* module.c */
|
---|
| 182 | extern FARPROC MODULE_GetProcAddress( HMODULE hModule, LPCSTR function, BOOL snoop );
|
---|
| 183 | extern WINE_MODREF *MODULE32_LookupHMODULE( HMODULE hModule );
|
---|
| 184 | extern BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved );
|
---|
| 185 | extern void MODULE_DllProcessDetach( BOOL bForceDetach, LPVOID lpReserved );
|
---|
| 186 | extern void MODULE_DllThreadAttach( LPVOID lpReserved );
|
---|
| 187 | extern void MODULE_DllThreadDetach( LPVOID lpReserved );
|
---|
| 188 | extern WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags );
|
---|
| 189 | extern BOOL MODULE_FreeLibrary( WINE_MODREF *wm );
|
---|
| 190 | extern WINE_MODREF *MODULE_FindModule( LPCSTR path );
|
---|
| 191 | extern HMODULE MODULE_CreateDummyModule( const OFSTRUCT *ofs, LPCSTR modName );
|
---|
| 192 | extern FARPROC16 MODULE_GetWndProcEntry16( const char *name );
|
---|
| 193 | extern FARPROC16 WINAPI WIN32_GetProcAddress16( HMODULE hmodule, LPCSTR name );
|
---|
| 194 | extern SEGPTR WINAPI HasGPHandler16( SEGPTR address );
|
---|
| 195 |
|
---|
| 196 | /* resource.c */
|
---|
[796] | 197 | extern INT WINAPI AccessResource(HMODULE,HRSRC);
|
---|
[4] | 198 |
|
---|
[796] | 199 | #ifndef __WIN32OS2__
|
---|
[4] | 200 | /* loader/ne/module.c */
|
---|
| 201 | extern NE_MODULE *NE_GetPtr( HMODULE16 hModule );
|
---|
| 202 | extern void NE_DumpModule( HMODULE16 hModule );
|
---|
| 203 | extern void NE_WalkModules(void);
|
---|
| 204 | extern void NE_RegisterModule( NE_MODULE *pModule );
|
---|
| 205 | extern WORD NE_GetOrdinal( HMODULE16 hModule, const char *name );
|
---|
| 206 | extern FARPROC16 NE_GetEntryPoint( HMODULE16 hModule, WORD ordinal );
|
---|
| 207 | extern FARPROC16 NE_GetEntryPointEx( HMODULE16 hModule, WORD ordinal, BOOL16 snoop );
|
---|
| 208 | extern BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset );
|
---|
| 209 | extern HANDLE NE_OpenFile( NE_MODULE *pModule );
|
---|
| 210 | extern HINSTANCE16 MODULE_LoadModule16( LPCSTR name, BOOL implicit );
|
---|
[796] | 211 | extern BOOL NE_CreateProcess( HFILE hFile, OFSTRUCT *ofs, LPCSTR cmd_line, LPCSTR env,
|
---|
[4] | 212 | LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
|
---|
| 213 | BOOL inherit, LPSTARTUPINFOA startup,
|
---|
| 214 | LPPROCESS_INFORMATION info );
|
---|
| 215 |
|
---|
| 216 | /* loader/ne/resource.c */
|
---|
| 217 | extern HGLOBAL16 WINAPI NE_DefResourceHandler(HGLOBAL16,HMODULE16,HRSRC16);
|
---|
| 218 | extern BOOL NE_InitResourceHandler( HMODULE16 hModule );
|
---|
| 219 | extern HRSRC16 NE_FindResource( NE_MODULE *pModule, LPCSTR name, LPCSTR type );
|
---|
| 220 | extern INT16 NE_AccessResource( NE_MODULE *pModule, HRSRC16 hRsrc );
|
---|
| 221 | extern DWORD NE_SizeofResource( NE_MODULE *pModule, HRSRC16 hRsrc );
|
---|
| 222 | extern HGLOBAL16 NE_LoadResource( NE_MODULE *pModule, HRSRC16 hRsrc );
|
---|
| 223 | extern BOOL16 NE_FreeResource( NE_MODULE *pModule, HGLOBAL16 handle );
|
---|
| 224 | extern NE_TYPEINFO *NE_FindTypeSection( LPBYTE pResTab, NE_TYPEINFO *pTypeInfo, LPCSTR typeId );
|
---|
| 225 | extern NE_NAMEINFO *NE_FindResourceFromType( LPBYTE pResTab, NE_TYPEINFO *pTypeInfo, LPCSTR resId );
|
---|
| 226 |
|
---|
| 227 | /* loader/ne/segment.c */
|
---|
| 228 | extern BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum );
|
---|
| 229 | extern BOOL NE_LoadAllSegments( NE_MODULE *pModule );
|
---|
| 230 | extern void NE_FixupPrologs( NE_MODULE *pModule );
|
---|
| 231 | extern void NE_InitializeDLLs( HMODULE16 hModule );
|
---|
| 232 | extern BOOL NE_CreateSegments( NE_MODULE *pModule );
|
---|
| 233 | extern HINSTANCE16 NE_CreateInstance( NE_MODULE *pModule, HINSTANCE16 *prev,
|
---|
| 234 | BOOL lib_only );
|
---|
| 235 |
|
---|
| 236 | /* loader/ne/convert.c */
|
---|
| 237 | HGLOBAL16 NE_LoadPEResource( NE_MODULE *pModule, WORD type, LPVOID bits, DWORD size );
|
---|
| 238 |
|
---|
| 239 | /* if1632/builtin.c */
|
---|
| 240 | extern BOOL BUILTIN_Init(void);
|
---|
| 241 | extern HMODULE16 BUILTIN_LoadModule( LPCSTR name, BOOL force );
|
---|
| 242 | extern LPCSTR BUILTIN_GetEntryPoint16( WORD cs, WORD ip, WORD *pOrd );
|
---|
| 243 |
|
---|
| 244 | /* relay32/builtin.c */
|
---|
| 245 | extern HMODULE BUILTIN32_LoadImage(LPCSTR name, OFSTRUCT *ofs);
|
---|
| 246 | extern WINE_MODREF *BUILTIN32_LoadLibraryExA(LPCSTR name, DWORD flags, DWORD *err);
|
---|
| 247 | extern void BUILTIN32_UnloadLibrary(WINE_MODREF *wm);
|
---|
| 248 |
|
---|
| 249 | /* if1632/builtin.c */
|
---|
| 250 | extern HMODULE16 (*fnBUILTIN_LoadModule)(LPCSTR name, BOOL force);
|
---|
[796] | 251 | #endif
|
---|
[4] | 252 |
|
---|
| 253 | #endif /* __WINE_MODULE_H */
|
---|