Ignore:
Timestamp:
Feb 27, 2000, 3:18:10 AM (26 years ago)
Author:
bird
Message:

Moved parts from pe2lx.cpp/h to ModuleBase.cpp/h.
Corrected writeLxFile to writeFile.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/pe2lx/pe2lx.cpp

    r2590 r2927  
    1 /* $Id: pe2lx.cpp,v 1.17 2000-02-01 11:10:54 bird Exp $
     1/* $Id: pe2lx.cpp,v 1.18 2000-02-27 02:18:10 bird Exp $
    22 *
    33 * Pe2Lx class implementation. Ring 0 and Ring 3
     
    1515*   Defined Constants And Macros                                               *
    1616*******************************************************************************/
    17 #define FOR_EXEHDR 1                        /* To make all object flags OBJ???. */
    18 #define INCL_DOSERRORS                      /* DOS Error codes. */
     17#define FOR_EXEHDR 1                    /* To make all object flags OBJ???. */
     18#define INCL_DOSERRORS                  /* DOS Error codes. */
    1919#ifdef RING0
    20     #define INCL_NOAPI                      /* RING0: No apis. */
     20    #define INCL_NOAPI                  /* RING0: No apis. */
    2121#else /*RING3*/
    22     #define INCL_DOSFILEMGR                 /* RING3: DOS File api. */
    23     #define INCL_DOSPROCESS                 /* RING3: DosSleep. */
     22    #define INCL_DOSPROCESS             /* RING3: DosSleep. */
    2423#endif
    2524
     
    3534
    3635#define MIN_STACK_SIZE              0x20000 /* 128KB stack */
    37 #define CB2PAGES_SHIFT              12      /* count of bytes to count of pages. shift right value. Note. ALIGN!*/
    3836
    3937
     
    7371
    7472
    75 /*
    76  * Read macros.
    77  *  ReadAt:  Reads from a file, hFile, at a given offset, ulOffset, into a buffer, pvBuffer,
    78  *           an amount of bytes, cbToRead.
    79  *           RING0: Map this to ldrRead with 0UL as flFlags.
    80  *           RING3: Implementes this function as a static function, ReadAt.
    81  *  ReadAtF: Same as ReadAt but two extra parameters; an additional flag and a pointer to an MTE.
    82  *           Used in the read method.
    83  *           RING0: Map directly to ldrRead.
    84  *           RING3: Map to ReadAt, ignoring the two extra parameters.
    85  */
    86 #ifdef RING0
    87     #define ReadAt(hFile, ulOffset, pvBuffer, cbToRead) \
    88         ldrRead(hFile, ulOffset, pvBuffer, 0UL, cbToRead, NULL)
    89     #define ReadAtF(hFile, ulOffset, pvBuffer, cbToRead, flFlags, pMTE) \
    90         ldrRead(hFile, ulOffset, pvBuffer, flFlags, cbToRead, pMTE)
    91 #else
    92     #define ReadAtF(hFile, ulOffset, pvBuffer, cbToRead, flFlags, pMTE) \
    93         ReadAt(hFile, ulOffset, pvBuffer, cbToRead)
    94 #endif
    95 
    9673
    9774/*******************************************************************************
    9875*   Header Files                                                               *
    9976*******************************************************************************/
    100 #include <os2.h>                            /* OS/2 header file. */
    101 #include <peexe.h>                          /* Wine PE structs and definitions. */
    102 #include <neexe.h>                          /* Wine NE structs and definitions. */
    103 #include <newexe.h>                         /* OS/2 NE structs and definitions. */
    104 #include <exe386.h>                         /* OS/2 LX structs and definitions. */
    105 
    106 #include "malloc.h"                         /* win32k malloc (resident). Not C library! */
    107 #include "smalloc.h"                        /* win32k swappable heap. */
    108 #include "rmalloc.h"                        /* win32k resident heap. */
    109 
    110 #include <string.h>                         /* C library string.h. */
    111 #include <stdlib.h>                         /* C library stdlib.h. */
    112 #include <stddef.h>                         /* C library stddef.h. */
    113 #include <stdarg.h>                         /* C library stdarg.h. */
    114 
    115 #include "vprintf.h"                        /* win32k printf and vprintf. Not C library! */
    116 #include "dev32.h"                          /* 32-Bit part of the device driver. (SSToDS) */
    117 #include "OS2Krnl.h"                        /* kernel structs.  (SFN) */
     77#include <os2.h>                        /* OS/2 header file. */
     78#include <peexe.h>                      /* Wine PE structs and definitions. */
     79#include <neexe.h>                      /* Wine NE structs and definitions. */
     80#include <newexe.h>                     /* OS/2 NE structs and definitions. */
     81#include <exe386.h>                     /* OS/2 LX structs and definitions. */
     82
     83#include "malloc.h"                     /* win32k malloc (resident). Not C library! */
     84#include "smalloc.h"                    /* win32k swappable heap. */
     85#include "rmalloc.h"                    /* win32k resident heap. */
     86
     87#include <string.h>                     /* C library string.h. */
     88#include <stdlib.h>                     /* C library stdlib.h. */
     89#include <stddef.h>                     /* C library stddef.h. */
     90#include <stdarg.h>                     /* C library stdarg.h. */
     91
     92#include "vprintf.h"                    /* win32k printf and vprintf. Not C library! */
     93#include "dev32.h"                      /* 32-Bit part of the device driver. (SSToDS) */
     94#include "OS2Krnl.h"                    /* kernel structs.  (SFN) */
    11895#ifdef RING0
    119     #include "ldrCalls.h"                   /* ldr* calls. (ldrRead) */
     96    #include "ldrCalls.h"               /* ldr* calls. (ldrRead) */
    12097#endif
    121 #include "modulebase.h"                     /* ModuleBase class definitions, ++. */
    122 #include "pe2lx.h"                          /* Pe2Lx class definitions, ++. */
    123 #include <versionos2.h>                     /* Pe2Lx version. */
    124 #include "yield.h"                          /* Yield CPU. */
     98#include "modulebase.h"                 /* ModuleBase class definitions, ++. */
     99#include "pe2lx.h"                      /* Pe2Lx class definitions, ++. */
     100#include <versionos2.h>                 /* Pe2Lx version. */
     101#include "yield.h"                      /* Yield CPU. */
    125102
    126103
     
    193170};
    194171
    195 
    196 /*******************************************************************************
    197 *   Internal Functions                                                         *
    198 *******************************************************************************/
    199 #ifndef RING0
    200 static ULONG ReadAt(SFN hFile, ULONG ulOffset, PVOID pvBuffer, ULONG cbToRead);
    201 
    202 
    203 /**
    204  *
    205  * @returns   OS/2 return code. (NO_ERROR on success...)
    206  * @param     hFile     Handle to file. (RING0: Handle to SystemFileNumber (SFN).)
    207  * @param     ulOffset  Offset in the file to start reading at.
    208  * @param     pvBuffer  Pointer to output buffer.
    209  * @param     cbToRead  Count of bytes to read.
    210  * @sketch    Set Change filepointer to ulOffset.
    211  *            Read cbToRead into pvBufer.
    212  * @status    completely tested.
    213  * @author    knut st. osmundsen
    214  * @remark
    215  */
    216 static ULONG ReadAt(SFN hFile, ULONG ulOffset, PVOID pvBuffer, ULONG cbToRead)
    217 {
    218     ULONG cbRead, ulMoved;
    219     APIRET rc;
    220 
    221     rc = DosSetFilePtr(hFile, ulOffset, FILE_BEGIN, &ulMoved);
    222     if (rc == NO_ERROR)
    223         rc = DosRead(hFile, pvBuffer, cbToRead, &cbRead);
    224     else
    225         printErr(("DosSetFilePtr(hfile, %#8x(%d),..) failed with rc = %d.",
    226                   ulOffset, ulOffset, rc));
    227 
    228     return rc;
    229 }
    230 #endif
    231172
    232173
     
    14081349 * @author    knut st. osmundsen
    14091350 */
    1410 ULONG Pe2Lx::writeLxFile(PCSZ pszLXFilename)
     1351ULONG Pe2Lx::writeFile(PCSZ pszLXFilename)
    14111352{
    14121353    static CHAR achReadBuffer[65000];
     
    19221863            paObjTab[0].o32_flags    = OBJREAD | OBJWRITE | OBJBIGDEF;
    19231864            paObjTab[0].o32_pagemap  = 1;  /* 1 based */
    1924             paObjTab[0].o32_mapsize  = ALIGN(paObjTab[0].o32_size, PAGESIZE) >> CB2PAGES_SHIFT;
     1865            paObjTab[0].o32_mapsize  = ALIGN(paObjTab[0].o32_size, PAGESIZE) >> PAGESHIFT;
    19251866            paObjTab[0].o32_reserved = 0;
    19261867        }
     
    19351876                paObjTab[i].o32_flags    = paObjects[i].flFlags;
    19361877                paObjTab[i].o32_pagemap  = ulPageMap;
    1937                 paObjTab[i].o32_mapsize  = ALIGN(paObjTab[i].o32_size, PAGESIZE) >> CB2PAGES_SHIFT;
     1878                paObjTab[i].o32_mapsize  = ALIGN(paObjTab[i].o32_size, PAGESIZE) >> PAGESHIFT;
    19381879                paObjTab[i].o32_reserved = 0;
    19391880                ulPageMap += paObjTab[i].o32_mapsize;
     
    42344175    {
    42354176        if (fAllInOneObject && iObj + 1 < cObjects)
    4236             cPages += ALIGN(paObjects[iObj+1].ulRVA - paObjects[iObj].ulRVA, PAGESIZE) >> CB2PAGES_SHIFT;
     4177            cPages += ALIGN(paObjects[iObj+1].ulRVA - paObjects[iObj].ulRVA, PAGESIZE) >> PAGESHIFT;
    42374178        else
    4238             cPages += ALIGN(paObjects[iObj].cbVirtual, PAGESIZE) >> CB2PAGES_SHIFT;
     4179            cPages += ALIGN(paObjects[iObj].cbVirtual, PAGESIZE) >> PAGESHIFT;
    42394180    }
    42404181
Note: See TracChangeset for help on using the changeset viewer.