Changeset 1273 for trunk/src/win32k/ldr/myldrRead.cpp
- Timestamp:
- Oct 14, 1999, 3:25:39 AM (26 years ago)
- 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:01bird Exp $1 /* $Id: myldrRead.cpp,v 1.2 1999-10-14 01:25:39 bird Exp $ 2 2 * 3 3 * myldrRead - _ldrRead. … … 18 18 #include <os2.h> 19 19 20 #include "pefile.h" 21 #include "lx.h" 20 #include <memory.h> 21 #include <stdlib.h> 22 22 23 #include "log.h" 23 24 #include "dev32.h" 25 #include <peexe.h> 26 #include <exe386.h> 27 #include "OS2Krnl.h" 28 #include "pe2lx.h" 29 #include "ldrCalls.h" 24 30 #include "ldr.h" 25 #include "ldrCalls.h"26 27 31 28 32 … … 37 41 { 38 42 ULONG rc; 39 ULONG ulRead;40 int i;41 PPENODE pNode;42 43 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) 45 46 { 47 PPENODE pNode; 48 46 49 pNode = getNodePtr(hFile); 47 50 if (pNode != NULL) … … 51 54 pNode->pMTE == pMTE; 52 55 53 /* debug*/56 /* debug */ 54 57 if (ulFlags != 0) 55 58 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); 57 61 return rc; 58 62 } 59 63 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")); 61 65 } 62 63 66 64 67 rc = _ldrRead( hFile, ulOffset, pBuffer, ulFlags, ulBytesToRead, pMTE ); … … 66 69 // kprintf(("_ldrRead: hF=%+04x off=%+08x pB=%+08x fl=%+08x cb=%+04x pMTE=%+08x rc=%d\n",hFile,ulOffset,pBuffer,ulFlags,ulBytesToRead,pMTE,rc)); 67 70 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 else82 { /* CERTAIN: not a PE-file */83 SetState(hFile, HSTATE_NOT_PE);84 freeUncertainEntry(hFile);85 }86 }87 else88 {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 lxfile102 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 else118 {119 /* init failed - complain */120 kprintf(("_ldrRead: opps! lxfile.init() failed!\n"));121 }122 }123 else124 {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 else131 {132 kprintf(("_ldrRead: Building an QAppType-Header!\n"));133 LXFile::buildQAppTypeHeader((struct e32_exe*)pBuffer);134 SetState(hFile, HSTATE_NOT_PE);135 }136 }137 else138 {139 /* CERTAIN: not a pefile! */140 SetState(hFile,HSTATE_NOT_PE);141 }142 freeUncertainEntry(hFile);143 }144 }145 }146 147 71 return rc; 148 72 }
Note:
See TracChangeset
for help on using the changeset viewer.