source: trunk/tools/common/kInterfaces.h@ 5531

Last change on this file since 5531 was 5531, checked in by bird, 24 years ago

Second iteration of the kFile* classes and interfaces.

File size: 5.9 KB
Line 
1/* $Id: kInterfaces.h,v 1.2 2001-04-17 00:26:12 bird Exp $
2 *
3 * This headerfile contains interfaces for the common tools classes.
4 *
5 * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
6 *
7 * Project Odin Software License can be found in LICENSE.TXT
8 *
9 */
10
11
12#ifndef _kInterfaces_h_
13#define _kInterfaces_h_
14
15
16class kPageI;
17class kExportI;
18class kExportEntry;
19class kModuleI;
20
21
22/**
23 * Interface class (ie. virtual) which defines the interface for
24 * executables (resources and object too perhaps) files used to
25 * get and put pages.
26 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
27 */
28class kPageI
29{
30public:
31 /** @cat Get and put page methods. */
32
33 /**
34 * Get a code, data or resource page from the file.
35 * @returns Success indicator.
36 * @param pachPage Pointer to a buffer of the size of a page which
37 * will receive the page data on the specified address.
38 * @param ulAddress Page address. This will be page aligned.
39 */
40 virtual BOOL pageGet(char *pachPage, ULONG ulAddress) = 0;
41
42 /**
43 * Get a code, data or resource page from the file.
44 * @returns Success indicator.
45 * @param pachPage Pointer to a buffer of the size of a page which
46 * will receive the page data on the specified address.
47 * @param iObject Object number. (0-based)
48 * @param offObject Offset into the object.
49 * @remark Object = Section.
50 */
51 virtual BOOL pageGet(char *pachPage, int iObject, int offObject) = 0;
52
53 /**
54 * Updates or adds a code, data, or resource page to the file.
55 * @returns Success indicator.
56 * @param pachPage Pointer to a buffer of the size of a page which
57 * holds the page data.
58 * @param ulAddress Page address. This will be page aligned.
59 */
60 virtual BOOL pagePut(const char *pachPage, ULONG ulAddress) = 0;
61
62 /**
63 * Updates or adds a code, data, or resource page to the file.
64 * @returns Success indicator.
65 * @param pachPage Pointer to a buffer of the size of a page which
66 * holds the page data.
67 * @param iObject Object number. (0-based)
68 * @param offObject Offset into the object.
69 */
70 virtual BOOL pagePut(const char *pachPage, int iObject, int offObject) = 0;
71
72 /**
73 * Get pagesize for the file.
74 * @returns Pagesize in bytes.
75 */
76 virtual int pageGetPageSize() = 0;
77};
78
79
80/**
81 * ExportEntry used by the findFirstExport/findNextExport functions
82 */
83class kExportEntry
84{
85#define MAXEXPORTNAME 256
86public:
87 unsigned long ulOrdinal; /* Ordinal of export. 0 if invalid. */
88 char achName[MAXEXPORTNAME]; /* Public or exported name. */
89 char achIntName[MAXEXPORTNAME]; /* Optional. not used by PEFile */
90
91 unsigned long ulOffset; /* Offset. -1 if invalid. */
92 unsigned long iObject; /* Object number. -1 if invalid. */
93 unsigned long ulAddress; /* Address of symbol. -1 if invalid. */
94
95public:
96 /** @cat Internal use - don't mess! */
97 void * pv; /* Internal pointer. */
98};
99
100/**
101 * Interface class (ie. virtual) which defines the interface for executables
102 * (objects and libraries to perhaps) files used to enumerate exports and
103 * public exported names.
104 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
105 */
106class kExportI
107{
108public:
109 /** @cat Export enumeration methods. */
110
111 /**
112 * Find the first export/public name.
113 * @returns Success indicator.
114 * @param pExport Communication area.
115 */
116 virtual BOOL exportFindFirst(kExportEntry * pExport) = 0;
117
118 /**
119 * Find the next export/public name.
120 * @returns Success indicator.
121 * FALSE when no more exports (exportFindClose has been processed then).
122 * @param pExport Communication area which has been successfully
123 * processed by findFirstExport.
124 */
125 virtual BOOL exportFindNext(kExportEntry * pExport) = 0;
126
127 /**
128 * Frees resources associated with the communicatin area.
129 * It's not necessary to call this when exportFindNext has return FALSE.
130 * @param pExport Communication area which has been successfully
131 * processed by findFirstExport.
132 */
133 virtual void exportFindClose(kExportEntry * pExport) = 0;
134
135
136 /** @cat Export Search methods */
137
138 /**
139 * Lookup information on a spesific export given by ordinal number.
140 * @returns Success indicator.
141 * @param pExport Communication area containing export information
142 * on successful return.
143 */
144 virtual BOOL exportLookup(unsigned long ulOrdinal, kExportEntry *pExport) = 0;
145
146 /**
147 * Lookup information on a spesific export given by name.
148 * @returns Success indicator.
149 * @param pExport Communication area containing export information
150 * on successful return.
151 */
152 virtual BOOL exportLookup(const char * pszName, kExportEntry *pExport) = 0;
153};
154
155
156/**
157 * Interface class (ie. virtual) which defines the interface for executables
158 * (objects and libraries to perhaps) files used to enumerate exports and
159 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
160 */
161class kModuleI
162{
163public:
164 /** @cat Module information methods. */
165 virtual BOOL moduleGetName(char *pszBuffer, int cbBuffer = 260) = 0;
166};
167
168
169/**
170 * Interface class (ie. virtual) which defines the interface for
171 * executables files.
172 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
173 */
174class kExecutableI : public kModuleI, public kExportI
175{
176public:
177 /** @cat Executable information methods. */
178 #if 0
179 virtual BOOL execIsDLL(void) = 0;
180 virtual BOOL execIsProgram(void) = 0;
181 virtual BOOL execIsDriver(void) = 0;
182 #endif
183};
184
185#endif
Note: See TracBrowser for help on using the repository browser.