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

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

Allow executable api exports

File size: 3.9 KB
Line 
1/* $Id: windlllx.cpp,v 1.5 1999-11-26 00:05:19 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 *
12 * Project Odin Software License can be found in LICENSE.TXT
13 *
14 */
15#define INCL_DOSFILEMGR /* File Manager values */
16#define INCL_DOSERRORS /* DOS Error values */
17#define INCL_DOSPROCESS /* DOS Process values */
18#define INCL_DOSMODULEMGR
19#define INCL_DOSMISC /* DOS Miscellanous values */
20#define INCL_WIN
21#include <os2wrap.h> //Odin32 OS/2 api wrappers
22#include <stdio.h>
23#include <string.h>
24#include <stdlib.h>
25#include <iostream.h>
26#include <fstream.h>
27#include <misc.h>
28#include <win32type.h>
29#include <windllbase.h>
30#include <windlllx.h>
31#include <odinlx.h>
32#include "oslibmisc.h"
33
34//******************************************************************************
35//Create LX Dll object and send process attach message
36//System dlls set EntryPoint to 0
37//Returns: Odin32 module handle
38//******************************************************************************
39DWORD WIN32API RegisterLxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint,
40 PVOID pResData)
41{
42 Win32LxDll *windll;
43
44 windll = (Win32LxDll *)Win32DllBase::findModule(hInstance);
45 if(windll) {
46 char *name = OSLibGetDllName(hInstance);
47 dprintf(("RegisterLxDll: Register existing dll %x %s", hInstance, name));
48 return FALSE;
49 }
50 windll = new Win32LxDll(hInstance, EntryPoint, pResData);
51 if(windll == NULL) {
52 dprintf(("RegisterLxDll: windll == NULL!!!"));
53 return FALSE;
54 }
55 windll->AddRef();
56 if(windll->attachProcess() == 0)
57 return 0;
58
59 return windll->getInstanceHandle();
60}
61//******************************************************************************
62//Destroy LX Dll object
63//******************************************************************************
64BOOL WIN32API UnregisterLxDll(HINSTANCE hInstance)
65{
66#if 1
67 return TRUE;
68#else
69 Win32LxDll *windll;
70
71 windll = (Win32LxDll *)Win32DllBase::findModule(hInstance);
72 if(!windll) {
73 dprintf(("UnregisterLxDll: Can't find dll with handle %x!!!", hInstance));
74 return FALSE;
75 }
76 windll->detachProcess();
77 delete windll;
78 return TRUE;
79#endif
80}
81//******************************************************************************
82//******************************************************************************
83Win32LxDll::Win32LxDll(HINSTANCE hInstance, WIN32DLLENTRY EntryPoint, PVOID pResData)
84 : Win32ImageBase(hInstance),
85 Win32LxImage(hInstance, pResData),
86 Win32DllBase(hInstance, EntryPoint)
87{
88 if(EntryPoint == NULL) {
89 fSkipEntryCalls = TRUE;
90 fAttachedToProcess = TRUE;
91 }
92}
93//******************************************************************************
94//******************************************************************************
95Win32LxDll::~Win32LxDll()
96{
97 dprintf(("Win32LxDll::~Win32LxDll %s", szModule));
98}
99//******************************************************************************
100//ASSUMPTION: called by FreeLibrary
101//******************************************************************************
102ULONG Win32LxDll::Release()
103{
104 ULONG ret = --referenced;
105
106 if(ret == 0) {
107 dprintf(("Win32LxDll::Release, referenced == 0\n"));
108 //DosFreeModule sends a termination message to the dll.
109 //The LX dll informs us when it's removed (UnregisterDll call)
110 DosFreeModule(hinstance);
111 }
112 return(ret);
113}
114//******************************************************************************
115//******************************************************************************
116BOOL Win32LxDll::isLxDll()
117{
118 return TRUE;
119}
120//******************************************************************************
121//******************************************************************************
Note: See TracBrowser for help on using the repository browser.