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

Last change on this file since 9975 was 9975, checked in by sandervl, 22 years ago

YD: Changes for header updates

File size: 3.4 KB
Line 
1/* $Id: windllpeldr.cpp,v 1.12 2003-04-02 12:58:31 sandervl 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//******************************************************************************
55DWORD Win32PeLdrDll::init(ULONG reservedMem, ULONG ulPEOffset)
56{
57 char modname[CCHMAXPATH];
58 char *syspath;
59 HFILE dllfile;
60 APIRET rc;
61 DWORD dwRet;
62
63 strupr(szFileName);
64 if(!strchr(szFileName, (int)'.')) {
65 strcat(szFileName, DLL_EXTENSION);
66 }
67
68 dllfile = OSLibDosOpen(szFileName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
69 if(dllfile == NULL) {//search in libpath for dll
70 syspath = getenv("WIN32LIBPATH");
71 if(syspath) {
72 strcpy(modname, syspath);
73 if(modname[strlen(modname)-1] != '\\') {
74 strcat(modname, "\\");
75 }
76 strcat(modname, szFileName);
77 strcpy(szFileName, modname);
78 }
79 }
80 else OSLibDosClose(dllfile);
81
82 dwRet = Win32PeLdrImage::init(0);
83 dllEntryPoint = (WIN32DLLENTRY)entryPoint;
84
85 if(!(fh.Characteristics & IMAGE_FILE_DLL)) {
86 //executable loaded as dll; don't call entrypoint
87 dprintf(("WARNING: Exe %s loaded as dll; entrypoint not called", szFileName));
88 dllEntryPoint = NULL;
89 }
90 return dwRet;
91}
92//******************************************************************************
93//******************************************************************************
94BOOL Win32PeLdrDll::isPe2LxDll() const
95{
96 return FALSE;
97}
98//******************************************************************************
99//******************************************************************************
100BOOL Win32PeLdrDll::isLxDll() const
101{
102 return FALSE;
103}
104//******************************************************************************
105//******************************************************************************
Note: See TracBrowser for help on using the repository browser.