| 1 | /* $Id: myLDRGetProcAddr.cpp,v 1.1 2000-12-17 22:44:46 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 |  | 
|---|
| 19 | /******************************************************************************* | 
|---|
| 20 | *   Header Files                                                               * | 
|---|
| 21 | *******************************************************************************/ | 
|---|
| 22 | #include <os2.h> | 
|---|
| 23 |  | 
|---|
| 24 | #include <memory.h> | 
|---|
| 25 | #include <stdlib.h> | 
|---|
| 26 | #include <string.h> | 
|---|
| 27 |  | 
|---|
| 28 | #include "devSegDf.h"                   /* Win32k segment definitions. */ | 
|---|
| 29 | #include "log.h" | 
|---|
| 30 | #include "avl.h" | 
|---|
| 31 | #include <peexe.h> | 
|---|
| 32 | #include <exe386.h> | 
|---|
| 33 | #include "OS2Krnl.h" | 
|---|
| 34 | #include "dev32.h" | 
|---|
| 35 | #include "ldr.h" | 
|---|
| 36 | #include "ldrCalls.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 |  | 
|---|