| 1 | /* $Id: ldr.h,v 1.3 1999-10-27 02:02:56 bird Exp $ | 
|---|
| 2 | * | 
|---|
| 3 | * ldr - loader header file. | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright (c)  1999 knut  St.  osmundsen | 
|---|
| 6 | * | 
|---|
| 7 | */ | 
|---|
| 8 |  | 
|---|
| 9 |  | 
|---|
| 10 | #ifndef _ldr_h_ | 
|---|
| 11 | #define _ldr_h_ | 
|---|
| 12 | #ifndef LDR_INCL_INITONLY | 
|---|
| 13 | /* state variable */ | 
|---|
| 14 | extern BOOL fQAppType; | 
|---|
| 15 |  | 
|---|
| 16 | /* | 
|---|
| 17 | * handle state - Array of handle states. Eight state per byte! | 
|---|
| 18 | */ | 
|---|
| 19 | #define MAX_FILE_HANDLES 0x10000 | 
|---|
| 20 |  | 
|---|
| 21 | extern unsigned char achHandleStates[MAX_FILE_HANDLES/8]; | 
|---|
| 22 |  | 
|---|
| 23 | #define HSTATE_UNUSED       0x00    /* Handle not used (or OS/2). */ | 
|---|
| 24 | #define HSTATE_OS2          0x00    /* OS/2 module filehandle. */ | 
|---|
| 25 | #define HSTATE_OUR          0x01    /* Our module filehandle. */ | 
|---|
| 26 | #define HSTATE_MASK         0xFE | 
|---|
| 27 | #define HSTATE_UMASK        0x01 | 
|---|
| 28 |  | 
|---|
| 29 | #define GetState(a)         (HSTATE_UMASK & (achHandleStates[(a)/8] >> ((a)%8))) | 
|---|
| 30 | #define SetState(a,b)       (achHandleStates[(a)/8] = (achHandleStates[(a)/8] & (HSTATE_MASK << ((a)%8) | HSTATE_MASK >> 8-((a)%8)) | ((b) & 0x1) << ((a)%8))) | 
|---|
| 31 |  | 
|---|
| 32 |  | 
|---|
| 33 | /* | 
|---|
| 34 | * Module struct. | 
|---|
| 35 | */ | 
|---|
| 36 | typedef struct _Module | 
|---|
| 37 | { | 
|---|
| 38 | AVLNODECORE     coreKey;    /* Key is hFile. */ | 
|---|
| 39 | AVLNODECORE     coreMTE;    /* Key is pMTE. */ | 
|---|
| 40 |  | 
|---|
| 41 | SFN             hFile;      /* System file number or file handle if you prefer that. */ | 
|---|
| 42 | PMTE            pMTE;       /* Pointer to MTE if we got one - NULL is allowed. */ | 
|---|
| 43 |  | 
|---|
| 44 | ULONG           fFlags;     /* Flags. Flags if coreMte is in use and what Data contains. */ | 
|---|
| 45 | union | 
|---|
| 46 | { | 
|---|
| 47 | Pe2Lx *     pPe2Lx;     /* Pointer to a Pe2Lx object. (Win32 executables) */ | 
|---|
| 48 | #if 0 | 
|---|
| 49 | Elf2Lx *    pElf2Lx;    /* Pointer to a Elf2Lx object. (ELF executables) */ | 
|---|
| 50 | Script *    pScript;    /* Pointer to a Script object. (Shell scripts) */ | 
|---|
| 51 | Pe *        pPe;        /* Pointer to a Pe object. (Ring3 loader) */ | 
|---|
| 52 | #endif | 
|---|
| 53 | void *      pv; | 
|---|
| 54 | } Data;                     /* Pointer to data. Currently it's allways a Pe2Lx object! */ | 
|---|
| 55 | } MODULE, *PMODULE; | 
|---|
| 56 |  | 
|---|
| 57 | #define MOD_FLAGS_IN_MTETREE    0x00000010 /* The node is present in the MTE-tree. */ | 
|---|
| 58 | #define MOD_TYPE_MASK           0x0000000F /* Type mask. */ | 
|---|
| 59 | #define MOD_TYPE_PE2LX          0x00000001 /* Pe2Lx module. */ | 
|---|
| 60 | #define MOD_TYPE_ELF2LX         0x00000002 /* Elf2Lx module. */ | 
|---|
| 61 | #define MOD_TYPE_SCRIPT         0x00000003 /* Script module. */ | 
|---|
| 62 | #define MOD_TYPE_PE             0x00000004 /* Pe module. */ | 
|---|
| 63 |  | 
|---|
| 64 |  | 
|---|
| 65 | /* | 
|---|
| 66 | * Modules operations. | 
|---|
| 67 | */ | 
|---|
| 68 | PMODULE     getModuleBySFN(SFN hFile); | 
|---|
| 69 | PMODULE     getModuleByMTE(PMTE pMTE); | 
|---|
| 70 | PMODULE     getModuleByFilename(PCSZ pszFilename); | 
|---|
| 71 |  | 
|---|
| 72 | ULONG       addModule(SFN hFile, PMTE pMTE, ULONG fFlags, void *pData); | 
|---|
| 73 | ULONG       removeModule(SFN hFile); | 
|---|
| 74 |  | 
|---|
| 75 | #endif | 
|---|
| 76 |  | 
|---|
| 77 | /*************/ | 
|---|
| 78 | /* functions */ | 
|---|
| 79 | /*************/ | 
|---|
| 80 | #ifdef __cplusplus | 
|---|
| 81 | extern "C" { | 
|---|
| 82 | #endif | 
|---|
| 83 |  | 
|---|
| 84 | ULONG ldrInit(void); | 
|---|
| 85 |  | 
|---|
| 86 | #ifdef __cplusplus | 
|---|
| 87 | } | 
|---|
| 88 | #endif | 
|---|
| 89 |  | 
|---|
| 90 | #pragma pack() | 
|---|
| 91 |  | 
|---|
| 92 | #endif | 
|---|