[269] | 1 | /* $Id: HandleManager.h,v 1.2 1999-07-05 07:55:09 phaller Exp $ */
|
---|
[262] | 2 |
|
---|
| 3 | /*
|
---|
| 4 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
| 5 | * Win32 Unified Handle Manager for OS/2
|
---|
| 6 | * 1998/02/11 PH Patrick Haller (haller@zebra.fh-weingarten.de)
|
---|
| 7 | *
|
---|
| 8 | * @(#) HandleManager.Cpp 1.0.0 1998/02/11 PH start
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | #ifndef _HANDLEMANAGER_H_
|
---|
| 12 | #define _HANDLEMANAGER_H_
|
---|
| 13 |
|
---|
| 14 |
|
---|
| 15 | /*****************************************************************************
|
---|
| 16 | * Remark *
|
---|
| 17 | *****************************************************************************
|
---|
| 18 |
|
---|
| 19 | 1998/02/11 PH The interface to the handle manager is twofold:
|
---|
| 20 | a) HMxxx routines to be called from the "top" from the
|
---|
| 21 | KERNEL32 stubs
|
---|
| 22 | b) the HMDeviceHandler class is actually a workaround for
|
---|
| 23 | the device driver that would handle the requests on Win32.
|
---|
| 24 | To implement a new pseudo-device, one has create a new
|
---|
| 25 | HMDeviceHandler class and link it into the table in the
|
---|
| 26 | HANDLEMANAGER.CPP file.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 |
|
---|
| 30 | /*****************************************************************************
|
---|
| 31 | * Includes *
|
---|
| 32 | *****************************************************************************/
|
---|
| 33 |
|
---|
| 34 | #ifdef _OS2WIN_H
|
---|
| 35 | #include <winos2def.h>
|
---|
| 36 | #else
|
---|
| 37 | typedef struct {
|
---|
| 38 | DWORD Internal;
|
---|
| 39 | DWORD InternalHigh;
|
---|
| 40 | DWORD Offset;
|
---|
| 41 | DWORD OffsetHigh;
|
---|
| 42 | HANDLE hEvent;
|
---|
| 43 | } OVERLAPPED, *POVERLAPPED, *LPOVERLAPPED;
|
---|
| 44 | #endif
|
---|
| 45 |
|
---|
| 46 |
|
---|
| 47 | /*****************************************************************************
|
---|
| 48 | * Defines & Macros *
|
---|
| 49 | *****************************************************************************/
|
---|
| 50 |
|
---|
| 51 | /* all handles to our special pseudo-devices are ORed with this define */
|
---|
| 52 | /* this allows us to determine quickly how to where to route requests to. */
|
---|
[269] | 53 | #define HM_HANDLE_ID 0x77770000
|
---|
[262] | 54 | #define HM_HANDLE_MASK 0x0000FFFF
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | //#define IS_HM_HANDLE(hHandle) ( (hHandle & ~HM_HANDLE_MASK) == HM_HANDLE_ID )
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | /* 1998/02/12 PH Correction of os2win.h */
|
---|
| 61 | #undef FILE_TYPE_UNKNOWN
|
---|
| 62 | #define FILE_TYPE_UNKNOWN 0x0000
|
---|
| 63 |
|
---|
| 64 | #undef FILE_TYPE_DISK
|
---|
| 65 | #define FILE_TYPE_DISK 0x0001
|
---|
| 66 |
|
---|
| 67 | #undef FILE_TYPE_CHAR
|
---|
| 68 | #define FILE_TYPE_CHAR 0x0002
|
---|
| 69 |
|
---|
| 70 | #undef FILE_TYPE_PIPE
|
---|
| 71 | #define FILE_TYPE_PIPE 0x0003
|
---|
| 72 |
|
---|
| 73 | #undef FILE_TYPE_REMOTE
|
---|
| 74 | #define FILE_TYPE_REMOTE 0x8000
|
---|
| 75 |
|
---|
| 76 | #ifndef INVALID_HANDLE_ERROR
|
---|
| 77 | #define INVALID_HANDLE_ERROR (-1)
|
---|
| 78 | #endif
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 | /*****************************************************************************
|
---|
| 82 | * Structures *
|
---|
| 83 | *****************************************************************************/
|
---|
| 84 |
|
---|
| 85 | typedef struct _HMHANDLEDATA
|
---|
| 86 | {
|
---|
| 87 | HANDLE hHMHandle; /* a copy of the handle */
|
---|
| 88 | HANDLE hWinHandle; /* a copy of the windows handle */
|
---|
| 89 |
|
---|
| 90 | DWORD dwType; /* handle type identifier */
|
---|
| 91 |
|
---|
| 92 | DWORD dwAccess; /* access mode of the handle */
|
---|
| 93 | DWORD dwShare; /* share mode of the handle */
|
---|
| 94 | DWORD dwCreation; /* dwCreationDisposition */
|
---|
| 95 | DWORD dwFlags; /* flags and attributes */
|
---|
| 96 |
|
---|
| 97 | LPVOID lpHandlerData; /* for private use of the device handler */
|
---|
| 98 | } HMHANDLEDATA, *PHMHANDLEDATA;
|
---|
| 99 |
|
---|
| 100 |
|
---|
| 101 | /*****************************************************************************
|
---|
| 102 | * Prototypes *
|
---|
| 103 | *****************************************************************************/
|
---|
| 104 |
|
---|
| 105 | DWORD HMInitialize(void); /* initialize the HandleManager */
|
---|
| 106 |
|
---|
| 107 | DWORD HMTerminate(void); /* terminate the HandleManager */
|
---|
| 108 |
|
---|
| 109 |
|
---|
| 110 | /* handle manager version of GetStdHandle, Open32 can't really help us here */
|
---|
| 111 | HANDLE HMGetStdHandle(DWORD nStdHandle);
|
---|
| 112 |
|
---|
| 113 | /* handle manager version of GetStdHandle, Open32 can't really help us here */
|
---|
| 114 | BOOL HMSetStdHandle(DWORD nStdHandle,
|
---|
| 115 | HANDLE hHandle);
|
---|
| 116 |
|
---|
| 117 |
|
---|
| 118 | /*****************************************************************************/
|
---|
| 119 | /* handle translation buffer management */
|
---|
| 120 | /* */
|
---|
| 121 | /* Since some Win32 applications rely (!) on 16-bit handles, we've got to do */
|
---|
| 122 | /* 32-bit to 16-bit and vs vsa translation here. */
|
---|
| 123 | /* Filehandle-based functions should be routed via the handlemanager instead */
|
---|
| 124 | /* of going to Open32 directly. */
|
---|
| 125 | /*****************************************************************************/
|
---|
| 126 |
|
---|
| 127 | DWORD HMHandleAllocate (PULONG phHandle16,
|
---|
| 128 | ULONG hHandle32);
|
---|
| 129 |
|
---|
| 130 | DWORD HMHandleFree (ULONG hHandle16);
|
---|
| 131 |
|
---|
| 132 | DWORD HMHandleValidate (ULONG hHandle16);
|
---|
| 133 |
|
---|
| 134 | DWORD HMHandleTranslateToWin (ULONG hHandle32,
|
---|
| 135 | PULONG phHandle16);
|
---|
| 136 |
|
---|
| 137 | DWORD HMHandleTranslateToOS2 (ULONG hHandle16,
|
---|
| 138 | PULONG hHandle32);
|
---|
| 139 |
|
---|
| 140 | DWORD HMHandleTranslateToOS2i(ULONG hHandle16);
|
---|
| 141 |
|
---|
| 142 |
|
---|
| 143 | /*****************************************************************************
|
---|
| 144 | * Forwarders *
|
---|
| 145 | *****************************************************************************/
|
---|
| 146 |
|
---|
| 147 | // enable C linkage to avoid parameter mangling
|
---|
| 148 | #ifdef __cplusplus__
|
---|
| 149 | extern "C" {
|
---|
| 150 | #endif
|
---|
| 151 |
|
---|
| 152 | HFILE HMCreateFile(LPCSTR lpFileName,
|
---|
| 153 | DWORD dwDesiredAccess,
|
---|
| 154 | DWORD dwShareMode,
|
---|
| 155 | LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
---|
| 156 | DWORD dwCreationDisposition,
|
---|
| 157 | DWORD dwFlagsAndAttributes,
|
---|
| 158 | HANDLE hTemplateFile);
|
---|
| 159 |
|
---|
| 160 | HANDLE HMOpenFile(LPCSTR lpFileName,
|
---|
| 161 | OFSTRUCT* pOFStruct,
|
---|
| 162 | UINT fuMode);
|
---|
| 163 |
|
---|
| 164 | BOOL HMCloseHandle(HANDLE hObject);
|
---|
| 165 |
|
---|
| 166 | BOOL HMReadFile(HANDLE hFile,
|
---|
| 167 | LPVOID lpBuffer,
|
---|
| 168 | DWORD nNumberOfBytesToRead,
|
---|
| 169 | LPDWORD lpNumberOfBytesRead,
|
---|
| 170 | LPOVERLAPPED lpOverlapped);
|
---|
| 171 |
|
---|
| 172 | BOOL HMWriteFile(HANDLE hFile,
|
---|
| 173 | LPCVOID lpBuffer,
|
---|
| 174 | DWORD nNumberOfBytesToWrite,
|
---|
| 175 | LPDWORD lpNumberOfBytesWritten,
|
---|
| 176 | LPOVERLAPPED lpOverlapped);
|
---|
| 177 |
|
---|
| 178 | DWORD HMGetFileType(HANDLE hFile);
|
---|
| 179 |
|
---|
| 180 | DWORD HMDeviceRequest (HANDLE hFile,
|
---|
| 181 | ULONG ulRequestCode,
|
---|
| 182 | ULONG arg1,
|
---|
| 183 | ULONG arg2,
|
---|
| 184 | ULONG arg3,
|
---|
| 185 | ULONG arg4);
|
---|
| 186 |
|
---|
| 187 | DWORD HMGetFileInformationByHandle (HANDLE hFile,
|
---|
| 188 | BY_HANDLE_FILE_INFORMATION *pHFI);
|
---|
| 189 |
|
---|
| 190 | BOOL HMSetEndOfFile (HANDLE hFile);
|
---|
| 191 |
|
---|
| 192 | BOOL HMSetFileTime (HANDLE hFile,
|
---|
| 193 | const FILETIME *pFT1,
|
---|
| 194 | const FILETIME *pFT2,
|
---|
| 195 | const FILETIME *pFT3);
|
---|
| 196 |
|
---|
| 197 | DWORD HMGetFileSize (HANDLE hFile,
|
---|
| 198 | PDWORD pSize);
|
---|
| 199 |
|
---|
| 200 | DWORD HMSetFilePointer (HANDLE hFile,
|
---|
| 201 | LONG lDistanceToMove,
|
---|
| 202 | PLONG lpDistanceToMoveHigh,
|
---|
| 203 | DWORD dwMoveMethod);
|
---|
| 204 |
|
---|
| 205 | BOOL HMLockFile (HFILE hFile,
|
---|
| 206 | DWORD arg2,
|
---|
| 207 | DWORD arg3,
|
---|
| 208 | DWORD arg4,
|
---|
| 209 | DWORD arg5);
|
---|
| 210 |
|
---|
| 211 | DWORD HMLockFileEx(HANDLE hFile,
|
---|
| 212 | DWORD dwFlags,
|
---|
| 213 | DWORD dwReserved,
|
---|
| 214 | DWORD nNumberOfBytesToLockLow,
|
---|
| 215 | DWORD nNumberOfBytesToLockHigh,
|
---|
| 216 | LPOVERLAPPED lpOverlapped);
|
---|
| 217 |
|
---|
| 218 | BOOL HMUnlockFile (HFILE hFile,
|
---|
| 219 | DWORD arg2,
|
---|
| 220 | DWORD arg3,
|
---|
| 221 | DWORD arg4,
|
---|
| 222 | DWORD arg5);
|
---|
| 223 |
|
---|
| 224 | BOOL HMUnlockFileEx(HANDLE hFile,
|
---|
| 225 | DWORD dwFlags,
|
---|
| 226 | DWORD dwReserved,
|
---|
| 227 | DWORD nNumberOfBytesToLockLow,
|
---|
| 228 | DWORD nNumberOfBytesToLockHigh,
|
---|
| 229 | LPOVERLAPPED lpOverlapped);
|
---|
| 230 |
|
---|
| 231 |
|
---|
| 232 | #ifdef __cplusplus__
|
---|
| 233 | }
|
---|
| 234 | #endif
|
---|
| 235 |
|
---|
| 236 | #endif /* _HANDLEMANAGER_H_ */
|
---|