source: trunk/src/kernel32/hmopen32.cpp

Last change on this file was 22024, checked in by dmik, 13 years ago

kernel32: Fix inverted return values in dummy HMDeviceHandler implementations.

This in particular affected GetFileInformationByHandle and other APIs. Some applications
(like Flash 10.1+) could be completely confused by the fact that the unimplemented API
returns success.

File size: 8.7 KB
Line 
1/* $Id: hmopen32.cpp,v 1.30 2003-02-04 11:28:59 sandervl Exp $ */
2
3/*
4 * Project Odin Software License can be found in LICENSE.TXT
5 * Win32 Unified Handle Manager for OS/2
6 */
7
8
9/*****************************************************************************
10 * Remark *
11 *****************************************************************************
12 */
13
14#define DEBUG_LOCAL
15
16#ifdef DEBUG_LOCAL
17# define dprintfl(a) dprintf(a)
18#else
19inline void ignore_dprintf(...){}
20# define dprintfl(a) ignore_dprintf(a)
21#endif
22
23/*****************************************************************************
24 * Includes *
25 *****************************************************************************/
26
27#include <os2win.h>
28#include <string.h>
29#include "HandleManager.h"
30#include "HMOpen32.h"
31#include "mmap.h"
32
33#define DBG_LOCALLOG DBG_hmopen32
34#include "dbglocal.h"
35
36/*****************************************************************************
37 * Defines *
38 *****************************************************************************/
39
40
41/*****************************************************************************
42 * Structures *
43 *****************************************************************************/
44
45/*****************************************************************************
46 * Name : HMDeviceOpen32Class::_DeviceRequest
47 * Purpose : entry method for special request functions
48 * Parameters: ULONG ulRequestCode
49 * various parameters as required
50 * Variables :
51 * Result :
52 * Remark : the standard behaviour is to return an error code for non-
53 * existant request codes
54 * Status :
55 *
56 * Author : Patrick Haller [Wed, 1998/02/11 20:44]
57 *****************************************************************************/
58DWORD HMDeviceOpen32Class::_DeviceRequest (PHMHANDLEDATA pHMHandleData,
59 ULONG ulRequestCode,
60 ULONG arg1,
61 ULONG arg2,
62 ULONG arg3,
63 ULONG arg4)
64{
65 dprintfl(("KERNEL32: HandleManager::Open32::_DeviceRequest %s(%08x,%08x) - stub?\n",
66 lpHMDeviceName,
67 pHMHandleData,
68 ulRequestCode));
69
70 SetLastError(ERROR_INVALID_FUNCTION);
71 return FALSE;
72}
73
74/*****************************************************************************
75 * Name : DWORD HMDeviceOpen32Class::CloseHandle
76 * Purpose : close the handle
77 * Parameters: PHMHANDLEDATA pHMHandleData
78 * Variables :
79 * Result : API returncode
80 * Remark :
81 * Status :
82 *
83 * Author : Patrick Haller [Wed, 1998/02/11 20:44]
84 *****************************************************************************/
85
86BOOL HMDeviceOpen32Class::CloseHandle(PHMHANDLEDATA pHMHandleData)
87{
88 BOOL bRC;
89
90 dprintfl(("KERNEL32: HandleManager::Open32::CloseHandle(%08x) %p\n",
91 pHMHandleData, pHMHandleData->hHMHandle));
92
93 bRC = O32_CloseHandle(pHMHandleData->hHMHandle);
94
95 dprintfl(("KERNEL32: HandleManager::Open32::CloseHandle returned %08xh\n",
96 bRC));
97
98 return bRC;
99}
100
101/*****************************************************************************
102 * Name : HMDeviceHandler::DuplicateHandle
103 * Purpose : dummy version
104 * Parameters:
105 * various parameters as required
106 * Variables :
107 * Result :
108 * Remark : the standard behaviour is to return an error code for non-
109 * existant request codes
110 * Status :
111 *
112 * Author : Patrick Haller [Wed, 1998/02/11 20:44]
113 *****************************************************************************/
114BOOL HMDeviceOpen32Class::DuplicateHandle(HANDLE srchandle, PHMHANDLEDATA pHMHandleData, HANDLE srcprocess,
115 PHMHANDLEDATA pHMSrcHandle,
116 HANDLE destprocess,
117 DWORD fdwAccess,
118 BOOL fInherit,
119 DWORD fdwOptions,
120 DWORD fdwOdinOptions)
121{
122 BOOL rc;
123
124 dprintf(("KERNEL32:HandleManager::Open32::DuplicateHandle %s(%08x,%08x,%08x,%08x,%08x)\n",
125 lpHMDeviceName, pHMHandleData, srcprocess, pHMSrcHandle->hHMHandle, destprocess));
126
127 pHMHandleData->hHMHandle = 0;
128 rc = O32_DuplicateHandle(srcprocess, pHMSrcHandle->hHMHandle, destprocess, &pHMHandleData->hHMHandle, fdwAccess, fInherit, fdwOptions);
129
130 return rc;
131}
132
133/*****************************************************************************
134 * Name : DWORD HMDeviceOpen32Class::GetFileType
135 * Purpose : determine the handle type
136 * Parameters: PHMHANDLEDATA pHMHandleData
137 * Variables :
138 * Result : API returncode
139 * Remark :
140 * Status :
141 *
142 * Author : Patrick Haller [Wed, 1998/02/11 20:44]
143 *****************************************************************************/
144
145DWORD HMDeviceOpen32Class::GetFileType(PHMHANDLEDATA pHMHandleData)
146{
147 dprintfl(("KERNEL32: HandleManager::Open32::GetFileType %s(%08x)\n",
148 lpHMDeviceName,
149 pHMHandleData));
150
151 return O32_GetFileType(pHMHandleData->hHMHandle);
152}
153
154
155/*****************************************************************************
156 * Name : BOOL HMDeviceOpen32Class::GetFileInformationByHandle
157 * Purpose : determine the handle type
158 * Parameters: PHMHANDLEDATA pHMHandleData
159 * BY_HANDLE_FILE_INFORMATION* pHFI
160 * Variables :
161 * Result : API returncode
162 * Remark :
163 * Status :
164 *
165 * Author : Patrick Haller [Wed, 1999/06/17 20:44]
166 *****************************************************************************/
167
168BOOL HMDeviceOpen32Class::GetFileInformationByHandle(PHMHANDLEDATA pHMHandleData,
169 BY_HANDLE_FILE_INFORMATION* pHFI)
170{
171 dprintfl(("KERNEL32: HandleManager::Open32::GetFileInformationByHandle %s(%08xh,%08xh)\n",
172 lpHMDeviceName,
173 pHMHandleData,
174 pHFI));
175
176 return O32_GetFileInformationByHandle(pHMHandleData->hHMHandle,
177 pHFI);
178}
179
180/*****************************************************************************
181 * Name : DWORD HMDeviceOpen32Class::WaitForSingleObject
182 * Purpose : object synchronization
183 * Parameters: PHMHANDLEDATA pHMHandleData
184 * DWORD dwTimeout
185 * Variables :
186 * Result : API returncode
187 * Remark :
188 * Status :
189 *
190 * Author : Patrick Haller [Wed, 1999/06/17 20:44]
191 *****************************************************************************/
192
193DWORD HMDeviceOpen32Class::WaitForSingleObject(PHMHANDLEDATA pHMHandleData,
194 DWORD dwTimeout)
195{
196 DWORD rc;
197#ifdef DEBUG
198 DWORD starttime, endtime;
199#endif
200
201 dprintfl(("KERNEL32: HandleManager::Open32::WaitForSingleObject(%08xh %08xh)\n",
202 pHMHandleData->hHMHandle,
203 dwTimeout));
204
205#ifdef DEBUG
206 if(dwTimeout) {
207 starttime = O32_GetCurrentTime();
208 }
209#endif
210 rc = (O32_WaitForSingleObject(pHMHandleData->hHMHandle,
211 dwTimeout));
212#ifdef DEBUG
213 if(dwTimeout) {
214 endtime = O32_GetCurrentTime();
215 dprintf2(("KERNEL32: HandleManager::WaitForSingleObject %x %x delta = %x (rc=%x)", pHMHandleData->hHMHandle, dwTimeout, endtime - starttime, rc));
216 }
217 else dprintf2(("KERNEL32: HandleManager::WaitForSingleObject %x 0 rc=%x", pHMHandleData->hHMHandle, rc));
218#endif
219 return rc;
220}
221
222
223/*****************************************************************************
224 * Name : DWORD HMDeviceOpen32Class::WaitForSingleObjectEx
225 * Purpose : object synchronization
226 * Parameters: PHMHANDLEDATA pHMHandleData
227 * DWORD dwTimeout
228 * BOOL fAlertable
229 * Variables :
230 * Result : API returncode
231 * Remark :
232 * Status :
233 *
234 * Author : Patrick Haller [Wed, 1999/06/17 20:44]
235 *****************************************************************************/
236
237DWORD HMDeviceOpen32Class::WaitForSingleObjectEx(PHMHANDLEDATA pHMHandleData,
238 DWORD dwTimeout,
239 BOOL fAlertable)
240{
241 dprintfl(("KERNEL32: HandleManager::Open32::WaitForSingleObjectEx(%08xh,%08h,%08xh) not implemented correctly.\n",
242 pHMHandleData->hHMHandle,
243 dwTimeout,
244 fAlertable));
245
246 //@@@PH: WARNING mapped to WaitForSingleObject simply. fAlertable missing!
247 return (O32_WaitForSingleObject(pHMHandleData->hHMHandle,
248 dwTimeout));
249}
250
Note: See TracBrowser for help on using the repository browser.