Ignore:
Timestamp:
Oct 14, 1999, 3:25:39 AM (26 years ago)
Author:
bird
Message:

Pe2Lx rewrite changes in win32k.
Pluss some makefile/depend changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/ldr/myldrRead.cpp

    r847 r1273  
    1 /* $Id: myldrRead.cpp,v 1.1 1999-09-06 02:20:01 bird Exp $
     1/* $Id: myldrRead.cpp,v 1.2 1999-10-14 01:25:39 bird Exp $
    22 *
    33 * myldrRead - _ldrRead.
     
    1818#include <os2.h>
    1919
    20 #include "pefile.h"
    21 #include "lx.h"
     20#include <memory.h>
     21#include <stdlib.h>
     22
    2223#include "log.h"
    2324#include "dev32.h"
     25#include <peexe.h>
     26#include <exe386.h>
     27#include "OS2Krnl.h"
     28#include "pe2lx.h"
     29#include "ldrCalls.h"
    2430#include "ldr.h"
    25 #include "ldrCalls.h"
    26 
    2731
    2832
     
    3741{
    3842    ULONG   rc;
    39     ULONG   ulRead;
    40     int     i;
    41     PPENODE pNode;
    4243
    43     /* check if this is an PE-file */
    44     if (GetState(hFile) == HSTATE_PE)
     44    /* Check if this is an overrided handle */
     45    if (GetState(hFile) == HSTATE_OUR)
    4546    {
     47        PPENODE pNode;
     48
    4649        pNode = getNodePtr(hFile);
    4750        if (pNode != NULL)
     
    5154                pNode->pMTE == pMTE;
    5255
    53             /*debug*/
     56            /* debug */
    5457            if (ulFlags != 0)
    5558                kprintf(("_ldrRead: Warning ulFlags = 0x%x (!= 0)\n", ulFlags));
    56             rc = pNode->lxfile.read(ulOffset, pBuffer, ulBytesToRead, (PULONG)SSToDS(&ulRead), ulFlags);
     59
     60            rc = pNode->pPe2Lx->read(ulOffset, pBuffer, ulBytesToRead, ulFlags);
    5761            return rc;
    5862        }
    5963        else
    60             kprintf(("_ldrRead:  DON'T PANIC! - I can't get Node ptr!\n"));
     64            kprintf(("_ldrRead:  DON'T PANIC! - but I can't get Node ptr! - This is really an IPE!\n"));
    6165    }
    62 
    6366
    6467    rc = _ldrRead( hFile, ulOffset, pBuffer, ulFlags, ulBytesToRead, pMTE );
     
    6669//  kprintf(("_ldrRead:  hF=%+04x off=%+08x pB=%+08x fl=%+08x cb=%+04x pMTE=%+08x rc=%d\n",hFile,ulOffset,pBuffer,ulFlags,ulBytesToRead,pMTE,rc));
    6770
    68     /* check if file is uncertain - try make it certain */
    69     if (GetState(hFile) == HSTATE_CHECK)
    70     {
    71         i = findUncertainEntry(hFile);
    72         if (!ahUncertain[i].fMZ && ulOffset == 0 && ulBytesToRead >= 0x40)
    73         {
    74             /* Stage 1: */
    75             if (((PUSHORT)pBuffer)[0] == IMAGE_DOS_SIGNATURE)
    76             {   /* MZ */
    77                 ahUncertain[i].offsetNEHdr = *(PULONG)((ULONG)pBuffer+0x3c); /*Need more verification???*/
    78                 ahUncertain[i].fMZ = 1;
    79                 //kprintf(("_ldrRead:  Yeah! Detected MZ file - offset of NEHdr=%#x.\n", ahUncertain[i].offsetNEHdr));
    80             }
    81             else
    82             {   /* CERTAIN: not a PE-file */
    83                 SetState(hFile, HSTATE_NOT_PE);
    84                 freeUncertainEntry(hFile);
    85             }
    86         }
    87         else
    88         {
    89             if (ahUncertain[i].fMZ && ulOffset == ahUncertain[i].offsetNEHdr && ulBytesToRead == sizeof(struct e32_exe))
    90             {
    91                 /* Stage 2: */
    92                 if (LXFile::isPEFile((PIMAGE_SIG_FILE_HEADER)pBuffer))
    93                 {
    94                     kprintf(("_ldrRead:  Yeah! Detected PE file.\n"));
    95                     if (!fQAppType)
    96                     {
    97                         pNode = allocateNode();
    98                         if (pNode != NULL)
    99                         {
    100                             /* setup node */
    101                             pNode->hFile = hFile;   //key - but yes it is duplicateded in lxfile
    102                             pNode->pMTE = pMTE;
    103                             insertNode(pNode);
    104                             SetState(hFile, HSTATE_PE);
    105                             pNode->lxfile.SetModuleName(ahUncertain[i].pszName);
    106 
    107                             /* initiate lxfile */
    108                             if (pNode->lxfile.init(hFile, (PIMAGE_SIG_FILE_HEADER)pBuffer, ahUncertain[i].offsetNEHdr))
    109                             {
    110                                 /* init ok - do read */
    111                                 ULONG read;
    112                                 /*debug*/
    113                                 if (ulFlags != 0)
    114                                     kprintf(("_ldrRead: Warning ulFlags = 0x%x (!= 0)\n", ulFlags));
    115                                 rc = pNode->lxfile.read(ulOffset, pBuffer, ulBytesToRead, (PULONG)SSToDS(&read), ulFlags);
    116                             }
    117                             else
    118                             {
    119                                 /* init failed - complain */
    120                                 kprintf(("_ldrRead:  opps! lxfile.init() failed!\n"));
    121                             }
    122                         }
    123                         else
    124                         {
    125                             /* to not enter an unstable state - free all and mark as no pefile*/
    126                             SetState(hFile, HSTATE_NOT_PE);
    127                             kprintf(("_ldrRead:  oops! could not allocate a Node for this file - why?\n"));
    128                         }
    129                     }
    130                     else
    131                     {
    132                         kprintf(("_ldrRead: Building an QAppType-Header!\n"));
    133                         LXFile::buildQAppTypeHeader((struct e32_exe*)pBuffer);
    134                         SetState(hFile, HSTATE_NOT_PE);
    135                     }
    136                 }
    137                 else
    138                 {
    139                     /* CERTAIN: not a pefile! */
    140                     SetState(hFile,HSTATE_NOT_PE);
    141                 }
    142                 freeUncertainEntry(hFile);
    143             }
    144         }
    145     }
    146 
    14771    return rc;
    14872}
Note: See TracChangeset for help on using the changeset viewer.