[6229] | 1 | /* $Id: OS2KLDR.h,v 1.2 2001-07-08 03:07:35 bird Exp $
|
---|
[5086] | 2 | *
|
---|
| 3 | * OS/2 kernel Loader Stuff.
|
---|
| 4 | *
|
---|
| 5 | * Copyright (c) 2001 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
| 6 | *
|
---|
| 7 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
| 8 | *
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | #ifndef _OS2KLDR_H_
|
---|
| 12 | #define _OS2KLDR_H_
|
---|
| 13 |
|
---|
| 14 | #ifdef __cplusplus
|
---|
| 15 | extern "C" {
|
---|
| 16 | #endif
|
---|
| 17 |
|
---|
| 18 | #pragma pack(1)
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | /*******************************************************************************
|
---|
| 22 | * Structures and Typedefs *
|
---|
| 23 | *******************************************************************************/
|
---|
| 24 | typedef struct OTE
|
---|
| 25 | {
|
---|
| 26 | ULONG ote_size; /* Object virtual size */
|
---|
| 27 | ULONG ote_base; /* Object base virtual address */
|
---|
| 28 | ULONG ote_flags; /* Attribute flags */
|
---|
| 29 | ULONG ote_pagemap; /* Object page map index */
|
---|
| 30 | ULONG ote_mapsize; /* Num of entries in obj page map */
|
---|
| 31 | /*ULONG ote_reserved;*/
|
---|
| 32 | USHORT ote_sel; /* Object Selector */
|
---|
| 33 | USHORT ote_hob; /* Object Handle */
|
---|
| 34 | } OTE, *POTE;
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 | /* ote_flags */
|
---|
[21916] | 38 | #if !defined(__EXE386__) && !defined(_LXexe_h_)
|
---|
[5086] | 39 | #define OBJREAD 0x00000001L /* Readable Object */
|
---|
| 40 | #define OBJWRITE 0x00000002L /* Writeable Object */
|
---|
| 41 | #define OBJEXEC 0x00000004L /* Executable Object */
|
---|
| 42 | #define OBJRSRC 0x00000008L /* Resource Object */
|
---|
| 43 | #define OBJDISCARD 0x00000010L /* Object is Discardable */
|
---|
| 44 | #define OBJSHARED 0x00000020L /* Object is Shared */
|
---|
| 45 | #define OBJPRELOAD 0x00000040L /* Object has preload pages */
|
---|
| 46 | #define OBJINVALID 0x00000080L /* Object has invalid pages */
|
---|
| 47 | #endif
|
---|
| 48 | #define OBJZEROFIL 0x00000100L /* Object has zero-filled pages */
|
---|
[21916] | 49 | #if !defined(__EXE386__) && !defined(_LXexe_h_)
|
---|
[5086] | 50 | #define OBJRESIDENT 0x00000200L /* Object is resident */
|
---|
| 51 | #define OBJCONTIG 0x00000300L /* Object is resident and contiguous */
|
---|
| 52 | #define OBJDYNAMIC 0x00000400L /* Object is permanent and long locable */
|
---|
| 53 | #define OBJTYPEMASK 0x00000700L /* Object type mask */
|
---|
| 54 | #define OBJALIAS16 0x00001000L /* 16:16 alias required */
|
---|
| 55 | #define OBJBIGDEF 0x00002000L /* Big/Default bit setting */
|
---|
| 56 | #define OBJCONFORM 0x00004000L /* Object is conforming for code */
|
---|
| 57 | #define OBJIOPL 0x00008000L /* Object I/O privilege level */
|
---|
| 58 | #endif
|
---|
| 59 | #define OBJMADEPRIV 0x40000000L /* Object is made private for debug (now obsolete) */
|
---|
| 60 | #define OBJALLOC 0x80000000L /* Object is allocated used by loader */
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 |
|
---|
| 66 |
|
---|
| 67 | /*************************/
|
---|
| 68 | /* warp 3.0 AS SMTEs */
|
---|
| 69 | /* Swap ModuleTableEntry */
|
---|
| 70 | /*************************/
|
---|
| 71 | typedef struct SMTE
|
---|
| 72 | {
|
---|
| 73 | /* lxheader fields */
|
---|
| 74 | /*- magic,border,worder,level,cpu,os,ver,mflags */
|
---|
| 75 | ULONG smte_mpages; /* 00 Module # pages */
|
---|
| 76 | ULONG smte_startobj; /* 04 Object # for instruction */
|
---|
| 77 | ULONG smte_eip; /* 08 Extended instruction pointer */
|
---|
| 78 | ULONG smte_stackobj; /* 0c Object # for stack pointer */
|
---|
| 79 | ULONG smte_esp; /* 10 Extended stack pointer */
|
---|
| 80 | /*- pagesize*/
|
---|
| 81 | ULONG smte_pageshift; /* 14 Page alignment shift in .EXE */
|
---|
| 82 | ULONG smte_fixupsize; /* 18 Fixup section size */
|
---|
| 83 | /*- fixupsum,ldrsize,ldrsum*/
|
---|
| 84 | POTE smte_objtab; /* 1c Object table offset - POINTER */
|
---|
| 85 | ULONG smte_objcnt; /* 20 Number of objects in module */
|
---|
| 86 | ULONG smte_objmap; /* 24 Object page map offset - POINTER */
|
---|
| 87 | ULONG smte_itermap; /* 28 Object iterated data map offset */
|
---|
| 88 | ULONG smte_rsrctab; /* 2c Offset of Resource Table */
|
---|
| 89 | ULONG smte_rsrccnt; /* 30 Number of resource entries */
|
---|
| 90 | ULONG smte_restab; /* 34 Offset of resident name table - POINTER */
|
---|
| 91 | ULONG smte_enttab; /* 38 Offset of Entry Table - POINTER */
|
---|
| 92 | ULONG smte_fpagetab; /* 3c Offset of Fixup Page Table - POINTER */
|
---|
| 93 | ULONG smte_frectab; /* 40 Offset of Fixup Record Table - POINTER */
|
---|
| 94 | ULONG smte_impmod; /* 44 Offset of Import Module Name Table - POINTER */
|
---|
| 95 | /*- impmodcnt*/
|
---|
| 96 | ULONG smte_impproc; /* 48 Offset of Imp Procedure Name Tab - POINTER */
|
---|
| 97 | /*- pagesum*/
|
---|
| 98 | ULONG smte_datapage; /* 4c Offset of Enumerated Data Pages */
|
---|
| 99 | /*- preload*/
|
---|
| 100 | ULONG smte_nrestab; /* 50 Offset of Non-resident Names Table */
|
---|
| 101 | ULONG smte_cbnrestab; /* 54 Size of Non-resident Name Table */
|
---|
| 102 | /*- nressum*/
|
---|
| 103 | ULONG smte_autods; /* 58 Object # for automatic data object */
|
---|
| 104 | ULONG smte_debuginfo; /* 5c Offset of the debugging info */
|
---|
| 105 | ULONG smte_debuglen; /* 60 The len of the debug info in */
|
---|
| 106 | /*- instpreload,instdemand*/
|
---|
| 107 | ULONG smte_heapsize; /* 64 use for converted 16-bit modules */
|
---|
| 108 | /*- res3*/
|
---|
| 109 | /* extra */
|
---|
| 110 | PCHAR smte_path; /* 68 full pathname - POINTER */
|
---|
| 111 | USHORT smte_semcount; /* 6c Count of threads waiting on MTE semaphore. 0 => semaphore is free */
|
---|
| 112 | USHORT smte_semowner; /* 6e Slot number of the owner of MTE semahore */
|
---|
| 113 | ULONG smte_pfilecache; /* 70 Pointer to file cache for Dos32CacheModule */
|
---|
| 114 | ULONG smte_stacksize; /* 74 Thread 1 Stack size from the exe header */
|
---|
| 115 | USHORT smte_alignshift; /* 78 use for converted 16-bit modules */
|
---|
| 116 | USHORT smte_NEexpver; /* 7a expver from NE header */
|
---|
| 117 | USHORT smte_pathlen; /* 7c length of full pathname */
|
---|
| 118 | USHORT smte_NEexetype; /* 7e exetype from NE header */
|
---|
| 119 | USHORT smte_csegpack; /* 80 count of segs to pack */
|
---|
| 120 | } SMTE, *PSMTE;
|
---|
| 121 |
|
---|
| 122 |
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 |
|
---|
| 126 |
|
---|
| 127 |
|
---|
| 128 |
|
---|
| 129 | /********************/
|
---|
| 130 | /* warp 3.0 GA MTEs */
|
---|
| 131 | /* ModuleTableEntry */
|
---|
| 132 | /********************/
|
---|
| 133 | typedef struct MTE
|
---|
| 134 | {
|
---|
| 135 | USHORT mte_flags2;
|
---|
| 136 | USHORT mte_handle;
|
---|
| 137 | PSMTE mte_swapmte; /* handle for swapmte */
|
---|
| 138 | struct MTE * mte_link;
|
---|
| 139 | ULONG mte_flags1;
|
---|
| 140 | ULONG mte_impmodcnt; /* number of entries in Import Module Name Table*/
|
---|
| 141 | SFN mte_sfn; /*"filehandle"*/
|
---|
| 142 | USHORT mte_usecnt; /* (.EXE only) - use count */
|
---|
| 143 | CHAR mte_modname[8];
|
---|
| 144 | } MTE,*PMTE,**PPMTE;
|
---|
| 145 |
|
---|
| 146 |
|
---|
| 147 | /***********/
|
---|
| 148 | /* flags 1 */
|
---|
| 149 | /***********/
|
---|
| 150 | #define NOAUTODS 0x00000000 /* No Auto DS exists */
|
---|
| 151 | #define SOLO 0x00000001 /* Auto DS is shared */
|
---|
| 152 | #define INSTANCEDS 0x00000002 /* Auto DS is not shared */
|
---|
| 153 | #define INSTLIBINIT 0x00000004 /* Perinstance Libinit */
|
---|
| 154 | #define GINISETUP 0x00000008 /* Global Init has been setup */
|
---|
| 155 | #define NOINTERNFIXUPS 0x00000010 /* internal fixups in .EXE.DLL applied */
|
---|
| 156 | #define NOEXTERNFIXUPS 0x00000020 /* external fixups in .EXE.DLL applied */
|
---|
| 157 | #define CLASS_PROGRAM 0x00000040 /* Program class */
|
---|
| 158 | #define CLASS_GLOBAL 0x00000080 /* Global class */
|
---|
| 159 | #define CLASS_SPECIFIC 0x000000C0 /* Specific class, as against global */
|
---|
| 160 | #define CLASS_ALL 0x00000000 /* nonspecific class all modules */
|
---|
| 161 | #define CLASS_MASK 0x000000C0 /* */
|
---|
| 162 | #define MTEPROCESSED 0x00000100 /* MTE being loaded */
|
---|
| 163 | #define USED 0x00000200 /* MTE is referenced see ldrgc.c */
|
---|
| 164 | #define DOSLIB 0x00000400 /* set if DOSCALL1 */
|
---|
| 165 | #define DOSMOD 0x00000800 /* set if DOSCALLS */
|
---|
| 166 | #define MTE_MEDIAFIXED 0x00001000 /* File Media permits discarding */
|
---|
| 167 | #define LDRINVALID 0x00002000 /* module not loadable */
|
---|
| 168 | #define PROGRAMMOD 0x00000000 /* program module */
|
---|
| 169 | #define DEVDRVMOD 0x00004000 /* device driver module */
|
---|
| 170 | #define LIBRARYMOD 0x00008000 /* DLL module */
|
---|
| 171 | #define VDDMOD 0x00010000 /* VDD module */
|
---|
| 172 | #define MVDMMOD 0x00020000 /* Set if VDD Helper MTE (MVDM.DLL) */
|
---|
| 173 | #define INGRAPH 0x00040000 /* In Module Graph see ldrgc.c */
|
---|
| 174 | #define GINIDONE 0x00080000 /* Global Init has finished */
|
---|
| 175 | #define MTEADDRALLOCED 0x00100000 /* Allocate specific or not */
|
---|
| 176 | #define FSDMOD 0x00200000 /* FSD MTE */
|
---|
| 177 | #define FSHMOD 0x00400000 /* FS helper MTE */
|
---|
| 178 | #define MTELONGNAMES 0x00800000 /* Module supports longnames */
|
---|
| 179 | #define MTE_MEDIACONTIG 0x01000000 /* File Media contiguous memory req */
|
---|
| 180 | #define MTE_MEDIA16M 0x02000000 /* File Media requires mem below 16M */
|
---|
| 181 | #define MTESWAPONLOAD 0x04000000 /* make code pages swap on load */
|
---|
| 182 | #define MTEPORTHOLE 0x08000000 /* porthole module */
|
---|
| 183 | #define MTEMODPROT 0x10000000 /* Module has shared memory protected */
|
---|
| 184 | #define MTENEWMOD 0x20000000 /* Newly added module */
|
---|
| 185 | #define MTEDLLTERM 0x40000000 /* Gets instance termination */
|
---|
| 186 | #define MTESYMLOADED 0x80000000 /* Set if debugger symbols loaded */
|
---|
| 187 |
|
---|
| 188 |
|
---|
| 189 | /***********/
|
---|
| 190 | /* flags 2 */
|
---|
| 191 | /***********/
|
---|
| 192 | #define MTEFORMATMASK 0x0003 /* Module format mask */
|
---|
| 193 | #define MTEFORMATR1 0x0000 /* Module format reserved */
|
---|
| 194 | #define MTEFORMATNE 0x0001 /* Module format NE */
|
---|
| 195 | #define MTEFORMATLX 0x0002 /* Module format LX */
|
---|
| 196 | #define MTEFORMATR2 0x0003 /* Module format reserved */
|
---|
| 197 | #define MTESYSTEMDLL 0x0004 /* DLL exists in system list */
|
---|
| 198 | #define MTELOADORATTACH 0x0008 /* Module under load or attach for init */
|
---|
| 199 | #define MTECIRCLEREF 0x0010 /* Module circular reference detection */
|
---|
| 200 | #define MTEFREEFIXUPS 0x0020 /* Free system mte's fixup flag d#98488 */
|
---|
| 201 | #define MTEPRELOADED 0x0040 /* MTE Preload completed */
|
---|
| 202 | #define MTEGETMTEDONE 0x0080 /* GetMTE already resolved */
|
---|
| 203 | #define MTEPACKSEGDONE 0x0100 /* Segment packed memory allocated */
|
---|
| 204 | #define MTE20LIELIST 0x0200 /* Name present in version20 lie list */
|
---|
| 205 | #define MTESYSPROCESSED 0x0400 /* System DLL already processed */
|
---|
| 206 | #define MTEDLLONEXTLST 0x1000 /* DLL has term routine on exit list #74177 */
|
---|
| 207 |
|
---|
| 208 |
|
---|
| 209 | #pragma pack()
|
---|
| 210 |
|
---|
| 211 |
|
---|
| 212 | #ifndef INCL_OS2KRNL_LDR_NOAPIS /* Flag to exclude prototypes. */
|
---|
| 213 | #ifndef INCL_16 /* 16-bit test - function prototypes for 32-bit code only! */
|
---|
| 214 |
|
---|
| 215 |
|
---|
| 216 | /*******************************************************************************
|
---|
| 217 | * Defined Constants And Macros *
|
---|
| 218 | *******************************************************************************/
|
---|
| 219 | #define LDRCALL __stdcall
|
---|
| 220 |
|
---|
| 221 | /** Additional ldrFindModule flag. Or together with the class. */
|
---|
| 222 | #define SEARCH_FULL_NAME 0x0001
|
---|
| 223 |
|
---|
| 224 |
|
---|
| 225 | /*******************************************************************************
|
---|
[6229] | 226 | * Global Variables *
|
---|
| 227 | *******************************************************************************/
|
---|
| 228 | extern PSZ* pLdrLibPath; /* Pointer to the libpath pointer. */
|
---|
| 229 |
|
---|
| 230 |
|
---|
| 231 | /*******************************************************************************
|
---|
[5086] | 232 | * Function Prototypes *
|
---|
| 233 | *******************************************************************************/
|
---|
| 234 | /**
|
---|
| 235 | * _ldrClose
|
---|
| 236 | */
|
---|
| 237 | extern ULONG LDRCALL ldrClose( /* retd 0x04 */
|
---|
| 238 | SFN p1 /* ebp + 0x08 */
|
---|
| 239 | );
|
---|
| 240 |
|
---|
| 241 | ULONG LDRCALL myldrClose(SFN);
|
---|
| 242 |
|
---|
| 243 |
|
---|
| 244 | /**
|
---|
| 245 | * _ldrOpen
|
---|
| 246 | */
|
---|
| 247 | extern ULONG LDRCALL ldrOpen( /* retd 0x0c */
|
---|
| 248 | PSFN p1, /* ebp + 0x08 */
|
---|
| 249 | PCHAR p2, /* ebp + 0x0c */
|
---|
| 250 | PULONG p3 /* ebp + 0x10 */
|
---|
| 251 | );
|
---|
| 252 |
|
---|
| 253 | ULONG LDRCALL myldrOpen(PSFN phFile, PSZ pszFilename, PULONG pfl);
|
---|
| 254 |
|
---|
| 255 |
|
---|
| 256 | /**
|
---|
| 257 | * _ldrRead
|
---|
| 258 | */
|
---|
| 259 | extern ULONG LDRCALL ldrRead( /* retd 0x18 */
|
---|
| 260 | SFN hFile, /* ebp + 0x08 */
|
---|
| 261 | ULONG ulOffset, /* ebp + 0x0c */
|
---|
| 262 | PVOID pvBuffer, /* ebp + 0x10 */
|
---|
| 263 | ULONG fpBuffer, /* ebp + 0x14 */
|
---|
| 264 | ULONG cbToRead, /* ebp + 0x18 */
|
---|
| 265 | PMTE pMTE /* ebp + 0x1c */
|
---|
| 266 | );
|
---|
| 267 |
|
---|
| 268 | ULONG LDRCALL myldrRead(
|
---|
| 269 | SFN hFile,
|
---|
| 270 | ULONG ulOffset,
|
---|
| 271 | PVOID pvBuffer,
|
---|
| 272 | ULONG fpBuffer,
|
---|
| 273 | ULONG cbToRead,
|
---|
| 274 | PMTE pMTE
|
---|
| 275 | );
|
---|
| 276 |
|
---|
| 277 |
|
---|
| 278 |
|
---|
| 279 | /**
|
---|
| 280 | * _LDRQAppType
|
---|
| 281 | */
|
---|
| 282 | extern ULONG LDRCALL LDRQAppType( /* retd 0x08 */
|
---|
| 283 | ULONG p1, /* ebp + 0x08 */
|
---|
| 284 | ULONG p2 /* ebp + 0x0c */
|
---|
| 285 | );
|
---|
| 286 |
|
---|
| 287 | ULONG LDRCALL myLDRQAppType(ULONG,ULONG);
|
---|
| 288 |
|
---|
| 289 |
|
---|
| 290 | /**
|
---|
| 291 | * ldrEnum32bitRelRecs
|
---|
| 292 | * @param pMTE Pointer to MTE for this module.
|
---|
| 293 | * @param iObject Object index. 0-based!
|
---|
| 294 | * @param iPageTabl Page index. 0-based!
|
---|
| 295 | * @param pvPage Pointer to page buffer.
|
---|
| 296 | * @param ulPageAddress Note! Page is not present.
|
---|
| 297 | * @param pPTDA
|
---|
| 298 | *
|
---|
| 299 | */
|
---|
| 300 | extern ULONG LDRCALL ldrEnum32bitRelRecs( /* retd 0x20 */
|
---|
| 301 | PMTE pMTE, /* ebp + 0x08 */
|
---|
| 302 | ULONG iObject, /* ebp + 0x0c */
|
---|
| 303 | ULONG iPageTable, /* ebp + 0x10 */
|
---|
| 304 | PVOID pvPage, /* ebp + 0x14 */
|
---|
| 305 | ULONG ulPageAddress, /* ebp + 0x18 */
|
---|
| 306 | PVOID pvPTDA /* ebp + 0x1c */
|
---|
| 307 | );
|
---|
| 308 |
|
---|
| 309 | ULONG LDRCALL myldrEnum32bitRelRecs(PMTE, ULONG, ULONG, PVOID, ULONG, PVOID);
|
---|
| 310 |
|
---|
| 311 |
|
---|
| 312 |
|
---|
| 313 | /**
|
---|
| 314 | * Loader local variables from KERNEL.SDF.
|
---|
| 315 | */
|
---|
| 316 | typedef struct ldrlv_s /* #memb 12 size 39 (0x027) */
|
---|
| 317 | {
|
---|
| 318 | PMTE lv_pmte; /* Pointer to mte. (ldrCreateMte/ldrXXX) */
|
---|
| 319 | ULONG lv_lbufaddr;
|
---|
| 320 | ULONG lv_sbufaddr;
|
---|
| 321 | ULONG lv_lrecbufaddr;
|
---|
| 322 | ULONG lv_srecbufaddr;
|
---|
| 323 | ULONG lv_new_exe_off;
|
---|
| 324 | USHORT lv_sfn; /* Handle to the module being loaded */
|
---|
| 325 | USHORT lv_hobmte;
|
---|
| 326 | ULONG lv_objnum;
|
---|
| 327 | ULONG lv_csmte; /* size of the swappable mte heap block. (ldrCreateMte) */
|
---|
| 328 | USHORT lv_class; /* Object class CLASS_* defines in OS2Krnl (mteflags1) it seems. */
|
---|
| 329 | /* CLASS_PROGRAM Program class. */
|
---|
| 330 | /* CLASS_GLOBAL Global class. */
|
---|
| 331 | /* CLASS_SPECIFIC Specific class, as against global. */
|
---|
| 332 | /* CLASS_ALL (0) Nonspecific class all modules. */
|
---|
| 333 | /* CLASS_MASK Class mask. */
|
---|
| 334 | UCHAR lv_type; /* Type of executable image expected loaded. */
|
---|
| 335 | } ldrlv_t;
|
---|
| 336 |
|
---|
| 337 |
|
---|
| 338 | /*
|
---|
| 339 | * Values of the lv_type byte. (Qualified guesses.)
|
---|
| 340 | */
|
---|
| 341 | #define LVTYPE_EXE 0 /* Executable program. */
|
---|
| 342 | #define LVTYPE_DLL 1 /* Dynamic Link Library. */
|
---|
| 343 | #define LVTYPE_DD 2 /* Device Driver. */
|
---|
| 344 | #define LVTYPE_IFS 3 /* Installable Filesystem. */
|
---|
| 345 | #define LVTYPE_VDD 4 /* Virtual Device Driver (for VDMs). */
|
---|
| 346 |
|
---|
| 347 |
|
---|
| 348 |
|
---|
| 349 | /**
|
---|
| 350 | * ldrOpenPath
|
---|
| 351 | * pre 14053.
|
---|
| 352 | * @returns OS2 return code.
|
---|
| 353 | * pLdrLv->lv_sfn is set to filename handle.
|
---|
| 354 | * @param pachModname Pointer to modulename. Not zero terminated!
|
---|
| 355 | * @param cchModname Modulename length.
|
---|
| 356 | * @param pLdrLv Loader local variables? (Struct from KERNEL.SDF)
|
---|
| 357 | * @param pfl Pointer to flags which are passed on to ldrOpen.
|
---|
| 358 | * @sketch
|
---|
| 359 | * if !CLASS_GLOBAL or miniifs then
|
---|
| 360 | * ldrOpen(pachModName)
|
---|
| 361 | * else
|
---|
| 362 | * loop until no more libpath elements
|
---|
| 363 | * get next libpath element and add it to the modname.
|
---|
| 364 | * try open the modname
|
---|
| 365 | * if successfull then break the loop.
|
---|
| 366 | * endloop
|
---|
| 367 | * endif
|
---|
| 368 | */
|
---|
| 369 | extern ULONG LDRCALL ldrOpenPath_old( /* retd 0x10 */
|
---|
| 370 | PCHAR pachFilename, /* ebp + 0x08 */
|
---|
| 371 | USHORT cchFilename, /* ebp + 0x0c */
|
---|
| 372 | ldrlv_t * plv, /* ebp + 0x10 */
|
---|
| 373 | PULONG pful /* ebp + 0x14 */
|
---|
| 374 | );
|
---|
| 375 |
|
---|
| 376 | ULONG LDRCALL myldrOpenPath_old(PCHAR pachFilename, USHORT cchFilename, ldrlv_t *plv, PULONG pful);
|
---|
| 377 |
|
---|
| 378 |
|
---|
| 379 | /**
|
---|
| 380 | * ldrOpenPath - ldrOpenPath for build 14053 and above.
|
---|
| 381 | *
|
---|
| 382 | * @returns OS2 return code.
|
---|
| 383 | * plv->lv_sfn is set to filename handle.
|
---|
| 384 | * @param pachFilename Pointer to modulename. Not zero terminated!
|
---|
| 385 | * @param cchFilename Modulename length.
|
---|
| 386 | * @param plv Loader local variables? (Struct from KERNEL.SDF)
|
---|
| 387 | * @param pful Pointer to flags which are passed on to ldrOpen.
|
---|
| 388 | * @param lLibPath New parameter in build 14053.
|
---|
| 389 | * ldrGetMte calls with 1
|
---|
| 390 | * ldrOpenNewExe calls with 3
|
---|
| 391 | * This is compared to the initial libpath index.
|
---|
| 392 | * The libpath index is:
|
---|
| 393 | * BEGINLIBPATH 1
|
---|
| 394 | * LIBPATH 2
|
---|
| 395 | * ENDLIBPATH 3
|
---|
| 396 | * The initial libpath index is either 1 or 2.
|
---|
| 397 | *
|
---|
| 398 | * @sketch
|
---|
| 399 | * This is roughly what the original ldrOpenPath does:
|
---|
| 400 | * Save pTCBCur->TCBFailErr.
|
---|
| 401 | * if !CLASS_GLOBAL or miniifs then
|
---|
| 402 | * ldrOpen(pachFilename)
|
---|
| 403 | * else
|
---|
| 404 | * if beglibpath != NULL then path = 1 else path = 2
|
---|
| 405 | * if (lLibPath < path)
|
---|
| 406 | * return ERROR_FILE_NOT_FOUND; (2)
|
---|
| 407 | * Allocate buffer.
|
---|
| 408 | * loop until no more libpath elements
|
---|
| 409 | * get next libpath element and add it to the modname.
|
---|
| 410 | * try open the modname
|
---|
| 411 | * if successfull then break the loop.
|
---|
| 412 | * endloop
|
---|
| 413 | * Free buffer.
|
---|
| 414 | * endif
|
---|
| 415 | * Restore pTCBCur->TCBFailErr.
|
---|
| 416 | */
|
---|
| 417 | extern ULONG LDRCALL ldrOpenPath( /* retd 0x14 */
|
---|
| 418 | PCHAR pachFilename, /* ebp + 0x08 */
|
---|
| 419 | USHORT cchFilename, /* ebp + 0x0c */
|
---|
| 420 | ldrlv_t * plv, /* ebp + 0x10 */
|
---|
| 421 | PULONG pful, /* ebp + 0x14 */
|
---|
| 422 | ULONG lLibPath /* ebp + 0x18 */
|
---|
| 423 | );
|
---|
| 424 |
|
---|
| 425 | ULONG LDRCALL myldrOpenPath(PCHAR pachFilename, USHORT cchFilename, ldrlv_t *plv, PULONG pful, ULONG lLibPath);
|
---|
| 426 |
|
---|
| 427 |
|
---|
| 428 | /**
|
---|
| 429 | * Finds a module if it's loaded.
|
---|
| 430 | * @returns NO_ERROR on success.
|
---|
| 431 | * OS/2 errorcode on error.
|
---|
| 432 | * @param pachFilename Pointer to module filename.
|
---|
| 433 | * @param cchFilename Length of modulefilename.
|
---|
| 434 | * @param usClass Module class. (CLASS_*)
|
---|
| 435 | * @param ppMTE Pointer to pMTE found.
|
---|
| 436 | * @sketch
|
---|
| 437 | */
|
---|
| 438 | ULONG LDRCALL ldrFindModule( /* retd 0x10 */
|
---|
| 439 | PCHAR pachFilename, /* ebp + 0x08 */
|
---|
| 440 | USHORT cchFilename, /* ebp + 0x0c */
|
---|
| 441 | USHORT usClass, /* ebp + 0x10 */
|
---|
| 442 | PPMTE ppMTE /* ebp + 0x14 */
|
---|
| 443 | );
|
---|
| 444 |
|
---|
| 445 | ULONG LDRCALL myldrFindModule(PCHAR pachFilename, USHORT cchFilename, USHORT usClass, PPMTE ppMTE);
|
---|
| 446 |
|
---|
| 447 |
|
---|
| 448 | /**
|
---|
| 449 | * Checks if a module was loaded using DosLoadModule.
|
---|
| 450 | * This is called from LDRGetProcAddr and LDRFreeModule.
|
---|
| 451 | * @returns NO_ERROR if the module was LoadModuled or executable.
|
---|
| 452 | * ERROR_INVALID_HANDLE if not LoadModuled.
|
---|
| 453 | * @param hmte MTE handle.
|
---|
| 454 | * @param pptda Pointer to the PTDA of the process calling. (current)
|
---|
| 455 | * @param pcUsage Pointer to usage variable. (output)
|
---|
| 456 | * The usage count is returned.
|
---|
| 457 | * @sketch
|
---|
| 458 | */
|
---|
| 459 | #ifdef _ptda_h_
|
---|
| 460 | ULONG LDRCALL ldrWasLoadModuled( /* retd 0x0c */
|
---|
| 461 | HMTE hmte, /* ebp + 0x08 */
|
---|
| 462 | PPTDA pptda, /* ebp + 0x0c */
|
---|
| 463 | PULONG pcUsage); /* ebp + 0x10 */
|
---|
| 464 |
|
---|
| 465 | ULONG LDRCALL myldrWasLoadModuled(HMTE hmte, PPTDA pptda, PULONG pcUsage);
|
---|
| 466 | #endif
|
---|
| 467 |
|
---|
| 468 |
|
---|
| 469 | /**
|
---|
| 470 | * LDRGetProcAddr gets address and proctype for a entry point to a module.
|
---|
| 471 | * @returns NO_ERROR if the module was LoadModuled.
|
---|
| 472 | * ERROR_INVALID_HANDLE if not LoadModuled.
|
---|
| 473 | * @param hmte Handle of module.
|
---|
| 474 | * @param ulOrdinal Procedure ordinal.
|
---|
| 475 | * @param pszName Pointer to procedure name.
|
---|
| 476 | * NULL is allowed. Ignored if ulOrdinal is not zero.
|
---|
| 477 | * @param pulAddress Pointer to address variable. (output)
|
---|
| 478 | * @param fFlat TRUE if a flat 0:32 address is to be returned.
|
---|
| 479 | * FALSE if a far 16:16 address is to be returned.
|
---|
| 480 | * @param pulProcType Pointer to procedure type variable. (output)
|
---|
| 481 | * NULL is allowed. (DosQueryProcAddr uses NULL)
|
---|
| 482 | * In user space.
|
---|
| 483 | * @sketch
|
---|
| 484 | */
|
---|
| 485 | ULONG LDRCALL LDRGetProcAddr( /* retd 0x14 */
|
---|
| 486 | HMTE hmte, /* ebp + 0x08 */
|
---|
| 487 | ULONG ulOrdinal, /* ebp + 0x0c */
|
---|
| 488 | PCSZ pszName, /* ebp + 0x10 */
|
---|
| 489 | PULONG pulAddress, /* ebp + 0x14 */
|
---|
| 490 | BOOL fFlat, /* ebp + 0x18 */
|
---|
| 491 | PULONG pulProcType); /* ebp + 0x1c */
|
---|
| 492 |
|
---|
| 493 | ULONG LDRCALL myLDRGetProcAddr(HMTE hmte, ULONG ulOrdinal, PCSZ pszName, PULONG pulAddress, BOOL fFlat, PULONG pulProcType);
|
---|
| 494 |
|
---|
| 495 |
|
---|
| 496 |
|
---|
| 497 | /**
|
---|
| 498 | * LDRClearSem - Clears the loader semaphore.
|
---|
| 499 | * (It does some garbage collection on release.)
|
---|
| 500 | * @returns NO_ERROR on success.
|
---|
| 501 | * OS/2 error on failure. (ERROR_INTERRUPT?)
|
---|
| 502 | */
|
---|
| 503 | extern ULONG LDRCALL LDRClearSem(void);
|
---|
| 504 |
|
---|
| 505 |
|
---|
| 506 | /**
|
---|
| 507 | * LDRRequestSem - Requests the loader semaphore..
|
---|
| 508 | * @returns NO_ERROR if succesfully.
|
---|
| 509 | * OS2 errorcode on failure. (ERROR_INTERRUPT?)
|
---|
| 510 | */
|
---|
| 511 | #define LDRRequestSem() KSEMRequestMutex(pLdrSem, (ULONG)-1)
|
---|
| 512 |
|
---|
| 513 |
|
---|
| 514 | /*
|
---|
| 515 | * Pointer to the loader semaphore.
|
---|
| 516 | */
|
---|
| 517 | #ifdef _OS2KSEM_h_
|
---|
| 518 | extern PKSEMMTX pLdrSem;
|
---|
| 519 | #endif
|
---|
| 520 |
|
---|
| 521 |
|
---|
| 522 | /**
|
---|
| 523 | * Validates an hMTE and gets the MTE pointer.
|
---|
| 524 | * @returns Pointer to MTE on success.
|
---|
| 525 | * NULL on error.
|
---|
| 526 | * @param hMTE MTE handle.
|
---|
| 527 | * @remark If you wan't to this faster:
|
---|
| 528 | * Use the hMTE as a HOB and get the HOB address (by using VMGetHandleInfo).
|
---|
| 529 | */
|
---|
| 530 | extern PMTE LDRCALL ldrValidateMteHandle(HMTE hMTE);
|
---|
| 531 |
|
---|
| 532 |
|
---|
| 533 | /**
|
---|
| 534 | * Gets the pMTE from a hMTE. No checks.
|
---|
| 535 | * @returns Pointer to the pMTE for a given hMTE.
|
---|
| 536 | * @param hMTE Module handle.
|
---|
| 537 | * @sketch
|
---|
| 538 | */
|
---|
| 539 | extern PMTE KRNLCALL ldrASMpMTEFromHandle(HMTE hMTE);
|
---|
| 540 |
|
---|
| 541 |
|
---|
| 542 | /**
|
---|
| 543 | * Translates a relative filename to a full qualified filename.
|
---|
| 544 | * @returns NO_ERROR on success.
|
---|
| 545 | * Errorcode on error.
|
---|
| 546 | * @param pszFilename Pointer to nullterminated filename.
|
---|
| 547 | */
|
---|
| 548 | extern ULONG LDRCALL ldrTransPath(PSZ pszFilename);
|
---|
| 549 |
|
---|
| 550 |
|
---|
| 551 | /**
|
---|
| 552 | * Sets the VM flags for an executable object.
|
---|
| 553 | * @returns void
|
---|
| 554 | * @param pMTE Pointer to the module table entry.
|
---|
| 555 | * @param flObj LX Object flags.
|
---|
| 556 | * @param pflFlags1 Pointer to the flFlags1 of VMAllocMem (out).
|
---|
| 557 | * @param pflFlags2 Pointer to the flFlags2 of VMAllocMem (out).
|
---|
| 558 | */
|
---|
| 559 | extern VOID LDRCALL ldrSetVMflags( /* retd 0x10 */
|
---|
| 560 | PMTE pMTE, /* ebp + 0x08 */
|
---|
| 561 | ULONG flObj, /* ebp + 0x0c */
|
---|
| 562 | PULONG pflFlags1, /* ebp + 0x10 */
|
---|
| 563 | PULONG pflFlags2 /* ebp + 0x14 */
|
---|
| 564 | );
|
---|
| 565 |
|
---|
| 566 | VOID LDRCALL myldrSetVMflags(PMTE pMTE, ULONG flObj, PULONG pflFlags1, PULONG pflFlags2);
|
---|
| 567 |
|
---|
| 568 |
|
---|
| 569 | /**
|
---|
| 570 | * Checks if the internal name (first name in the resident nametable) matches
|
---|
| 571 | * the filename.
|
---|
| 572 | * @returns NO_ERROR on success (the name matched).
|
---|
| 573 | * ERROR_INVALID_NAME if mismatch.
|
---|
| 574 | * @param pMTE Pointer to the MTE of the module to check.<br>
|
---|
| 575 | * Assumes! that the filename for this module is present in ldrpFileNameBuf.
|
---|
| 576 | */
|
---|
| 577 | extern ULONG LDRCALL ldrCheckInternalName( /* retd 0x04 */
|
---|
| 578 | PMTE pMTE /* ebp + 0x08 */
|
---|
| 579 | );
|
---|
| 580 |
|
---|
| 581 | ULONG LDRCALL myldrCheckInternalName(PMTE pMTE);
|
---|
| 582 |
|
---|
| 583 |
|
---|
| 584 | /**
|
---|
| 585 | * Parses a filename to find the name and extention.
|
---|
| 586 | * @returns Length of the filename without the extention.
|
---|
| 587 | * @param pachFilename Pointer to filename to parse - must have path!
|
---|
| 588 | * @param ppachName Pointer to pointer which should hold the name pointer upon successfull return.
|
---|
| 589 | * @param ppachExt Pointer to pointer which should hold the extention pointer upon successfull return.
|
---|
| 590 | */
|
---|
| 591 | extern ULONG LDRCALL ldrGetFileName(PSZ pszFilename, PCHAR *ppchName, PCHAR *ppchExt);
|
---|
| 592 |
|
---|
| 593 |
|
---|
| 594 | /**
|
---|
| 595 | * Parses a filename to find the name and extention.
|
---|
| 596 | * @returns Length of the filename without the extention.
|
---|
| 597 | * @param pachFilename Pointer to filename to parse - path not needed.
|
---|
| 598 | * @param ppachName Pointer to pointer which should hold the name pointer upon successfull return.
|
---|
| 599 | * @param ppachExt Pointer to pointer which should hold the extention pointer upon successfull return.
|
---|
| 600 | */
|
---|
| 601 | extern ULONG LDRCALL ldrGetFileName2(PSZ pszFilename, PCHAR *ppchName, PCHAR *ppchExt);
|
---|
| 602 |
|
---|
| 603 |
|
---|
| 604 | /**
|
---|
| 605 | * Uppercase a string.
|
---|
| 606 | * @returns void
|
---|
| 607 | * @param pach String to uppercase.
|
---|
| 608 | * @param cch Length of string. (may include terminator)
|
---|
| 609 | */
|
---|
| 610 | extern VOID LDRCALL ldrUCaseString(PCHAR pch, unsigned cch);
|
---|
| 611 |
|
---|
| 612 |
|
---|
| 613 | /**
|
---|
| 614 | * Pointer to the loader filename buffer.
|
---|
| 615 | * Upon return from ldrOpen (and ldrOpenPath which calls ldrOpen) this is
|
---|
| 616 | * set to the fully qualified filename of the file last opened (successfully).
|
---|
| 617 | */
|
---|
| 618 | extern PSZ *pldrpFileNameBuf;
|
---|
| 619 | #define ldrpFileNameBuf (*pldrpFileNameBuf)
|
---|
| 620 |
|
---|
| 621 |
|
---|
| 622 |
|
---|
| 623 | #endif /* INCL_16 (16-bit test - function prototypes for 32-bit code only!) */
|
---|
| 624 | #endif /* no loader api test */
|
---|
| 625 |
|
---|
| 626 |
|
---|
| 627 | #ifdef __cplusplus
|
---|
| 628 | } /* extern "C" */
|
---|
| 629 | #endif
|
---|
| 630 |
|
---|
| 631 | #endif
|
---|