source: trunk/src/kernel32/HandleManager.h@ 73

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

* empty log message *

File size: 9.7 KB
Line 
1/*
2 *
3 * Project Odin Software License can be found in LICENSE.TXT
4 *
5 */
6/*
7 * Win32 Unified Handle Manager for OS/2
8 *
9 * 1998/02/11 PH Patrick Haller (haller@zebra.fh-weingarten.de)
10 *
11 * @(#) HandleManager.Cpp 1.0.0 1998/02/11 PH start
12 */
13
14#ifndef _HANDLEMANAGER_H_
15#define _HANDLEMANAGER_H_
16
17
18/*****************************************************************************
19 * Remark *
20 *****************************************************************************
21
22 1998/02/11 PH The interface to the handle manager is twofold:
23 a) HMxxx routines to be called from the "top" from the
24 KERNEL32 stubs
25 b) the HMDeviceHandler class is actually a workaround for
26 the device driver that would handle the requests on Win32.
27 To implement a new pseudo-device, one has create a new
28 HMDeviceHandler class and link it into the table in the
29 HANDLEMANAGER.CPP file.
30 */
31
32
33/*****************************************************************************
34 * Includes *
35 *****************************************************************************/
36
37#ifdef _OS2WIN_H
38#include <winos2def.h>
39#else
40typedef struct {
41 DWORD Internal;
42 DWORD InternalHigh;
43 DWORD Offset;
44 DWORD OffsetHigh;
45 HANDLE hEvent;
46} OVERLAPPED, *POVERLAPPED, *LPOVERLAPPED;
47#endif
48
49
50/*****************************************************************************
51 * Defines & Macros *
52 *****************************************************************************/
53
54 /* all handles to our special pseudo-devices are ORed with this define */
55 /* this allows us to determine quickly how to where to route requests to. */
56#define HM_HANDLE_ID 0xDEAD0000
57#define HM_HANDLE_MASK 0x0000FFFF
58
59
60#define IS_HM_HANDLE(hHandle) ( (hHandle & ~HM_HANDLE_MASK) == HM_HANDLE_ID )
61
62
63 /* 1998/02/12 PH Correction of os2win.h */
64#undef FILE_TYPE_UNKNOWN
65#define FILE_TYPE_UNKNOWN 0x0000
66
67#undef FILE_TYPE_DISK
68#define FILE_TYPE_DISK 0x0001
69
70#undef FILE_TYPE_CHAR
71#define FILE_TYPE_CHAR 0x0002
72
73#undef FILE_TYPE_PIPE
74#define FILE_TYPE_PIPE 0x0003
75
76#undef FILE_TYPE_REMOTE
77#define FILE_TYPE_REMOTE 0x8000
78
79
80
81/*****************************************************************************
82 * Structures *
83 *****************************************************************************/
84
85typedef struct _HMHANDLEDATA
86{
87 HANDLE hHandle; /* a copy of the handle */
88
89 DWORD dwType; /* handle type identifier */
90
91 DWORD dwAccess; /* access mode of the handle */
92 DWORD dwShare; /* share mode of the handle */
93 DWORD dwCreation; /* dwCreationDisposition */
94 DWORD dwFlags; /* flags and attributes */
95
96 LPVOID lpHandlerData; /* for private use of the device handler */
97} HMHANDLEDATA, *PHMHANDLEDATA;
98
99
100#ifdef __cplusplus
101class HMDeviceHandler
102{
103 /***************************************************************************
104 * The following methods are called by the handle manager request router. *
105 * They are exact replacements for the corresponding Win32 calls. *
106 ***************************************************************************/
107
108public:
109 LPCSTR lpHMDeviceName; /* a reference to the device name */
110
111 HMDeviceHandler(LPCSTR lpDeviceName); /* constructor with device name */
112
113
114 /***********************************
115 * handle generic standard methods *
116 ***********************************/
117
118 /* this is a special internal method to handle non-standard requests */
119 /* such as GetConsoleMode() for console devices */
120 virtual DWORD _DeviceRequest (PHMHANDLEDATA pHMHandleData,
121 ULONG ulRequestCode,
122 ULONG arg1,
123 ULONG arg2,
124 ULONG arg3,
125 ULONG arg4);
126
127 /* this is a handler method for calls to CreateFile() */
128 virtual DWORD CreateFile (LPCSTR lpFileName,
129 PHMHANDLEDATA pHMHandleData,
130 PVOID lpSecurityAttributes,
131 PHMHANDLEDATA pHMHandleDataTemplate);
132
133 /* this is a handler method for calls to CloseHandle() */
134 virtual DWORD CloseHandle(PHMHANDLEDATA pHMHandleData);
135
136 /* this is a handler method for calls to ReadFile() */
137 virtual DWORD ReadFile (PHMHANDLEDATA pHMHandleData,
138 LPCVOID lpBuffer,
139 DWORD nNumberOfBytesToRead,
140 LPDWORD lpNumberOfBytesRead,
141 LPOVERLAPPED lpOverlapped);
142
143 /* this is a handler method for calls to WriteFile() */
144 virtual DWORD WriteFile (PHMHANDLEDATA pHMHandleData,
145 LPCVOID lpBuffer,
146 DWORD nNumberOfBytesToWrite,
147 LPDWORD lpNumberOfBytesWritten,
148 LPOVERLAPPED lpOverlapped);
149
150 /* this is a handler method for calls to GetFileType() */
151 virtual DWORD GetFileType (PHMHANDLEDATA pHMHandleData);
152};
153
154#endif
155
156
157/*****************************************************************************
158 * Prototypes *
159 *****************************************************************************/
160
161DWORD HMInitialize(void); /* initialize the HandleManager */
162
163DWORD HMTerminate(void); /* terminate the HandleManager */
164
165
166#ifdef __cplusplus
167 /* register a new device with the handle manager */
168DWORD HMDeviceRegister(PSZ pszDeviceName, HMDeviceHandler *pDeviceHandler);
169#endif
170
171
172
173 /* handle manager version of GetStdHandle, Open32 can't really help us here */
174HANDLE HMGetStdHandle(DWORD nStdHandle);
175
176 /* handle manager version of GetStdHandle, Open32 can't really help us here */
177BOOL HMSetStdHandle(DWORD nStdHandle,
178 HANDLE hHandle);
179
180 /* this is a handler method for calls to CreateFile() */
181HANDLE HMCreateFile (LPCSTR lpFileName,
182 DWORD dwDesiredAccess,
183 DWORD dwShareMode,
184 PVOID lpSecurityAttributes,
185 DWORD dwCreationDisposition,
186 DWORD dwFlagsAndAttributes,
187 HANDLE hTemplateFile);
188
189 /* this is a handler method for calls to CloseHandle() */
190BOOL HMCloseHandle(HANDLE hObject);
191
192 /* this is a handler method for calls to ReadFile() */
193BOOL HMReadFile (HANDLE hFile,
194 LPCVOID lpBuffer,
195 DWORD nNumberOfBytesToRead,
196 LPDWORD lpNumberOfBytesRead,
197 LPOVERLAPPED lpOverlapped);
198
199 /* this is a handler method for calls to WriteFile() */
200BOOL HMWriteFile (HANDLE hFile,
201 LPCVOID lpBuffer,
202 DWORD nNumberOfBytesToWrite,
203 LPDWORD lpNumberOfBytesWritten,
204 LPOVERLAPPED lpOverlapped);
205
206 /* this is a handler method for calls to GetFileType() */
207DWORD HMGetFileType(HANDLE hFile);
208
209 /* this is for special non-standard device I/O */
210DWORD HMDeviceRequest (HANDLE hFile,
211 ULONG ulRequestCode,
212 ULONG arg1,
213 ULONG arg2,
214 ULONG arg3,
215 ULONG arg4);
216
217
218/*****************************************************************************/
219/* handle translation buffer management */
220/* */
221/* Since some Win32 applications rely (!) on 16-bit handles, we've got to do */
222/* 32-bit to 16-bit and vs vsa translation here. */
223/* Filehandle-based functions should be routed via the handlemanager instead */
224/* of going to Open32 directly. */
225/*****************************************************************************/
226
227DWORD HMHandleAllocate (PULONG phHandle16,
228 ULONG hHandle32);
229
230DWORD HMHandleFree (ULONG hHandle16);
231
232DWORD HMHandleValidate (ULONG hHandle16);
233
234DWORD HMHandleTranslateToWin (ULONG hHandle32,
235 PULONG phHandle16);
236
237DWORD HMHandleTranslateToOS2 (ULONG hHandle16,
238 PULONG hHandle32);
239
240DWORD HMHandleTranslateToOS2i(ULONG hHandle16);
241
242
243/*****************************************************************************
244 * Forwarders *
245 *****************************************************************************/
246
247
248#endif /* _HANDLEMANAGER_H_ */
Note: See TracBrowser for help on using the repository browser.