Ignore:
Timestamp:
Feb 2, 2001, 9:45:42 AM (25 years ago)
Author:
bird
Message:

Corrected kFileLX and kFilePE constructors.
Made kDump.exe work again.
Added import module dump to kFilePE.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/common/kFileLX.cpp

    r4750 r5053  
    1 /* $Id: kFileLX.cpp,v 1.3 2000-12-04 08:48:08 bird Exp $
     1/* $Id: kFileLX.cpp,v 1.4 2001-02-02 08:45:41 bird Exp $
    22 *
    33 *
     
    4646#include <assert.h>
    4747
     48#include "kFile.h"
    4849#include "kFileFormatBase.h"
    4950#include "kInterfaces.h"
     
    112113 * @param     pszFilename   LX executable image name.
    113114 */
    114 kFileLX::kFileLX(const char *pszFilename)
     115kFileLX::kFileLX(const char *pszFilename)  throw (int)
    115116: pvBase(NULL)
    116117{
     
    119120    /* create filemapping */
    120121    pvBase = kFileFormatBase::readfile(pszFilename);
     122    if (pvBase == NULL)
     123        throw(1);
     124
     125    pehdr = (struct exe_hdr*)pvBase;
     126    if (pehdr->e_magic == EMAGIC)
     127        offLXHdr = pehdr->e_lfanew;
     128    else
     129        offLXHdr = 0;
     130
     131    pe32 = (struct e32_exe*)((char*)pvBase + offLXHdr);
     132    if (*(PUSHORT)pe32 != E32MAGIC)
     133    {
     134        free(pvBase);
     135        pvBase = NULL;
     136        throw(2);
     137    }
     138
     139    paObject = pe32->e32_objtab && pe32->e32_objcnt
     140        ? (struct o32_obj*)((char*)pvBase + pe32->e32_objtab + offLXHdr) : NULL;
     141    paMap = pe32->e32_objmap
     142        ? (struct o32_map*)((char*)pvBase + pe32->e32_objmap + offLXHdr) : NULL;
     143}
     144
     145
     146/**
     147 * Create an LX file object from an LX executable image.
     148 * @param     pFile     Pointer to opened LX file.
     149 */
     150kFileLX::kFileLX(kFile *pFile) throw (int)
     151: pvBase(NULL)
     152{
     153    struct exe_hdr * pehdr;
     154
     155    /* create filemapping */
     156    pvBase = pFile->readFile();
    121157    if (pvBase == NULL)
    122158        throw(1);
Note: See TracChangeset for help on using the changeset viewer.