| 1 | /* $Id: ModuleBase.h,v 1.1 1999-11-10 01:45:31 bird Exp $
|
|---|
| 2 | *
|
|---|
| 3 | * ModuleBase - Declaration of the Basic module class.
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright (c) 1999 knut st. osmundsen
|
|---|
| 6 | *
|
|---|
| 7 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 8 | *
|
|---|
| 9 | */
|
|---|
| 10 | #ifndef _MODULEBASE_H_
|
|---|
| 11 | #define _MODULEBASE_H_
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 | /*******************************************************************************
|
|---|
| 15 | * Defined Constants And Macros *
|
|---|
| 16 | *******************************************************************************/
|
|---|
| 17 | /*
|
|---|
| 18 | * Error definitions (used in addition to them in bseerr.h)
|
|---|
| 19 | */
|
|---|
| 20 | #define ERROR_FAILED_TO_ADD_OBJECT 0x42000000UL
|
|---|
| 21 | #define ERROR_INITMETHOD_NOT_INITTIME 0x42000001UL
|
|---|
| 22 | #define ERROR_INTERNAL_PROCESSING_ERROR 0x42000002UL
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 | /*
|
|---|
| 26 | * Output macros.
|
|---|
| 27 | * Macros: option infolevel
|
|---|
| 28 | * printIPE -W1 Error
|
|---|
| 29 | * printErr -W1 Error
|
|---|
| 30 | * printWar -W2 Warning
|
|---|
| 31 | * printInf -W3 Info
|
|---|
| 32 | * printInfA -W4 InfoAll
|
|---|
| 33 | */
|
|---|
| 34 | #define printIPE(a) (ModuleBase::ulInfoLevel >= ModuleBase::Error ? \
|
|---|
| 35 | ModuleBase::printf("\nerror(%d:"__FUNCTION__"): !Internal Processing Error!\n\t", __LINE__), \
|
|---|
| 36 | ModuleBase::printf a, \
|
|---|
| 37 | ModuleBase::printf("\n") \
|
|---|
| 38 | : (void)0,(void)0,(void)0 )
|
|---|
| 39 | #define printErr(a) (ModuleBase::ulInfoLevel >= ModuleBase::Error ? \
|
|---|
| 40 | ModuleBase::printf("error(%d:"__FUNCTION__"): ", __LINE__), \
|
|---|
| 41 | ModuleBase::printf a \
|
|---|
| 42 | : (void)0,(void)0 )
|
|---|
| 43 | #define printWar(a) (ModuleBase::ulInfoLevel >= ModuleBase::Warning ? \
|
|---|
| 44 | ModuleBase::printf("warning("__FUNCTION__"): "), \
|
|---|
| 45 | ModuleBase::printf a \
|
|---|
| 46 | : (void)0,(void)0 )
|
|---|
| 47 | #define printInf(a) (ModuleBase::ulInfoLevel >= ModuleBase::Info ? \
|
|---|
| 48 | ModuleBase::printf a : (void)0 )
|
|---|
| 49 | #define printInfA(a)(ModuleBase::ulInfoLevel >= ModuleBase::InfoAll ? \
|
|---|
| 50 | ModuleBase::printf a : (void)0 )
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 | /*
|
|---|
| 54 | * Misc
|
|---|
| 55 | */
|
|---|
| 56 | #define PAGESIZE 0x1000
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 | /**
|
|---|
| 62 | * Base class for executable modules.
|
|---|
| 63 | * @author knut st. osmundsen
|
|---|
| 64 | * @approval not approved yet...
|
|---|
| 65 | */
|
|---|
| 66 | class ModuleBase
|
|---|
| 67 | {
|
|---|
| 68 | public:
|
|---|
| 69 | /** @cat Constructor/Destructor */
|
|---|
| 70 | ModuleBase(SFN hFile);
|
|---|
| 71 | virtual ~ModuleBase();
|
|---|
| 72 |
|
|---|
| 73 | /** @cat Public Main methods */
|
|---|
| 74 | virtual ULONG init(PCSZ pszFilename);
|
|---|
| 75 | virtual ULONG read(ULONG offLXFile, PVOID pvBuffer, ULONG cbToRead, ULONG flFlags, PMTE pMTE) = 0;
|
|---|
| 76 | #ifndef RING0
|
|---|
| 77 | virtual ULONG writeFile(PCSZ pszLXFilename);
|
|---|
| 78 | #endif
|
|---|
| 79 |
|
|---|
| 80 | /** @cat public Helper methods */
|
|---|
| 81 | virtual VOID dumpVirtualLxFile() = 0;
|
|---|
| 82 | BOOL queryIsModuleName(PCSZ pszFilename);
|
|---|
| 83 |
|
|---|
| 84 | /** @cat static print method */
|
|---|
| 85 | static VOID printf(PCSZ pszFormat, ...);
|
|---|
| 86 |
|
|---|
| 87 | protected:
|
|---|
| 88 | /** @cat private data members. */
|
|---|
| 89 | #ifdef DEBUG
|
|---|
| 90 | BOOL fInitTime; /* init time indicator (debug) */
|
|---|
| 91 | #endif
|
|---|
| 92 | SFN hFile; /* filehandle */
|
|---|
| 93 | PSZ pszFilename; /* fullpath */
|
|---|
| 94 | PSZ pszModuleName; /* filename without extention. */
|
|---|
| 95 |
|
|---|
| 96 | /** @cat public static data. */
|
|---|
| 97 | public:
|
|---|
| 98 | static ULONG ulInfoLevel; /* Current output message detail level. */
|
|---|
| 99 | enum {Quiet, Error, Warning, Info, InfoAll}; /* Output message detail levels. */
|
|---|
| 100 | };
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 | #endif
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|