source: trunk/include/winimagebase.h@ 953

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

New headers for kernel32 win32 image classes + removed old ones + nameid.h

File size: 3.7 KB
RevLine 
[953]1/* $Id: winimagebase.h,v 1.1 1999-09-15 23:29:37 sandervl Exp $ */
2
3/*
4 * Win32 PE Image 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 __WINIMAGEBASE_H__
13#define __WINIMAGEBASE_H__
14
15#include <peexe.h>
16
17#ifdef DEBUG
18#define MAGIC_WINIMAGE 0x11223344
19#endif
20
21#ifndef CCHMAXPATH
22#define CCHMAXPATH 260
23#endif
24
25#define LANG_GETFIRST 0x80000000
26
27class Win32Resource;
28
29class Win32ImageBase
30{
31#ifdef DEBUG
32protected:
33 DWORD magic;
34public:
35 void checkObject()
36 {
37 if(magic != MAGIC_WINIMAGE) {
38 eprintf(("Corrupt this pointer %X %X!!", this, magic));
39 DebugInt3();
40 }
41 };
42#endif
43
44public:
45 // Constructors and destructors
46 Win32ImageBase(HINSTANCE hInstance);
47virtual ~Win32ImageBase();
48
49 ULONG getError() { return errorState; };
50 HINSTANCE getInstanceHandle() { return hinstance; };
51
52virtual void setFullPath(char *name);
53 char *getFullPath() { return fullpath; };
54
55 char *getModuleName() { return szModule; };
56
57virtual HRSRC findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG lang = LANG_GETFIRST) = 0;
58 HRSRC findResourceW(LPWSTR lpszName, LPWSTR lpszType, ULONG lang = LANG_GETFIRST);
59virtual ULONG getResourceSizeA(LPCSTR lpszName, LPSTR lpszType, ULONG lang = LANG_GETFIRST) = 0;
60 ULONG getResourceSizeW(LPCWSTR lpszName, LPWSTR lpszType, ULONG lang = LANG_GETFIRST);
61
62virtual ULONG getVersionSize() = 0;
63virtual BOOL getVersionStruct(char *verstruct, ULONG bufLength) = 0;
64
65static BOOL isPEImage(char *szFileName);
66
67 void setEntryPoint(ULONG startAddress) { entryPoint = startAddress; };
68
69 void setTLSAddress(LPVOID dwTlsAddress) { tlsAddress = dwTlsAddress; };
70 void setTLSIndexAddr(LPDWORD dwTlsIndexAddr) { tlsIndexAddr = dwTlsIndexAddr; };
71 void setTLSInitSize(ULONG dwTlsSize) { tlsInitSize = dwTlsSize; };
72 void setTLSTotalSize(ULONG dwTlsSize) { tlsTotalSize = dwTlsSize; };
73 void setTLSCallBackAddr(PIMAGE_TLS_CALLBACK *dwTlsCallBackAddr)
74 {
75 tlsCallBackAddr = dwTlsCallBackAddr;
76 };
77
78 void tlsAttachThread(); //setup TLS structures for new thread
79 void tlsDetachThread(); //destroy TLS structures
80
81virtual BOOL isDll() = 0;
82
83protected:
84 void tlsAlloc(); //Allocate TLS index for this module
85 void tlsDelete(); //Destroy TLS index for this module
86
87 Win32Resource *winres;
88
89 ULONG errorState, entryPoint;
90
91 char *fullpath;
92 char szModule[CCHMAXPATH];
93 char szFileName[CCHMAXPATH];
94
95 HINSTANCE hinstance;
96
97 LPVOID tlsAddress; //address of TLS data
98 LPDWORD tlsIndexAddr; //address of DWORD that receives the TLS index
99 ULONG tlsInitSize; //size of initialized TLS memory block
100 ULONG tlsTotalSize; //size of TLS memory block
101 PIMAGE_TLS_CALLBACK *tlsCallBackAddr; //ptr to TLS callback array
102 ULONG tlsIndex; //module TLS index
103
104private:
105
106 friend class Win32Resource;
107 friend ULONG SYSTEM GetVersionSize(char *modname);
108};
109
110//SvL: This structure is placed at the end of the first page of the image (header
111// page), so we can determine the Win32Image pointer from a HINSTANCE variable
112// (which is actually the address of the win32 module)
113typedef struct
114{
115 Win32ImageBase *image;
116 ULONG magic;
117} WINIMAGE_LOOKUP;
118
119#define WINIMAGE_LOOKUPADDR(a) (WINIMAGE_LOOKUP *)((ULONG)a + PAGE_SIZE - sizeof(WINIMAGE_LOOKUP))
120
121#endif //__WINIMAGEBASE_H__
Note: See TracBrowser for help on using the repository browser.