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