1 | /* $Id: windllbase.h,v 1.4 1999-11-22 20:36:53 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 |
|
---|
18 | #ifndef HINSTANCE
|
---|
19 | #define HINSTANCE ULONG
|
---|
20 | #endif
|
---|
21 |
|
---|
22 | #define DLL_PROCESS_ATTACH 1
|
---|
23 | #define DLL_THREAD_ATTACH 2
|
---|
24 | #define DLL_THREAD_DETACH 3
|
---|
25 | #define DLL_PROCESS_DETACH 0
|
---|
26 |
|
---|
27 | #define DONT_RESOLVE_DLL_REFERENCES 0x00000001
|
---|
28 | #define LOAD_LIBRARY_AS_DATAFILE 0x00000002
|
---|
29 | #define LOAD_WITH_ALTERED_SEARCH_PATH 0x00000008
|
---|
30 |
|
---|
31 | //odin.ini section names to lookup renamed dlls
|
---|
32 | //i.e. OLE32 -> OLE32OS2
|
---|
33 | #define DLLRENAMEWIN_SECTION "DLLRENAMEWIN"
|
---|
34 | //i.e. OLE32OS2 -> OLE32
|
---|
35 | #define DLLRENAMEOS2_SECTION "DLLRENAMEOS2"
|
---|
36 |
|
---|
37 | class Win32DllBase : public virtual Win32ImageBase
|
---|
38 | {
|
---|
39 | public:
|
---|
40 | Win32DllBase(HINSTANCE hInstance, WIN32DLLENTRY DllEntryPoint);
|
---|
41 | virtual ~Win32DllBase();
|
---|
42 |
|
---|
43 | ULONG AddRef() { return ++referenced; };
|
---|
44 | //ASSUMPTION: called by FreeLibrary only
|
---|
45 | virtual ULONG Release();
|
---|
46 | char *getName() { return szModule; };
|
---|
47 | void setNoEntryCalls() { fSkipEntryCalls = TRUE; };
|
---|
48 |
|
---|
49 | Win32DllBase *getNext() { return next; };
|
---|
50 | static Win32DllBase *getFirst();
|
---|
51 |
|
---|
52 | //Send DLL_THREAD_ATTACH message to all dlls for a new thread
|
---|
53 | static void attachThreadToAllDlls();
|
---|
54 |
|
---|
55 | //Send DLL_THREAD_DETACH message to all dlls for thread that's about to die
|
---|
56 | static void detachThreadFromAllDlls();
|
---|
57 |
|
---|
58 | //Setup TLS structure for all dlls for a new thread
|
---|
59 | static void tlsAttachThreadToAllDlls();
|
---|
60 |
|
---|
61 | //Destroy TLS structure for all dlls for a thread that's about to die
|
---|
62 | static void tlsDetachThreadFromAllDlls();
|
---|
63 |
|
---|
64 | virtual ULONG getApi(char *name) = 0;
|
---|
65 | virtual ULONG getApi(int ordinal) = 0;
|
---|
66 |
|
---|
67 | BOOL attachProcess();
|
---|
68 | BOOL detachProcess();
|
---|
69 | BOOL attachThread();
|
---|
70 | BOOL detachThread();
|
---|
71 |
|
---|
72 | // enable / disable thread attach/detach calls
|
---|
73 | void setThreadLibraryCalls(BOOL fEnable);
|
---|
74 |
|
---|
75 | static void deleteAll();
|
---|
76 |
|
---|
77 | static BOOL isSystemDll(char *szFileName);
|
---|
78 |
|
---|
79 | virtual BOOL isLxDll() = 0;
|
---|
80 | virtual BOOL isDll();
|
---|
81 |
|
---|
82 | static void renameDll(char *dllname, BOOL fWinToOS2=TRUE);
|
---|
83 | static void setDefaultRenaming();
|
---|
84 |
|
---|
85 | static Win32DllBase *findModule(char *dllname);
|
---|
86 | static Win32DllBase *findModule(HINSTANCE hinstance);
|
---|
87 | static Win32DllBase *findModule(WIN32DLLENTRY DllEntryPoint);
|
---|
88 |
|
---|
89 | protected:
|
---|
90 | BOOL fSkipEntryCalls, fUnloaded, fAttachedToProcess;
|
---|
91 |
|
---|
92 | WIN32DLLENTRY dllEntryPoint;
|
---|
93 |
|
---|
94 | ULONG referenced;
|
---|
95 |
|
---|
96 | private:
|
---|
97 | static Win32DllBase *head;
|
---|
98 | Win32DllBase *next;
|
---|
99 | };
|
---|
100 |
|
---|
101 | #endif
|
---|