source: trunk/src/kernel32/windllbase.h@ 4507

Last change on this file since 4507 was 4474, checked in by sandervl, 25 years ago

pe loader fixes, add system32\drivers dir during installation, add build date + time during kernel32 load

File size: 3.9 KB
Line 
1/* $Id: windllbase.h,v 1.6 2000-10-10 17:14:06 sandervl Exp $ */
2
3/*
4 * Win32 Dll base class
5 *
6 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12#ifndef __WINDLLBASE_H__
13#define __WINDLLBASE_H__
14
15#include <winimagebase.h>
16#include <odinlx.h>
17#include <vmutex.h>
18
19#ifndef HINSTANCE
20#define HINSTANCE ULONG
21#endif
22
23#define DLL_PROCESS_ATTACH 1
24#define DLL_THREAD_ATTACH 2
25#define DLL_THREAD_DETACH 3
26#define DLL_PROCESS_DETACH 0
27
28#define DONT_RESOLVE_DLL_REFERENCES 0x00000001
29#define LOAD_LIBRARY_AS_DATAFILE 0x00000002
30#define LOAD_WITH_ALTERED_SEARCH_PATH 0x00000008
31
32//odin.ini section names to lookup renamed dlls
33//i.e. OLE32 -> OLE32OS2
34#define DLLRENAMEWIN_SECTION "DLLRENAMEWIN"
35//i.e. OLE32OS2 -> OLE32
36#define DLLRENAMEOS2_SECTION "DLLRENAMEOS2"
37
38class Win32DllBase : public virtual Win32ImageBase
39{
40public:
41 Win32DllBase(HINSTANCE hInstance, WIN32DLLENTRY DllEntryPoint, Win32ImageBase *parent = NULL);
42virtual ~Win32DllBase();
43
44#ifdef DEBUG
45virtual ULONG AddRef(char *parentname = NULL);
46#else
47virtual ULONG AddRef();
48#endif
49virtual ULONG Release();
50
51 char *getName() { return szModule; };
52
53 //do not call the ATTACH_THREAD, DETACH_THREAD functions
54 void disableThreadLibraryCalls() { fSkipThreadEntryCalls = TRUE; };
55 void disableLibraryCalls() { fSkipEntryCalls = fSkipThreadEntryCalls = TRUE; };
56
57 Win32DllBase *getNext() { return next; };
58static Win32DllBase *getFirst();
59
60//Send DLL_THREAD_ATTACH message to all dlls for a new thread
61static void attachThreadToAllDlls();
62
63//Send DLL_THREAD_DETACH message to all dlls for thread that's about to die
64static void detachThreadFromAllDlls();
65
66//Setup TLS structure for all dlls for a new thread
67static void tlsAttachThreadToAllDlls();
68
69//Destroy TLS structure for all dlls for a thread that's about to die
70static void tlsDetachThreadFromAllDlls();
71
72 BOOL attachProcess();
73 BOOL detachProcess();
74 BOOL attachThread();
75 BOOL detachThread();
76
77 //This counter is incremented when the dll has been loaded with LoadLibrary(Ex)
78 //(== not loaded on behalf of another dll or the main exe)
79 void incDynamicLib();
80 void decDynamicLib();
81 BOOL isDynamicLib() { return nrDynamicLibRef != 0; };
82
83 void setUnloadOrder(Win32ImageBase *parent);
84
85 void updateDependencies();
86
87 BOOL RemoveCircularDependency(Win32DllBase *parent);
88
89 //Only called for kernel32
90 void DisableUnload() { fDisableUnload = TRUE; };
91
92static void deleteDynamicLibs();
93static void deleteAll();
94
95static BOOL isSystemDll(char *szFileName);
96
97virtual BOOL isLxDll() = 0;
98virtual BOOL isDll();
99
100static void renameDll(char *dllname, BOOL fWinToOS2=TRUE);
101static void setDefaultRenaming();
102
103static Win32DllBase *findModule(char *dllname, BOOL fRenameFirst = FALSE);
104static Win32DllBase *findModule(HINSTANCE hinstance);
105static Win32DllBase *findModule(WIN32DLLENTRY DllEntryPoint);
106static Win32DllBase *findModuleByAddr(ULONG address);
107
108#ifdef DEBUG_ENABLELOG_LEVEL2
109 void printListOfDlls();
110#endif
111
112protected:
113#ifdef DEBUG
114 void printDependencies(char *parent);
115#endif
116
117 BOOL fSkipThreadEntryCalls, fUnloaded, fAttachedToProcess, fSkipEntryCalls;
118
119 WIN32DLLENTRY dllEntryPoint;
120
121 LONG referenced;
122
123 //This counter is incremented when the dll has been loaded with LoadLibrary(Ex)
124 //(== not loaded on behalf of another dll or the main exe)
125 BOOL nrDynamicLibRef;
126
127 BOOL fInserted; //inserted in dll list
128
129 //This flag is set when a dll has been loaded with DosLoadModule
130 BOOL fDisableUnload;
131
132static Win32DllBase *head;
133 Win32DllBase *next;
134private:
135static Queue loadLibDlls;
136};
137
138extern VMutex dlllistmutex; //protects linked lists of heaps
139
140#endif
Note: See TracBrowser for help on using the repository browser.