source: trunk/src/win32k/ldr/myldrRead.cpp@ 6666

Last change on this file since 6666 was 5086, checked in by bird, 25 years ago

Moved ldrCalls.h into the OS2Krnl.h tree as OS2KLDR.h.
Also moved the Ldr definitions from OS2Krnl.h and into OS2KLDR.h.

File size: 3.5 KB
Line 
1/* $Id: myldrRead.cpp,v 1.9 2001-02-10 11:11:47 bird Exp $
2 *
3 * myldrRead - ldrRead.
4 *
5 * Copyright (c) 1998-2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
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#define INCL_OS2KRNL_LDR
17
18/*******************************************************************************
19* Header Files *
20*******************************************************************************/
21#include <os2.h>
22
23#include <memory.h>
24#include <stdlib.h>
25
26#include "devSegDf.h" /* Win32k segment definitions. */
27#include "log.h"
28#include "avl.h"
29#include "dev32.h"
30#include <peexe.h>
31#include <exe386.h>
32#include "OS2Krnl.h"
33#include "ldr.h"
34#include "ModuleBase.h"
35#include "pe2lx.h"
36
37
38/**
39 * Overloads ldrRead.
40 * @returns OS/2 return code.
41 * @param hFile Filehandle to read from.
42 * @param pvBuffer Buffer to read into.
43 * @param fpBuffer This is not flags as I first though, but probably a far 16-bit pointer
44 * to the buffer.
45 * @param cbToRead Count of bytes to read.
46 * @param pMTE
47 * @sketch IF it's our module THEN
48 * Get module pointer. (complain if this failes and backout to ldrRead.)
49 * Currently - verify that it's a Pe2Lx module. (complain and fail if not.)
50 * Invoke the read method of the module do the requested read operation.
51 * Save pMTE if present and not save allready.
52 * ENDIF
53 * - backout or not our module -
54 * forward request to the original ldrRead.
55 * @status Completely implemented.
56 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
57 */
58ULONG LDRCALL myldrRead(
59 SFN hFile,
60 ULONG ulOffset,
61 PVOID pvBuffer,
62 ULONG fpBuffer,
63 ULONG cbToRead,
64 PMTE pMTE
65 )
66{
67 ULONG rc;
68
69 /* Check if this is an overrided handle */
70 if (GetState(hFile) == HSTATE_OUR)
71 {
72 PMODULE pMod;
73 kprintf(("myldrRead: hF=%+04x off=%+08x pB=%+08x fp=%+08x cb=%+04x pMTE=%+08x\n",
74 hFile, ulOffset, pvBuffer, fpBuffer, cbToRead, pMTE));
75
76 pMod = getModuleBySFN(hFile);
77 if (pMod != NULL)
78 {
79 /* I would love to have a pointer to the MTE */
80 if (pMod->pMTE == NULL && pMTE != NULL)
81 pMod->pMTE = pMTE;
82
83 if ((pMod->fFlags & MOD_TYPE_MASK) == MOD_TYPE_PE2LX)
84 rc = pMod->Data.pModule->read(ulOffset, pvBuffer, fpBuffer, cbToRead, pMTE);
85 else
86 {
87 kprintf(("myldrRead: Invalid module type, %#x\n", pMod->fFlags & MOD_TYPE_MASK));
88 rc = ERROR_READ_FAULT;
89 }
90 }
91 else
92 {
93 kprintf(("myldrRead: DON'T PANIC! - but I can't get Node ptr! - This is really an IPE!\n"));
94 rc = ERROR_READ_FAULT;
95 }
96 }
97 else
98 {
99 rc = ldrRead(hFile, ulOffset, pvBuffer, fpBuffer, cbToRead, pMTE);
100 }
101 #if 0
102 kprintf(("myldrRead: hF=%+04x off=%+08x pB=%+08x fp=%+08x cb=%+04x pMTE=%+08x rc=%d\n",
103 hFile, ulOffset, pvBuffer, fpBuffer, cbToRead, pMTE, rc));
104 #endif
105
106 return rc;
107}
Note: See TracBrowser for help on using the repository browser.