1 | /* $Id: myLDRGetProcAddr.cpp,v 1.2 2001-02-10 11:11:45 bird Exp $
|
---|
2 | *
|
---|
3 | * LDRGetProcAddr - Get an entry point to a module.
|
---|
4 | * We override this and allow querying entrypoints from executable too.
|
---|
5 | *
|
---|
6 | * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
7 | *
|
---|
8 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
9 | *
|
---|
10 | */
|
---|
11 |
|
---|
12 | /*******************************************************************************
|
---|
13 | * Defined Constants And Macros *
|
---|
14 | *******************************************************************************/
|
---|
15 | #define INCL_DOSERRORS
|
---|
16 | #define INCL_NOPMAPI
|
---|
17 | #define INCL_OS2KRNL_PTDA
|
---|
18 | #define INCL_OS2KRNL_LDR
|
---|
19 |
|
---|
20 | /*******************************************************************************
|
---|
21 | * Header Files *
|
---|
22 | *******************************************************************************/
|
---|
23 | #include <os2.h>
|
---|
24 |
|
---|
25 | #include <memory.h>
|
---|
26 | #include <stdlib.h>
|
---|
27 | #include <string.h>
|
---|
28 |
|
---|
29 | #include "devSegDf.h" /* Win32k segment definitions. */
|
---|
30 | #include "log.h"
|
---|
31 | #include "avl.h"
|
---|
32 | #include <peexe.h>
|
---|
33 | #include <exe386.h>
|
---|
34 | #include "OS2Krnl.h"
|
---|
35 | #include "dev32.h"
|
---|
36 | #include "ldr.h"
|
---|
37 | #include "options.h"
|
---|
38 |
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * LDRGetProcAddr gets address and proctype for a entry point to a module.
|
---|
42 | *
|
---|
43 | * We would like to treat hmte == NULLHANDLE as the handle of the
|
---|
44 | * executable module of the calling (current) process. So, we'll
|
---|
45 | * have to correct it.
|
---|
46 | *
|
---|
47 | * @returns NO_ERROR if the module was LoadModuled or executable.
|
---|
48 | * ERROR_INVALID_HANDLE if not LoadModuled.
|
---|
49 | * @param hmte Handle of module.
|
---|
50 | * @param ulOrdinal Procedure ordinal.
|
---|
51 | * @param pszName Pointer to procedure name.
|
---|
52 | * NULL is allowed. Ignored if ulOrdinal is not zero.
|
---|
53 | * @param pulAddress Pointer to address variable. (output)
|
---|
54 | * @param fFlat TRUE if a flat 0:32 address is to be returned.
|
---|
55 | * FALSE if a far 16:16 address is to be returned.
|
---|
56 | * @param pulProcType Pointer to procedure type variable. (output)
|
---|
57 | * NULL is allowed. (DosQueryProcAddr uses NULL)
|
---|
58 | * In user space.
|
---|
59 | * @sketch Check if enabled.
|
---|
60 | * Correct hmte == NULLHANDLE to the EXE hmte for the current process.
|
---|
61 | */
|
---|
62 | ULONG LDRCALL myLDRGetProcAddr(HMTE hmte,
|
---|
63 | ULONG ulOrdinal,
|
---|
64 | PCSZ pszName,
|
---|
65 | PULONG pulAddress,
|
---|
66 | BOOL fFlat,
|
---|
67 | PULONG pulProcType)
|
---|
68 | {
|
---|
69 | /*
|
---|
70 | * Check if the fix is enabled, and needed, and possible to apply.
|
---|
71 | */
|
---|
72 | if ( isExeFixesEnabled()
|
---|
73 | && hmte == NULLHANDLE
|
---|
74 | && ptdaGetCur() != NULL)
|
---|
75 | {
|
---|
76 | hmte = ptdaGet_ptda_module(ptdaGetCur());
|
---|
77 | kprintf(("myLDRGetProcAddr: Set hmte to exe handle. hmte=%04x\n", hmte));
|
---|
78 | }
|
---|
79 |
|
---|
80 | /*
|
---|
81 | * Let the real function do rest of the work.
|
---|
82 | */
|
---|
83 | return LDRGetProcAddr(hmte, ulOrdinal, pszName, pulAddress, fFlat, pulProcType);
|
---|
84 | }
|
---|
85 |
|
---|