| [4] | 1 | /* $Id: windll.h,v 1.1 1999-05-24 20:19:07 ktk Exp $ */ | 
|---|
|  | 2 |  | 
|---|
|  | 3 | /* | 
|---|
|  | 4 | * | 
|---|
|  | 5 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
|  | 6 | * | 
|---|
|  | 7 | */ | 
|---|
|  | 8 | /* | 
|---|
|  | 9 | * Win32 PE Dll class | 
|---|
|  | 10 | * | 
|---|
|  | 11 | * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl) | 
|---|
|  | 12 | * | 
|---|
|  | 13 | */ | 
|---|
|  | 14 | #ifndef __WINDLL_H__ | 
|---|
|  | 15 | #define __WINDLL_H__ | 
|---|
|  | 16 |  | 
|---|
|  | 17 | #include "winimage.h" | 
|---|
|  | 18 |  | 
|---|
|  | 19 | #ifndef CCHMAXPATH | 
|---|
|  | 20 | #define CCHMAXPATH 260 | 
|---|
|  | 21 | #endif | 
|---|
|  | 22 | #ifndef HINSTANCE | 
|---|
|  | 23 | #define HINSTANCE ULONG | 
|---|
|  | 24 | #endif | 
|---|
|  | 25 |  | 
|---|
|  | 26 | #define DLL_PROCESS_ATTACH 1 | 
|---|
|  | 27 | #define DLL_THREAD_ATTACH  2 | 
|---|
|  | 28 | #define DLL_THREAD_DETACH  3 | 
|---|
|  | 29 | #define DLL_PROCESS_DETACH 0 | 
|---|
|  | 30 |  | 
|---|
|  | 31 | #define DONT_RESOLVE_DLL_REFERENCES     0x00000001 | 
|---|
|  | 32 | #define LOAD_LIBRARY_AS_DATAFILE        0x00000002 | 
|---|
|  | 33 | #define LOAD_WITH_ALTERED_SEARCH_PATH   0x00000008 | 
|---|
|  | 34 |  | 
|---|
|  | 35 | typedef ULONG (* WIN32API WIN32DLLENTRY)(ULONG hInstance, ULONG reason, ULONG reserved); | 
|---|
|  | 36 |  | 
|---|
|  | 37 | class Win32Dll : public Win32Image | 
|---|
|  | 38 | { | 
|---|
|  | 39 | public: | 
|---|
|  | 40 | Win32Dll(HINSTANCE hinstance, int NameTableId, int Win32TableId, WIN32DLLENTRY DllEntryPoint); | 
|---|
|  | 41 | Win32Dll(char *szDllName); | 
|---|
|  | 42 | ~Win32Dll(); | 
|---|
|  | 43 |  | 
|---|
|  | 44 | void      OS2DllInit(HINSTANCE hinstance, int NameTableId, int Win32TableId, | 
|---|
|  | 45 | WIN32DLLENTRY DllEntryPoint); | 
|---|
|  | 46 |  | 
|---|
|  | 47 | BOOL      init(); | 
|---|
|  | 48 |  | 
|---|
|  | 49 | ULONG     AddRef()           { return ++referenced; }; | 
|---|
|  | 50 | //ASSUMPTION: called by FreeLibrary only | 
|---|
|  | 51 | ULONG     Release(); | 
|---|
|  | 52 | char     *getName()          { return szModule; }; | 
|---|
|  | 53 | void      setNoEntryCalls()  { fSkipEntryCalls = TRUE; }; | 
|---|
|  | 54 |  | 
|---|
|  | 55 | Win32Dll *getNext()  { return next; }; | 
|---|
|  | 56 | static  Win32Dll *getFirst(); | 
|---|
|  | 57 |  | 
|---|
|  | 58 | ULONG     getApi(char *name); | 
|---|
|  | 59 | ULONG     getApi(int ordinal); | 
|---|
|  | 60 | BOOL      attachProcess(); | 
|---|
|  | 61 | BOOL      detachProcess(); | 
|---|
|  | 62 | BOOL      attachThread(); | 
|---|
|  | 63 | BOOL      detachThread(); | 
|---|
|  | 64 |  | 
|---|
|  | 65 | static  void      deleteAll(); | 
|---|
|  | 66 |  | 
|---|
|  | 67 | static  BOOL      isSystemDll(char *szFileName); | 
|---|
|  | 68 |  | 
|---|
|  | 69 | static  Win32Dll *findModule(char *dllname); | 
|---|
|  | 70 | static  Win32Dll *findModule(HINSTANCE hinstance); | 
|---|
|  | 71 | static  Win32Dll *findModule(WIN32DLLENTRY DllEntryPoint); | 
|---|
|  | 72 |  | 
|---|
|  | 73 | protected: | 
|---|
|  | 74 | BOOL      fSystemDll, fSkipEntryCalls, fUnloaded; | 
|---|
|  | 75 |  | 
|---|
|  | 76 | WIN32DLLENTRY dllEntryPoint; | 
|---|
|  | 77 | private: | 
|---|
|  | 78 | ULONG     referenced; | 
|---|
|  | 79 | char      szModule[CCHMAXPATH]; | 
|---|
|  | 80 |  | 
|---|
|  | 81 | char     *StripPath(char *path); | 
|---|
|  | 82 |  | 
|---|
|  | 83 |  | 
|---|
|  | 84 | static  Win32Dll *head; | 
|---|
|  | 85 | Win32Dll *next; | 
|---|
|  | 86 | }; | 
|---|
|  | 87 |  | 
|---|
|  | 88 | #endif | 
|---|