| 1 | /* $Id: LdrCalls.h,v 1.4 2000-09-02 21:08:02 bird Exp $
|
|---|
| 2 | *
|
|---|
| 3 | * Prototypes for the loader overrided function.
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright (c) 1998-1999 knut st. osmundsen
|
|---|
| 6 | *
|
|---|
| 7 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 8 | *
|
|---|
| 9 | */
|
|---|
| 10 | #ifndef _ldrCalls_h_
|
|---|
| 11 | #define _ldrCalls_h_
|
|---|
| 12 |
|
|---|
| 13 | #ifdef __cplusplus
|
|---|
| 14 | extern "C" {
|
|---|
| 15 | #endif
|
|---|
| 16 |
|
|---|
| 17 | /*******************************************************************************
|
|---|
| 18 | * Defined Constants And Macros *
|
|---|
| 19 | *******************************************************************************/
|
|---|
| 20 | #define LDRCALL __stdcall
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 | /**
|
|---|
| 24 | * _ldrClose
|
|---|
| 25 | */
|
|---|
| 26 | extern ULONG LDRCALL ldrClose( /* retd 0x04 */
|
|---|
| 27 | SFN p1 /* ebp + 0x08 */
|
|---|
| 28 | );
|
|---|
| 29 |
|
|---|
| 30 | ULONG LDRCALL myldrClose(SFN);
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 | /**
|
|---|
| 34 | * _ldrOpen
|
|---|
| 35 | */
|
|---|
| 36 | extern ULONG LDRCALL ldrOpen( /* retd 0x0c */
|
|---|
| 37 | PSFN p1, /* ebp + 0x08 */
|
|---|
| 38 | PCHAR p2, /* ebp + 0x0c */
|
|---|
| 39 | PULONG p3 /* ebp + 0x10 */
|
|---|
| 40 | );
|
|---|
| 41 |
|
|---|
| 42 | ULONG LDRCALL myldrOpen(PSFN phFile, PSZ pszFilename, PULONG pfl);
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 | /**
|
|---|
| 46 | * _ldrRead
|
|---|
| 47 | */
|
|---|
| 48 | extern ULONG LDRCALL ldrRead( /* retd 0x18 */
|
|---|
| 49 | SFN hFile, /* ebp + 0x08 */
|
|---|
| 50 | ULONG ulOffset, /* ebp + 0x0c */
|
|---|
| 51 | PVOID pvBuffer, /* ebp + 0x10 */
|
|---|
| 52 | ULONG fpBuffer, /* ebp + 0x14 */
|
|---|
| 53 | ULONG cbToRead, /* ebp + 0x18 */
|
|---|
| 54 | PMTE pMTE /* ebp + 0x1c */
|
|---|
| 55 | );
|
|---|
| 56 |
|
|---|
| 57 | ULONG LDRCALL myldrRead(
|
|---|
| 58 | SFN hFile,
|
|---|
| 59 | ULONG ulOffset,
|
|---|
| 60 | PVOID pvBuffer,
|
|---|
| 61 | ULONG fpBuffer,
|
|---|
| 62 | ULONG cbToRead,
|
|---|
| 63 | PMTE pMTE
|
|---|
| 64 | );
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 | /**
|
|---|
| 69 | * _LDRQAppType
|
|---|
| 70 | */
|
|---|
| 71 | extern ULONG LDRCALL LDRQAppType( /* retd 0x08 */
|
|---|
| 72 | ULONG p1, /* ebp + 0x08 */
|
|---|
| 73 | ULONG p2 /* ebp + 0x0c */
|
|---|
| 74 | );
|
|---|
| 75 |
|
|---|
| 76 | ULONG LDRCALL myLDRQAppType(ULONG,ULONG);
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 | /**
|
|---|
| 80 | * ldrEnum32bitRelRecs
|
|---|
| 81 | * @param pMTE Pointer to MTE for this module.
|
|---|
| 82 | * @param iObject Object index. 0-based!
|
|---|
| 83 | * @param iPageTabl Page index. 0-based!
|
|---|
| 84 | * @param pvPage Pointer to page buffer.
|
|---|
| 85 | * @param ulPageAddress Note! Page is not present.
|
|---|
| 86 | * @param pPTDA
|
|---|
| 87 | *
|
|---|
| 88 | */
|
|---|
| 89 | extern ULONG LDRCALL ldrEnum32bitRelRecs( /* retd 0x20 */
|
|---|
| 90 | PMTE pMTE, /* ebp + 0x08 */
|
|---|
| 91 | ULONG iObject, /* ebp + 0x0c */
|
|---|
| 92 | ULONG iPageTable, /* ebp + 0x10 */
|
|---|
| 93 | PVOID pvPage, /* ebp + 0x14 */
|
|---|
| 94 | ULONG ulPageAddress, /* ebp + 0x18 */
|
|---|
| 95 | PVOID pvPTDA /* ebp + 0x1c */
|
|---|
| 96 | );
|
|---|
| 97 |
|
|---|
| 98 | ULONG LDRCALL myldrEnum32bitRelRecs(PMTE, ULONG, ULONG, PVOID, ULONG, PVOID);
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 | /**
|
|---|
| 103 | * Loader local variables from KERNEL.SDF.
|
|---|
| 104 | */
|
|---|
| 105 | typedef struct ldrlv_s /* #memb 12 size 39 (0x027) */
|
|---|
| 106 | {
|
|---|
| 107 | PMTE lv_pmte; /* Pointer to mte. (ldrCreateMte/ldrXXX) */
|
|---|
| 108 | ULONG lv_lbufaddr;
|
|---|
| 109 | ULONG lv_sbufaddr;
|
|---|
| 110 | ULONG lv_lrecbufaddr;
|
|---|
| 111 | ULONG lv_srecbufaddr;
|
|---|
| 112 | ULONG lv_new_exe_off;
|
|---|
| 113 | USHORT lv_sfn; /* Handle to the module being loaded */
|
|---|
| 114 | USHORT lv_hobmte;
|
|---|
| 115 | ULONG lv_objnum;
|
|---|
| 116 | ULONG lv_csmte; /* size of the swappable mte heap block. (ldrCreateMte) */
|
|---|
| 117 | USHORT lv_class; /* Object class CLASS_* defines in OS2Krnl (mteflags1) it seems. */
|
|---|
| 118 | /* CLASS_PROGRAM Program class. */
|
|---|
| 119 | /* CLASS_GLOBAL Global class. */
|
|---|
| 120 | /* CLASS_SPECIFIC Specific class, as against global. */
|
|---|
| 121 | /* CLASS_ALL (0) Nonspecific class all modules. */
|
|---|
| 122 | /* CLASS_MASK Class mask. */
|
|---|
| 123 | UCHAR lv_type; /* Type of executable image expected loaded. */
|
|---|
| 124 | } ldrlv_t;
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 | /*
|
|---|
| 128 | * Values of the lv_type byte. (Qualified guesses.)
|
|---|
| 129 | */
|
|---|
| 130 | #define LVTYPE_EXE 0 /* Executable program. */
|
|---|
| 131 | #define LVTYPE_DLL 1 /* Dynamic Link Library. */
|
|---|
| 132 | #define LVTYPE_DD 2 /* Device Driver. */
|
|---|
| 133 | #define LVTYPE_IFS 3 /* Installable Filesystem. */
|
|---|
| 134 | #define LVTYPE_VDD 4 /* Virtual Device Driver (for VDMs). */
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 | /**
|
|---|
| 139 | * ldrOpenPath
|
|---|
| 140 | * @returns OS2 return code.
|
|---|
| 141 | * pLdrLv->lv_sfn is set to filename handle.
|
|---|
| 142 | * @param pachModname Pointer to modulename. Not zero terminated!
|
|---|
| 143 | * @param cchModname Modulename length.
|
|---|
| 144 | * @param pLdrLv Loader local variables? (Struct from KERNEL.SDF)
|
|---|
| 145 | * @param pfl Pointer to flags which are passed on to ldrOpen.
|
|---|
| 146 | * @sketch
|
|---|
| 147 | * if !CLASS_GLOBAL or miniifs then
|
|---|
| 148 | * ldrOpen(pachModName)
|
|---|
| 149 | * else
|
|---|
| 150 | * loop until no more libpath elements
|
|---|
| 151 | * get next libpath element and add it to the modname.
|
|---|
| 152 | * try open the modname
|
|---|
| 153 | * if successfull then break the loop.
|
|---|
| 154 | * endloop
|
|---|
| 155 | * endif
|
|---|
| 156 | */
|
|---|
| 157 | extern ULONG LDRCALL ldrOpenPath( /* retd 0x10 */
|
|---|
| 158 | PCHAR pachFilename, /* ebp + 0x08 */
|
|---|
| 159 | USHORT cchFilename, /* ebp + 0x0c */
|
|---|
| 160 | ldrlv_t * plv, /* ebp + 0x10 */
|
|---|
| 161 | PULONG pful /* ebp + 0x14 */
|
|---|
| 162 | );
|
|---|
| 163 |
|
|---|
| 164 | ULONG LDRCALL myldrOpenPath(PCHAR pachFilename, USHORT cchFilename, ldrlv_t *plv, PULONG pful);
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 | /**
|
|---|
| 168 | * Finds a module if it's loaded.
|
|---|
| 169 | * @returns NO_ERROR on success.
|
|---|
| 170 | * OS/2 errorcode on error.
|
|---|
| 171 | * @param pachFilename Pointer to module filename.
|
|---|
| 172 | * @param cchFilename Length of modulefilename.
|
|---|
| 173 | * @param usClass Module class. (CLASS_*)
|
|---|
| 174 | * @param ppMTE Pointer to pMTE found.
|
|---|
| 175 | * @sketch
|
|---|
| 176 | */
|
|---|
| 177 | ULONG LDRCALL ldrFindModule(PCHAR pachFilename, USHORT cchFilename, USHORT usClass, PPMTE ppMTE);
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 | /**
|
|---|
| 181 | * LDRClearSem - Clears the loader semaphore.
|
|---|
| 182 | * (It does some garbage collection on release.)
|
|---|
| 183 | * @returns NO_ERROR on success.
|
|---|
| 184 | * OS/2 error on failure. (ERROR_INTERRUPT?)
|
|---|
| 185 | */
|
|---|
| 186 | extern ULONG LDRCALL LDRClearSem(void);
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 | /**
|
|---|
| 190 | * LDRRequestSem - Requests the loader semaphore..
|
|---|
| 191 | * @returns NO_ERROR if succesfully.
|
|---|
| 192 | * OS2 errorcode on failure. (ERROR_INTERRUPT?)
|
|---|
| 193 | */
|
|---|
| 194 | #define LDRRequestSem() KSEMRequestMutex(pLdrSem, (ULONG)-1)
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 | /*
|
|---|
| 198 | * Pointer to the loader semaphore.
|
|---|
| 199 | */
|
|---|
| 200 | #ifdef _OS2KSEM_h_
|
|---|
| 201 | extern PKSEMMTX pLdrSem;
|
|---|
| 202 | #endif
|
|---|
| 203 |
|
|---|
| 204 |
|
|---|
| 205 | /**
|
|---|
| 206 | * Validates an hMTE and gets the MTE pointer.
|
|---|
| 207 | * @returns Pointer to MTE on success.
|
|---|
| 208 | * NULL on error.
|
|---|
| 209 | * @param hMTE MTE handle.
|
|---|
| 210 | * @remark If you wan't to this faster:
|
|---|
| 211 | * Use the hMTE as a HOB and get the HOB address (by using VMGetHandleInfo).
|
|---|
| 212 | */
|
|---|
| 213 | extern PMTE LDRCALL ldrValidateMteHandle(HMTE hMTE);
|
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 | /**
|
|---|
| 217 | * Gets the pMTE from a hMTE. No checks.
|
|---|
| 218 | * @returns Pointer to the pMTE for a given hMTE.
|
|---|
| 219 | * @param hMTE Module handle.
|
|---|
| 220 | * @sketch
|
|---|
| 221 | */
|
|---|
| 222 | extern PMTE KRNLCALL ldrASMpMTEFromHandle(HMTE hMTE);
|
|---|
| 223 |
|
|---|
| 224 |
|
|---|
| 225 | /**
|
|---|
| 226 | * Pointer to the loader filename buffer.
|
|---|
| 227 | * Upon return from ldrOpen (and ldrOpenPath which calls ldrOpen) this is
|
|---|
| 228 | * set to the fully qualified filename of the file last opened (successfully).
|
|---|
| 229 | */
|
|---|
| 230 | extern PSZ *pldrpFileNameBuf;
|
|---|
| 231 | #define ldrpFileNameBuf (*pldrpFileNameBuf)
|
|---|
| 232 |
|
|---|
| 233 |
|
|---|
| 234 | #ifdef __cplusplus
|
|---|
| 235 | } /* extern "C" */
|
|---|
| 236 | #endif
|
|---|
| 237 |
|
|---|
| 238 | #endif
|
|---|
| 239 |
|
|---|