| 1 | /* $Id: myldrRead.cpp,v 1.4 1999-10-27 02:02:58 bird Exp $
|
|---|
| 2 | *
|
|---|
| 3 | * myldrRead - _ldrRead.
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright (c) 1998-1999 knut st. osmundsen
|
|---|
| 6 | *
|
|---|
| 7 | */
|
|---|
| 8 |
|
|---|
| 9 | /*******************************************************************************
|
|---|
| 10 | * Defined Constants And Macros *
|
|---|
| 11 | *******************************************************************************/
|
|---|
| 12 | #define INCL_DOSERRORS
|
|---|
| 13 | #define INCL_NOPMAPI
|
|---|
| 14 |
|
|---|
| 15 | /*******************************************************************************
|
|---|
| 16 | * Header Files *
|
|---|
| 17 | *******************************************************************************/
|
|---|
| 18 | #include <os2.h>
|
|---|
| 19 |
|
|---|
| 20 | #include <memory.h>
|
|---|
| 21 | #include <stdlib.h>
|
|---|
| 22 |
|
|---|
| 23 | #include "log.h"
|
|---|
| 24 | #include "dev32.h"
|
|---|
| 25 | #include <peexe.h>
|
|---|
| 26 | #include <exe386.h>
|
|---|
| 27 | #include "OS2Krnl.h"
|
|---|
| 28 | #include "pe2lx.h"
|
|---|
| 29 | #include "avl.h"
|
|---|
| 30 | #include "ldrCalls.h"
|
|---|
| 31 | #include "ldr.h"
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 | ULONG LDRCALL myldrRead(
|
|---|
| 35 | SFN hFile,
|
|---|
| 36 | ULONG ulOffset,
|
|---|
| 37 | PVOID pBuffer,
|
|---|
| 38 | ULONG ulFlags ,
|
|---|
| 39 | ULONG ulBytesToRead,
|
|---|
| 40 | PMTE pMTE
|
|---|
| 41 | )
|
|---|
| 42 | {
|
|---|
| 43 | ULONG rc;
|
|---|
| 44 |
|
|---|
| 45 | /* Check if this is an overrided handle */
|
|---|
| 46 | if (GetState(hFile) == HSTATE_OUR)
|
|---|
| 47 | {
|
|---|
| 48 | PMODULE pMod;
|
|---|
| 49 | kprintf(("_ldrRead+: hF=%+04x off=%+08x pB=%+08x fl=%+08x cb=%+04x pMTE=%+08x\n",hFile,ulOffset,pBuffer,ulFlags,ulBytesToRead,pMTE));
|
|---|
| 50 |
|
|---|
| 51 | pMod = getModuleBySFN(hFile);
|
|---|
| 52 | if (pMod != NULL)
|
|---|
| 53 | {
|
|---|
| 54 | /* I would love to have a pointer to the MTE */
|
|---|
| 55 | if (pMod->pMTE == NULL && pMTE != NULL)
|
|---|
| 56 | pMod->pMTE == pMTE;
|
|---|
| 57 |
|
|---|
| 58 | /* debug */
|
|---|
| 59 | if (ulFlags != 0)
|
|---|
| 60 | kprintf(("_ldrRead: Warning ulFlags = 0x%x (!= 0)\n", ulFlags));
|
|---|
| 61 |
|
|---|
| 62 | if ((pMod->fFlags & MOD_TYPE_MASK) == MOD_TYPE_PE2LX)
|
|---|
| 63 | rc = pMod->Data.pPe2Lx->read(ulOffset, pBuffer, ulBytesToRead, ulFlags, pMTE);
|
|---|
| 64 | else
|
|---|
| 65 | {
|
|---|
| 66 | kprintf(("_ldrRead: Invalid module type, %#x\n", pMod->fFlags & MOD_TYPE_MASK));
|
|---|
| 67 | rc = ERROR_READ_FAULT;
|
|---|
| 68 | }
|
|---|
| 69 | return rc;
|
|---|
| 70 | }
|
|---|
| 71 | else
|
|---|
| 72 | kprintf(("_ldrRead: DON'T PANIC! - but I can't get Node ptr! - This is really an IPE!\n"));
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | rc = _ldrRead(hFile, ulOffset, pBuffer, ulFlags, ulBytesToRead, pMTE);
|
|---|
| 76 |
|
|---|
| 77 | #if 0
|
|---|
| 78 | kprintf(("_ldrRead: hF=%+04x off=%+08x pB=%+08x fl=%+08x cb=%+04x pMTE=%+08x rc=%d\n",
|
|---|
| 79 | hFile,ulOffset,pBuffer,ulFlags,ulBytesToRead,pMTE,rc));
|
|---|
| 80 | #endif
|
|---|
| 81 |
|
|---|
| 82 | return rc;
|
|---|
| 83 | }
|
|---|