home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 December / PCO_1298.ISO / filesbbs / os2 / fn128os2.arj / FN128OS2.ZIP / fn128os2 / src / os2lx.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-02  |  6.9 KB  |  162 lines

  1. /*
  2.  # $Id: os2lx.h,v 1.2 1998/04/10 10:25:03 fbm Exp fbm $
  3.  # Copyright (C) 1997,1998 Farrell McKay
  4.  # All rights reserved.
  5.  #
  6.  # This file is part of the Fortify distribution, a toolkit for
  7.  # upgrading the cryptographic strength of the Netscape Navigator
  8.  # web browser, authored by Farrell McKay.
  9.  #
  10.  # This toolkit is provided to the recipient under the
  11.  # following terms and conditions:-
  12.  #   1.  This copyright notice must not be removed or modified.
  13.  #   2.  This toolkit may not be reproduced or included in any commercial
  14.  #       media distribution, or commercial publication (for example CD-ROM,
  15.  #       disk, book, magazine, journal) without first obtaining the author's
  16.  #       express permission.
  17.  #   3.  This toolkit, or any component of this toolkit, may not be
  18.  #       commercially resold, redeveloped, rewritten, enhanced or otherwise
  19.  #       used as the basis for commercial venture, without first obtaining
  20.  #       the author's express permission.
  21.  #   4.  Subject to the above conditions being observed (1-3), this toolkit
  22.  #       may be freely reproduced or redistributed.
  23.  #   5.  This software is provided "as-is", without express or implied
  24.  #       warranty.  In no event shall the author be liable for any direct,
  25.  #       indirect or consequential damages however caused.
  26.  #   6.  Subject to the above conditions being observed (1-5),
  27.  #       this toolkit may be used at no cost to the recipient.
  28.  #
  29.  # Farrell McKay
  30.  # Wayfarer Systems Pty Ltd        contact@fortify.net
  31.  */
  32.  
  33. #ifndef OS2LX_H
  34. #define OS2LX_H
  35.  
  36. /* OS/2 NE and LX Header structures and structures of */
  37. /* all fixed size table entry types. */
  38.  
  39. /* Dummy DOS struct that points to the file offset of the NE/LX exe header. */
  40. /* This ignores MZ header items other than ID word and lfanew. */
  41. /* This struct is at file offset 0. */
  42.  
  43. typedef struct {
  44.     unsigned short        magic;        /* MUST BE ASCII "MZ" */
  45.     char            padding[58];
  46.     unsigned long        lfanew;        /* File offset of new exe header. */
  47. } SIMPLE_MZ_EXE;
  48.  
  49.  
  50. /* Structure that defines the LX exe header. */
  51. typedef struct {
  52.     unsigned short        Magic;        /* "LX" */
  53.     unsigned char        ByteOrder;    /* LITTLE_ENDIAN or BIG_ENDIAN */
  54.     unsigned char        WordOrder;    /* LITTLE_ENDIAN or BIG_ENDIAN */
  55.     unsigned long        FormatLevel;    /* Loader format level, currently 0 */
  56.     unsigned short        CpuType;    /* 286 through Pentium+ */
  57.     unsigned short        OSType;        /* DOS, Win, OS/2 ... */
  58.     unsigned long        ModVersion;    /* Version of this exe */
  59.     unsigned long        ModFlags;    /* Program/Library ... */
  60.     unsigned long        ModNumPgs;    /* Number of non-zero-fill or invalid pages */
  61.     unsigned long        EIPObjNum;    /* Initial code object */
  62.     unsigned long        EIP;        /* Start address within EIPObjNum */
  63.     unsigned long        ESPObjNum;    /* Initial stack object */
  64.     unsigned long        Esp;        /* Top of stack within ESPObjNum */
  65.     unsigned long        PgSize;        /* Page size, fixed at 4k  */
  66.     unsigned long        PgOfsShift;    /* Page alignment shift */
  67.     unsigned long        FixupSectionSize;    /* Size of fixup information in file */
  68.     unsigned long        FixupCksum;    /* Checksum of FixupSection */
  69.     unsigned long        LoaderSecSize;    /* Size of Loader Section */
  70.      unsigned long        LoaderSecCksum;    /* Loader Section checksum */
  71.     unsigned long        ObjTblOfs;    /* File offset of Object Table */
  72.     unsigned long        NumObjects;    /* Number of Objects */
  73.     unsigned long        ObjPgTblOfs;    /* File offset of Object Page Table */
  74.     unsigned long        ObjIterPgsOfs;    /* File offset of Iterated Data Pages */
  75.     unsigned long        RscTblOfs;    /* File offset of Resource Table */
  76.     unsigned long        NumRscTblEnt;    /* # of entries in Resource Table */
  77.         unsigned long        ResNameTblOfs;    /* File offset of Resident Name Table */
  78.         unsigned long        EntryTblOfs;    /* File offset of Entry Table */
  79.     unsigned long        ModDirOfs;    /* File offset of Module Directives */
  80.     unsigned long        NumModDirs;    /* Number of Module Directives */
  81.     unsigned long        FixupPgTblOfs;    /* File offset of Fixup Page Table */
  82.     unsigned long        FixupRecTblOfs;    /* File offset of Fixup Record Table */
  83.     unsigned long        ImpModTblOfs;    /* File offset of Imp Module Table */
  84.     unsigned long        NumImpModEnt;    /* Number of Imported Modules */
  85.     unsigned long        ImpProcTblOfs;    /* File offset of Imported Proc Table */
  86.     unsigned long        PerPgCksumOfs;    /* File offset of Per-Page Checksum Table */
  87.     unsigned long        DataPgOfs;    /* File offset of Data Pages */
  88.     unsigned long        NumPreloadPg;    /* Number of Preload Pages */
  89.     unsigned long        NResNameTblOfs;    /* File offset of Non Resident  */
  90.                         /* Name Table from beginning of file! */
  91.     unsigned long        NResNameTblLen;    /* Length in bytes of Non Resident  */
  92.                         /* Name Table; table is also NULL terminated. */
  93.     unsigned long        NResNameTblCksum;    /* Non Resident Name Table checksum */
  94.     unsigned long        AutoDSObj;    /* Object number of auto data */
  95.     unsigned long        DebugInfoOfs;    /* File offset of debugging info */
  96.     unsigned long        DebugInfoLen;    /* Length of Debugging Info */
  97.     unsigned long        NumInstPreload;    /* Number of instance-preload pages */
  98.     unsigned long        NumInstDemand;    /* Number of instance-demand pages */
  99.     unsigned long        HeapSize;    /* Heap size */
  100.     /* unsigned long    StackSize;    /* Stack size */
  101. } LX_EXE;
  102.  
  103.  
  104. /* An entry in the LX object table */
  105. typedef struct {
  106.     unsigned long        size;        /* Load-time size of object */
  107.     unsigned long        reloc_base_addr;/* Address the object wants  */
  108.                         /* to be loaded at. */
  109.     unsigned long        obj_flags;    /* Read/Write/Execute, Resource, Zero-fill ... */
  110.     unsigned long        pg_tbl_index;    /* Index in Object Page Table at  */
  111.                         /* which this objects first page  */
  112.                         /* is located. */
  113.     unsigned long        num_pg_tbl_entries;    /* Number of consecutive Object  */
  114.                         /* Page Table entries that belong to  */
  115.                         /* this object. */
  116.     unsigned long        reserved;
  117. } LX_OBJ;
  118.  
  119.  
  120. /* An entry in the LX Object Page Table. */
  121. typedef struct {
  122.     unsigned long        offset;        /* File offset of this pages data. */
  123.                         /* Relative to beginning of Iterated */
  124.                         /* or Preload Pages  */
  125.     unsigned short        size;        /* Size of this page.  <= 4096 */
  126.     unsigned short        flags;        /* Iterated, Zero-filled, Invalid ... */
  127. } LX_PG;
  128.  
  129.  
  130. /* An entry in the LX Resource Table */
  131. typedef struct {
  132.     unsigned short        type_id;    /* one of rsc_types */
  133.     unsigned short        name_id;    /* ID application uses to load this resource */
  134.     unsigned long        size;        /* size of the resource */
  135.     unsigned short        object;        /* which object is this resource located in? */
  136.     /*unsigned long        offset;        // resource offset within the object  */
  137.     unsigned char        offlow;        /* least-sig byte of offset. */
  138. } LX_RSC;
  139.  
  140.  
  141. /* A structure to pull everything together into one piece. */
  142. typedef struct {
  143.     SIMPLE_MZ_EXE        mz;
  144.     LX_EXE            lx;
  145.     struct lxObject        **lxObjects;
  146.     int            nlxObjects;
  147.     struct lxPage              **pages;
  148.     int                  npages;
  149. } lxfile_t;
  150.  
  151.  
  152. #if 0
  153. int        lxFile_compressed(lxfile_t *lx, char *md5_span);
  154. #endif
  155. char        *lxFile_md5_calc(lxfile_t *lx, int fd, char *md5_span, int *err);
  156. lxfile_t    *lxFile_is_lx(int fd);
  157. void        lxFile_free(lxfile_t *lx);
  158. unsigned long    lxFile_get_offset(lxfile_t *lx, unsigned long addr);
  159. void        lxFile_print_hdr(lxfile_t *lx);
  160.  
  161. #endif
  162.