source: trunk/src/kernel32/windlllx.cpp@ 2802

Last change on this file since 2802 was 2802, checked in by sandervl, 26 years ago

Added new logging feature

File size: 4.2 KB
Line 
1/* $Id: windlllx.cpp,v 1.8 2000-02-16 14:22:11 sandervl Exp $ */
2
3/*
4 * Win32 LX Dll class (compiled in OS/2 using Odin32 api)
5 *
6 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 *
9 * TODO: Unloading of dlls probably needs to be fixed due to OS/2 bug
10 * (wrong unload order of dlls)
11 * TODO: Unloading of system dlls is not correct for the PE loader
12 * (they're always put at the head of the list even though there
13 * might be a dependency with a win32 dll)
14 *
15 * Project Odin Software License can be found in LICENSE.TXT
16 *
17 */
18#define INCL_DOSFILEMGR /* File Manager values */
19#define INCL_DOSERRORS /* DOS Error values */
20#define INCL_DOSPROCESS /* DOS Process values */
21#define INCL_DOSMODULEMGR
22#define INCL_DOSMISC /* DOS Miscellanous values */
23#define INCL_WIN
24#include <os2wrap.h> //Odin32 OS/2 api wrappers
25#include <stdio.h>
26#include <string.h>
27#include <stdlib.h>
28#include <iostream.h>
29#include <fstream.h>
30#include <misc.h>
31#include <win32type.h>
32#include <windllbase.h>
33#include <windlllx.h>
34#include <odinlx.h>
35#include "oslibmisc.h"
36
37#define DBG_LOCALLOG DBG_windlllx
38#include "dbglocal.h"
39
40//******************************************************************************
41//Create LX Dll object and send process attach message
42//System dlls set EntryPoint to 0
43//Returns: Odin32 module handle
44//******************************************************************************
45DWORD WIN32API RegisterLxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint,
46 PVOID pResData)
47{
48 Win32LxDll *windll;
49
50 windll = (Win32LxDll *)Win32DllBase::findModule(hInstance);
51 if(windll) {
52 char *name = OSLibGetDllName(hInstance);
53 dprintf(("RegisterLxDll: Register existing dll %x %s", hInstance, name));
54 return FALSE;
55 }
56 windll = new Win32LxDll(hInstance, EntryPoint, pResData);
57 if(windll == NULL) {
58 dprintf(("RegisterLxDll: windll == NULL!!!"));
59 return FALSE;
60 }
61 windll->AddRef();
62 if(windll->attachProcess() == 0)
63 return 0;
64
65 return windll->getInstanceHandle();
66}
67//******************************************************************************
68//Destroy LX Dll object
69//******************************************************************************
70BOOL WIN32API UnregisterLxDll(HINSTANCE hInstance)
71{
72#if 1
73 return TRUE;
74#else
75 Win32LxDll *windll;
76
77 windll = (Win32LxDll *)Win32DllBase::findModule(hInstance);
78 if(!windll) {
79 dprintf(("UnregisterLxDll: Can't find dll with handle %x!!!", hInstance));
80 return FALSE;
81 }
82 windll->detachProcess();
83 delete windll;
84 return TRUE;
85#endif
86}
87//******************************************************************************
88//******************************************************************************
89Win32LxDll::Win32LxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint, PVOID pResData)
90 : Win32ImageBase(hInstance),
91 Win32LxImage(hInstance, pResData),
92 Win32DllBase(hInstance, EntryPoint)
93{
94 if(EntryPoint == NULL) {
95 fSkipEntryCalls = TRUE;
96 fAttachedToProcess = TRUE;
97 }
98}
99//******************************************************************************
100//******************************************************************************
101Win32LxDll::~Win32LxDll()
102{
103 dprintf(("Win32LxDll::~Win32LxDll %s", szModule));
104}
105//******************************************************************************
106//ASSUMPTION: called by FreeLibrary
107//******************************************************************************
108ULONG Win32LxDll::Release()
109{
110 ULONG ret = --referenced;
111 HINSTANCE hinst;
112
113 if(ret == 0) {
114 dprintf(("Win32LxDll::Release, referenced == 0\n"));
115 //DosFreeModule sends a termination message to the dll.
116 //The LX dll informs us when it's removed (UnregisterDll call)
117 hinst = hinstance;
118 delete this;
119 DosFreeModule(hinst);
120 }
121 return(ret);
122}
123//******************************************************************************
124//******************************************************************************
125BOOL Win32LxDll::isLxDll()
126{
127 return TRUE;
128}
129//******************************************************************************
130//******************************************************************************
Note: See TracBrowser for help on using the repository browser.