source: trunk/src/kernel32/windllpeldr.cpp@ 7029

Last change on this file since 7029 was 6015, checked in by bird, 24 years ago

Corrected Pe2Lx bug in LoadLibrary. Added isPe2LxDLL.

File size: 3.4 KB
Line 
1/* $Id: windllpeldr.cpp,v 1.9 2001-06-15 09:42:48 bird Exp $ */
2
3/*
4 * Win32 PE loader Dll class
5 *
6 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12#define INCL_DOSFILEMGR /* File Manager values */
13#define INCL_DOSERRORS /* DOS Error values */
14#define INCL_DOSPROCESS /* DOS Process values */
15#define INCL_DOSMODULEMGR
16#define INCL_DOSMISC /* DOS Miscellanous values */
17#define INCL_WIN
18#include <os2wrap.h> //Odin32 OS/2 api wrappers
19#include <stdio.h>
20#include <string.h>
21#include <stdlib.h>
22#include <iostream.h>
23#include <fstream.h>
24#include <misc.h>
25#include <win32type.h>
26#include <pefile.h>
27#include <windllpeldr.h>
28#include <wprocess.h>
29
30#include "oslibmisc.h"
31#include "oslibdos.h"
32
33#define DBG_LOCALLOG DBG_windllpeldr
34#include "dbglocal.h"
35
36
37//******************************************************************************
38//******************************************************************************
39Win32PeLdrDll::Win32PeLdrDll(char *szDllName, Win32ImageBase *parentImage)
40 : Win32ImageBase(-1),
41 Win32DllBase(-1, 0, parentImage),
42 Win32PeLdrImage(szDllName, FALSE)
43{
44 dprintf(("Win32PeLdrDll::Win32PeLdrDll %s %s loaded by %s", szFileName, szModule,
45 (parentImage) ? parentImage->getModuleName() : "Unknown"));
46}
47//******************************************************************************
48//******************************************************************************
49Win32PeLdrDll::~Win32PeLdrDll()
50{
51 dprintf(("Win32PeLdrDll::~Win32PeLdrDll %s", szModule));
52}
53//******************************************************************************
54//******************************************************************************
55BOOL Win32PeLdrDll::init(ULONG reservedMem)
56{
57 char modname[CCHMAXPATH];
58 char *syspath;
59 HFILE dllfile;
60 APIRET rc;
61 BOOL fRet;
62
63 strupr(szFileName);
64 if(!strchr(szFileName, (int)'.')) {
65 strcat(szFileName, DLL_EXTENSION);
66 }
67 dllfile = OSLibDosOpen(szFileName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
68 if(dllfile == NULL) {//search in libpath for dll
69 syspath = getenv("WIN32LIBPATH");
70 if(syspath) {
71 strcpy(modname, syspath);
72 if(modname[strlen(modname)-1] != '\\') {
73 strcat(modname, "\\");
74 }
75 strcat(modname, szFileName);
76 strcpy(szFileName, modname);
77 }
78 }
79 else OSLibDosClose(dllfile);
80 fRet = Win32PeLdrImage::init(0);
81 dllEntryPoint = (WIN32DLLENTRY)entryPoint;
82
83 if(!(fh.Characteristics & IMAGE_FILE_DLL)) {
84 //executable loaded as dll; don't call entrypoint
85 dprintf(("WARNING: Exe %s loaded as dll; entrypoint not called", szFileName));
86 dllEntryPoint = NULL;
87 }
88 return fRet;
89}
90//******************************************************************************
91//******************************************************************************
92BOOL Win32PeLdrDll::isPe2LxDll() const
93{
94 return FALSE;
95}
96//******************************************************************************
97//******************************************************************************
98BOOL Win32PeLdrDll::isLxDll() const
99{
100 return FALSE;
101}
102//******************************************************************************
103//******************************************************************************
Note: See TracBrowser for help on using the repository browser.