1 | /* $Id: kobjects.cpp,v 1.9 2000-02-16 14:25:41 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
5 | * Win32 compatibility file functions for OS/2
|
---|
6 | * Copyright 1998 Sander van Leeuven
|
---|
7 | * Copyright 1998 Patrick Haller
|
---|
8 | * Copyright 1998 Peter Fitzsimmons
|
---|
9 | * Copyright 1998 Knut St. Osmundsen
|
---|
10 | */
|
---|
11 |
|
---|
12 |
|
---|
13 | /*****************************************************************************
|
---|
14 | * Includes *
|
---|
15 | *****************************************************************************/
|
---|
16 |
|
---|
17 | #include <odin.h>
|
---|
18 | #include <odinwrap.h>
|
---|
19 | #include <os2sel.h>
|
---|
20 |
|
---|
21 | #include <os2win.h>
|
---|
22 | #include "misc.h"
|
---|
23 | #include "handlemanager.h"
|
---|
24 |
|
---|
25 | #define DBG_LOCALLOG DBG_kobjects
|
---|
26 | #include "dbglocal.h"
|
---|
27 |
|
---|
28 |
|
---|
29 | ODINDEBUGCHANNEL(KERNEL32-KOBJECTS)
|
---|
30 |
|
---|
31 |
|
---|
32 | // REMARK: THIS IS IN PREPARATION FOR HANDLEMANAGER SUPPORT (PH) !!
|
---|
33 | //#define HMCreateEvent O32_CreateEvent
|
---|
34 | //#define HMCreateMutex O32_CreateMutex
|
---|
35 | //#define HMCreateSemaphore O32_CreateSemaphore
|
---|
36 | //#define HMSetEvent O32_SetEvent
|
---|
37 | //#define HMReleaseMutex O32_ReleaseMutex
|
---|
38 | //#define HMWaitForSingleObject O32_WaitForSingleObject
|
---|
39 | //#define HMWaitForSingleObjectEx O32_WaitForSingleObjectEx
|
---|
40 | //#define HMGetOverlappedResult O32_GetOverlappedResult
|
---|
41 | //#define HMOpenEvent O32_OpenEvent
|
---|
42 | //#define HMOpenMutex O32_OpenMutex
|
---|
43 | //#define HMOpenSemaphore O32_OpenSemaphore
|
---|
44 | //#define HMPulseEvent O32_PulseEvent
|
---|
45 | //#define HMReleaseSemaphore O32_ReleaseSemaphore
|
---|
46 | //#define HMResetEvent O32_ResetEvent
|
---|
47 | //#define HMWaitForMultipleObjects O32_WaitForMultipleObjects
|
---|
48 | //#define HMWaitForMultipleObjectsEx O32_WaitForMultipleObjectsEx
|
---|
49 | //#define HMFlushFileBuffers O32_FlushFileBuffers
|
---|
50 | #define HMSetHandleCount O32_SetHandleCount
|
---|
51 | #define HMGetHandleCount O32_GetHandleCount
|
---|
52 | //#define HMDuplicateHandle O32_DuplicateHandle
|
---|
53 |
|
---|
54 |
|
---|
55 |
|
---|
56 | /*****************************************************************************
|
---|
57 | * Defines *
|
---|
58 | *****************************************************************************/
|
---|
59 |
|
---|
60 | /* this define enables certain less important debug messages */
|
---|
61 | //#define DEBUG_LOCAL 1
|
---|
62 |
|
---|
63 |
|
---|
64 |
|
---|
65 | /*****************************************************************************
|
---|
66 | * Name : BOOL CreateEventA
|
---|
67 | * Purpose : forward call to Open32
|
---|
68 | * Parameters:
|
---|
69 | * Variables :
|
---|
70 | * Result :
|
---|
71 | * Remark :
|
---|
72 | * Status :
|
---|
73 | *
|
---|
74 | * Author : Patrick Haller [Fri, 1998/06/12 03:44]
|
---|
75 | *****************************************************************************/
|
---|
76 |
|
---|
77 | ODINFUNCTION4(HANDLE, CreateEventA,
|
---|
78 | LPSECURITY_ATTRIBUTES, lpsa,
|
---|
79 | BOOL, fManualReset,
|
---|
80 | BOOL, fInitialState,
|
---|
81 | LPCTSTR, lpszEventName)
|
---|
82 | {
|
---|
83 | return(HMCreateEvent(lpsa, /* create event semaphore */
|
---|
84 | fManualReset,
|
---|
85 | fInitialState,
|
---|
86 | lpszEventName));
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 | /*****************************************************************************
|
---|
91 | * Name : BOOL CreateEventW
|
---|
92 | * Purpose : forward call to Open32
|
---|
93 | * Parameters:
|
---|
94 | * Variables :
|
---|
95 | * Result :
|
---|
96 | * Remark : handle translation is done in CreateEventA
|
---|
97 | * Status :
|
---|
98 | *
|
---|
99 | * Author : Patrick Haller [Fri, 1998/06/12 03:44]
|
---|
100 | *****************************************************************************/
|
---|
101 |
|
---|
102 | ODINFUNCTION4(HANDLE, CreateEventW,
|
---|
103 | LPSECURITY_ATTRIBUTES, arg1,
|
---|
104 | BOOL, arg2,
|
---|
105 | BOOL, arg3,
|
---|
106 | LPCWSTR, arg4)
|
---|
107 | {
|
---|
108 | HANDLE rc;
|
---|
109 | char *astring;
|
---|
110 |
|
---|
111 | if (arg4 != NULL) // support for unnamed semaphores
|
---|
112 | astring = UnicodeToAsciiString((LPWSTR)arg4);
|
---|
113 | else
|
---|
114 | astring = NULL;
|
---|
115 |
|
---|
116 | dprintf(("KERNEL32: CreateEventW(%s)\n",
|
---|
117 | astring));
|
---|
118 |
|
---|
119 | rc = HMCreateEvent(arg1,
|
---|
120 | arg2,
|
---|
121 | arg3,
|
---|
122 | astring);
|
---|
123 |
|
---|
124 | if (astring != NULL)
|
---|
125 | FreeAsciiString(astring);
|
---|
126 |
|
---|
127 | return(rc);
|
---|
128 | }
|
---|
129 |
|
---|
130 |
|
---|
131 | /*****************************************************************************
|
---|
132 | * Name : BOOL CreateMutexA
|
---|
133 | * Purpose : forward call to Open32
|
---|
134 | * Parameters:
|
---|
135 | * Variables :
|
---|
136 | * Result :
|
---|
137 | * Remark : handle translation is done in CreateMutexA
|
---|
138 | * Status :
|
---|
139 | *
|
---|
140 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
141 | *****************************************************************************/
|
---|
142 |
|
---|
143 | ODINFUNCTION3(HANDLE, CreateMutexA,
|
---|
144 | LPSECURITY_ATTRIBUTES, lpsa,
|
---|
145 | BOOL, fInitialOwner,
|
---|
146 | LPCTSTR, lpszMutexName)
|
---|
147 | {
|
---|
148 | dprintf(("KERNEL32: CreateMutexA(%s)\n",
|
---|
149 | lpszMutexName));
|
---|
150 |
|
---|
151 | return(HMCreateMutex(lpsa,
|
---|
152 | fInitialOwner,
|
---|
153 | lpszMutexName));
|
---|
154 | }
|
---|
155 |
|
---|
156 |
|
---|
157 | /*****************************************************************************
|
---|
158 | * Name : BOOL CreateMutexW
|
---|
159 | * Purpose : forward call to Open32
|
---|
160 | * Parameters:
|
---|
161 | * Variables :
|
---|
162 | * Result :
|
---|
163 | * Remark : handle translation is done in CreateMutexW
|
---|
164 | * Status :
|
---|
165 | *
|
---|
166 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
167 | *****************************************************************************/
|
---|
168 |
|
---|
169 | ODINFUNCTION3(HANDLE, CreateMutexW,
|
---|
170 | PSECURITY_ATTRIBUTES, arg1,
|
---|
171 | BOOL, arg2,
|
---|
172 | LPCWSTR, arg3)
|
---|
173 | {
|
---|
174 | HANDLE rc;
|
---|
175 | char *astring;
|
---|
176 |
|
---|
177 | if (arg3 != NULL) // support for unnamed mutexes
|
---|
178 | astring = UnicodeToAsciiString((LPWSTR)arg3);
|
---|
179 | else
|
---|
180 | astring = NULL;
|
---|
181 |
|
---|
182 | dprintf(("KERNEL32: CreateMutexW(%s)\n",
|
---|
183 | astring));
|
---|
184 |
|
---|
185 | rc = HMCreateMutex(arg1,
|
---|
186 | arg2,
|
---|
187 | astring);
|
---|
188 |
|
---|
189 | if (astring != NULL)
|
---|
190 | FreeAsciiString(astring);
|
---|
191 |
|
---|
192 | return(rc);
|
---|
193 | }
|
---|
194 |
|
---|
195 |
|
---|
196 | /*****************************************************************************
|
---|
197 | * Name : BOOL ReleaseMutex
|
---|
198 | * Purpose : forward call to Open32
|
---|
199 | * Parameters:
|
---|
200 | * Variables :
|
---|
201 | * Result :
|
---|
202 | * Remark : handle translation is done in ReleaseMutex
|
---|
203 | * Status :
|
---|
204 | *
|
---|
205 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
206 | *****************************************************************************/
|
---|
207 |
|
---|
208 | ODINFUNCTION1(BOOL, ReleaseMutex,
|
---|
209 | HANDLE, mutex)
|
---|
210 | {
|
---|
211 | return(HMReleaseMutex(mutex));
|
---|
212 | }
|
---|
213 |
|
---|
214 |
|
---|
215 | /*****************************************************************************
|
---|
216 | * Name : BOOL SetEvent
|
---|
217 | * Purpose : forward call to Open32
|
---|
218 | * Parameters:
|
---|
219 | * Variables :
|
---|
220 | * Result :
|
---|
221 | * Remark : handle translation is done in SetEvent
|
---|
222 | * Status :
|
---|
223 | *
|
---|
224 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
225 | *****************************************************************************/
|
---|
226 |
|
---|
227 | ODINFUNCTION1(BOOL, SetEvent,
|
---|
228 | HANDLE, hEvent)
|
---|
229 | {
|
---|
230 | return(HMSetEvent(hEvent));
|
---|
231 | }
|
---|
232 |
|
---|
233 |
|
---|
234 | /*****************************************************************************
|
---|
235 | * Name : BOOL WaitForSingleObject
|
---|
236 | * Purpose : forward call to Open32
|
---|
237 | * Parameters:
|
---|
238 | * Variables :
|
---|
239 | * Result :
|
---|
240 | * Remark : handle translation is done in WaitForSingleObject
|
---|
241 | * Status :
|
---|
242 | *
|
---|
243 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
244 | *****************************************************************************/
|
---|
245 |
|
---|
246 | ODINFUNCTION2(DWORD, WaitForSingleObject,
|
---|
247 | HANDLE, hObject,
|
---|
248 | DWORD, timeout)
|
---|
249 | {
|
---|
250 | return(HMWaitForSingleObject(hObject,
|
---|
251 | timeout));
|
---|
252 | }
|
---|
253 |
|
---|
254 |
|
---|
255 | /*****************************************************************************
|
---|
256 | * Name : DWORD OS2WaitForSingleObjectEx
|
---|
257 | * Purpose : The WaitForSingleObjectEx function is an extended wait function
|
---|
258 | * that can be used to perform an alertable wait. This enables the
|
---|
259 | * function to return when the system queues an I/O completion
|
---|
260 | * routine to be executed by the calling thread. The function also
|
---|
261 | * returns when the specified object is in the signaled state or
|
---|
262 | * when the time-out interval elapses.
|
---|
263 | * Parameters: HANDLE hObject handle of object to wait for
|
---|
264 | * DWORD dwTimeout time-out interval in milliseconds
|
---|
265 | * BOOL fAlertable alertable wait flag
|
---|
266 | * Variables :
|
---|
267 | * Result : 0xFFFFFFFF in case of error
|
---|
268 | * Remark : only really required for async I/O
|
---|
269 | * Status : UNTESTED STUB
|
---|
270 | *
|
---|
271 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
272 | *****************************************************************************/
|
---|
273 |
|
---|
274 | ODINFUNCTION3(DWORD, WaitForSingleObjectEx,
|
---|
275 | HANDLE, hObject,
|
---|
276 | DWORD, dwTimeout,
|
---|
277 | BOOL, fAlertable)
|
---|
278 | {
|
---|
279 | dprintf(("Kernel32: WaitForSingleObjectEx(%08xh,%08xh,%08xh) not implemented correctly.\n",
|
---|
280 | hObject,
|
---|
281 | dwTimeout,
|
---|
282 | fAlertable));
|
---|
283 |
|
---|
284 | return(HMWaitForSingleObjectEx(hObject,
|
---|
285 | dwTimeout,
|
---|
286 | fAlertable));
|
---|
287 | }
|
---|
288 |
|
---|
289 |
|
---|
290 | /*****************************************************************************
|
---|
291 | * Name : BOOL FlushFileBuffers
|
---|
292 | * Purpose : forward call to Open32
|
---|
293 | * Parameters:
|
---|
294 | * Variables :
|
---|
295 | * Result :
|
---|
296 | * Remark : handle translation is done in FlushFileBuffers
|
---|
297 | * Status :
|
---|
298 | *
|
---|
299 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
300 | *****************************************************************************/
|
---|
301 |
|
---|
302 | ODINFUNCTION1(BOOL, FlushFileBuffers,
|
---|
303 | HANDLE, hFile)
|
---|
304 | {
|
---|
305 | return(HMFlushFileBuffers(hFile));
|
---|
306 | }
|
---|
307 |
|
---|
308 |
|
---|
309 | /*****************************************************************************
|
---|
310 | * Name : UINT SetHandleCount
|
---|
311 | * Purpose : forward call to Open32
|
---|
312 | * Parameters:
|
---|
313 | * Variables :
|
---|
314 | * Result :
|
---|
315 | * Remark : handle translation is done in SetHandleCount
|
---|
316 | * Status :
|
---|
317 | *
|
---|
318 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
319 | *****************************************************************************/
|
---|
320 |
|
---|
321 | ODINFUNCTION1(UINT, SetHandleCount,
|
---|
322 | UINT, cHandles)
|
---|
323 | {
|
---|
324 | return(HMSetHandleCount(cHandles));
|
---|
325 | }
|
---|
326 |
|
---|
327 |
|
---|
328 | /*****************************************************************************
|
---|
329 | * Name : BOOL DuplicateHandle
|
---|
330 | * Purpose : forward call to Open32
|
---|
331 | * Parameters:
|
---|
332 | * Variables :
|
---|
333 | * Result :
|
---|
334 | * Remark : handle translation is done in DuplicateHandle
|
---|
335 | * Status :
|
---|
336 | *
|
---|
337 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
338 | *****************************************************************************/
|
---|
339 |
|
---|
340 | //******************************************************************************
|
---|
341 | //SvL: 24-6-'97 - Added
|
---|
342 | //SvL: 28-6-'97: Fix for timeSetEvent in Red Alert Map Editor
|
---|
343 | //******************************************************************************
|
---|
344 | ODINFUNCTION7(BOOL, DuplicateHandle,
|
---|
345 | HANDLE, srcprocess,
|
---|
346 | HANDLE, srchandle,
|
---|
347 | HANDLE, destprocess,
|
---|
348 | PHANDLE, desthandle,
|
---|
349 | DWORD, arg5,
|
---|
350 | BOOL, arg6,
|
---|
351 | DWORD, arg7)
|
---|
352 | {
|
---|
353 | BOOL rc;
|
---|
354 |
|
---|
355 | rc = HMDuplicateHandle(srcprocess,
|
---|
356 | srchandle,
|
---|
357 | destprocess,
|
---|
358 | desthandle,
|
---|
359 | arg5,
|
---|
360 | arg6,
|
---|
361 | arg7);
|
---|
362 | //@@@PH: (temporary) fix for non-HandleManager handles
|
---|
363 | if (rc == FALSE)
|
---|
364 | rc = O32_DuplicateHandle(srcprocess,
|
---|
365 | srchandle,
|
---|
366 | destprocess,
|
---|
367 | desthandle,
|
---|
368 | arg5,
|
---|
369 | arg6,
|
---|
370 | arg7);
|
---|
371 |
|
---|
372 | return(rc);
|
---|
373 | }
|
---|
374 |
|
---|
375 |
|
---|
376 | /*****************************************************************************
|
---|
377 | * Name : BOOL CreateSemaphoreA
|
---|
378 | * Purpose : forward call to Open32
|
---|
379 | * Parameters:
|
---|
380 | * Variables :
|
---|
381 | * Result :
|
---|
382 | * Remark : handle translation is done in CreateSemaphoreA
|
---|
383 | * Status :
|
---|
384 | *
|
---|
385 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
386 | *****************************************************************************/
|
---|
387 |
|
---|
388 | ODINFUNCTION4(HANDLE, CreateSemaphoreA,
|
---|
389 | LPSECURITY_ATTRIBUTES, arg1,
|
---|
390 | LONG, arg2,
|
---|
391 | LONG, arg3,
|
---|
392 | LPCSTR, arg4)
|
---|
393 | {
|
---|
394 | return HMCreateSemaphore(arg1,
|
---|
395 | arg2,
|
---|
396 | arg3,
|
---|
397 | (LPSTR)arg4);
|
---|
398 | }
|
---|
399 |
|
---|
400 |
|
---|
401 | /*****************************************************************************
|
---|
402 | * Name : BOOL CreateSemaphoreW
|
---|
403 | * Purpose : forward call to Open32
|
---|
404 | * Parameters:
|
---|
405 | * Variables :
|
---|
406 | * Result :
|
---|
407 | * Remark : handle translation is done in CreateSemaphoreW
|
---|
408 | * Status :
|
---|
409 | *
|
---|
410 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
411 | *****************************************************************************/
|
---|
412 |
|
---|
413 | ODINFUNCTION4(HANDLE, CreateSemaphoreW,
|
---|
414 | PSECURITY_ATTRIBUTES, arg1,
|
---|
415 | LONG, arg2,
|
---|
416 | LONG, arg3,
|
---|
417 | LPCWSTR, arg4)
|
---|
418 | {
|
---|
419 | HANDLE rc;
|
---|
420 | char *astring;
|
---|
421 |
|
---|
422 | if (arg4 != NULL) // support for unnamed semaphores
|
---|
423 | astring = UnicodeToAsciiString((LPWSTR)arg4);
|
---|
424 | else
|
---|
425 | astring = NULL;
|
---|
426 |
|
---|
427 | dprintf(("KERNEL32: CreateSemaphoreW(%s)\n",
|
---|
428 | astring));
|
---|
429 |
|
---|
430 | rc = HMCreateSemaphore(arg1,
|
---|
431 | arg2,
|
---|
432 | arg3,
|
---|
433 | astring);
|
---|
434 |
|
---|
435 | if (astring != NULL)
|
---|
436 | FreeAsciiString(astring);
|
---|
437 | return(rc);
|
---|
438 | }
|
---|
439 |
|
---|
440 |
|
---|
441 | /*****************************************************************************
|
---|
442 | * Name : BOOL GetOverlappedResult
|
---|
443 | * Purpose : forward call to Open32
|
---|
444 | * Parameters:
|
---|
445 | * Variables :
|
---|
446 | * Result :
|
---|
447 | * Remark : handle translation is done in GetOverlappedResult
|
---|
448 | * Status :
|
---|
449 | *
|
---|
450 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
451 | *****************************************************************************/
|
---|
452 |
|
---|
453 | ODINFUNCTION4(BOOL, GetOverlappedResult,
|
---|
454 | HANDLE, arg1,
|
---|
455 | LPOVERLAPPED, arg2,
|
---|
456 | LPDWORD, arg3,
|
---|
457 | BOOL, arg4)
|
---|
458 | {
|
---|
459 | return HMGetOverlappedResult(arg1,
|
---|
460 | arg2,
|
---|
461 | arg3,
|
---|
462 | arg4);
|
---|
463 | }
|
---|
464 |
|
---|
465 |
|
---|
466 | /*****************************************************************************
|
---|
467 | * Name : BOOL OpenEventA
|
---|
468 | * Purpose : forward call to Open32
|
---|
469 | * Parameters:
|
---|
470 | * Variables :
|
---|
471 | * Result :
|
---|
472 | * Remark : handle translation is done in OpenEventA
|
---|
473 | * Status :
|
---|
474 | *
|
---|
475 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
476 | *****************************************************************************/
|
---|
477 |
|
---|
478 | ODINFUNCTION3(HANDLE, OpenEventA,
|
---|
479 | DWORD, arg1,
|
---|
480 | BOOL, arg2,
|
---|
481 | LPCSTR, arg3)
|
---|
482 | {
|
---|
483 | dprintf(("KERNEL32: OpenEventA(%s)\n",
|
---|
484 | arg3));
|
---|
485 |
|
---|
486 | return HMOpenEvent(arg1,
|
---|
487 | arg2,
|
---|
488 | arg3);
|
---|
489 | }
|
---|
490 |
|
---|
491 |
|
---|
492 | /*****************************************************************************
|
---|
493 | * Name : BOOL
|
---|
494 | * Purpose : forward call to Open32
|
---|
495 | * Parameters:
|
---|
496 | * Variables :
|
---|
497 | * Result :
|
---|
498 | * Remark : handle translation is done in OpenEventW
|
---|
499 | * Status :
|
---|
500 | *
|
---|
501 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
502 | *****************************************************************************/
|
---|
503 |
|
---|
504 | ODINFUNCTION3(HANDLE, OpenEventW,
|
---|
505 | DWORD, dwDesiredAccess,
|
---|
506 | BOOL, bInheritHandle,
|
---|
507 | LPCWSTR, lpName)
|
---|
508 | {
|
---|
509 | char *asciiname;
|
---|
510 | HANDLE rc;
|
---|
511 |
|
---|
512 | asciiname = UnicodeToAsciiString((LPWSTR)lpName);
|
---|
513 |
|
---|
514 | dprintf(("KERNEL32: OpenEventW(%s)\n",
|
---|
515 | asciiname));
|
---|
516 |
|
---|
517 | rc = HMOpenEvent(dwDesiredAccess,
|
---|
518 | bInheritHandle,
|
---|
519 | asciiname);
|
---|
520 | FreeAsciiString(asciiname);
|
---|
521 | return(rc);
|
---|
522 | }
|
---|
523 |
|
---|
524 |
|
---|
525 | /*****************************************************************************
|
---|
526 | * Name : BOOL OpenMutexA
|
---|
527 | * Purpose : forward call to Open32
|
---|
528 | * Parameters:
|
---|
529 | * Variables :
|
---|
530 | * Result :
|
---|
531 | * Remark : handle translation is done in OpenMutexA
|
---|
532 | * Status :
|
---|
533 | *
|
---|
534 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
535 | *****************************************************************************/
|
---|
536 |
|
---|
537 | ODINFUNCTION3(HANDLE, OpenMutexA,
|
---|
538 | DWORD, arg1,
|
---|
539 | BOOL, arg2,
|
---|
540 | LPCSTR, arg3)
|
---|
541 | {
|
---|
542 | dprintf(("KERNEL32: OpenMutexA(%s)\n",
|
---|
543 | arg3));
|
---|
544 |
|
---|
545 | return HMOpenMutex(arg1,
|
---|
546 | arg2,
|
---|
547 | arg3);
|
---|
548 | }
|
---|
549 |
|
---|
550 |
|
---|
551 | /*****************************************************************************
|
---|
552 | * Name : BOOL OpenMutexW
|
---|
553 | * Purpose : forward call to Open32
|
---|
554 | * Parameters:
|
---|
555 | * Variables :
|
---|
556 | * Result :
|
---|
557 | * Remark : handle translation is done in OpenMutexW
|
---|
558 | * Status :
|
---|
559 | *
|
---|
560 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
561 | *****************************************************************************/
|
---|
562 |
|
---|
563 | ODINFUNCTION3(HANDLE, OpenMutexW,
|
---|
564 | DWORD, dwDesiredAccess,
|
---|
565 | BOOL, bInheritHandle,
|
---|
566 | LPCWSTR, lpName)
|
---|
567 | {
|
---|
568 | char *asciiname;
|
---|
569 | HANDLE rc;
|
---|
570 |
|
---|
571 | asciiname = UnicodeToAsciiString((LPWSTR)lpName);
|
---|
572 |
|
---|
573 | dprintf(("KERNEL32: OpenMutexW(%s)\n",
|
---|
574 | asciiname));
|
---|
575 |
|
---|
576 | rc = HMOpenMutex(dwDesiredAccess,
|
---|
577 | bInheritHandle,
|
---|
578 | asciiname);
|
---|
579 | FreeAsciiString(asciiname);
|
---|
580 | return(rc);
|
---|
581 | }
|
---|
582 |
|
---|
583 |
|
---|
584 | /*****************************************************************************
|
---|
585 | * Name : BOOL OpenSemaphoreA
|
---|
586 | * Purpose : forward call to Open32
|
---|
587 | * Parameters:
|
---|
588 | * Variables :
|
---|
589 | * Result :
|
---|
590 | * Remark : handle translation is done in OpenSemaphoreA
|
---|
591 | * Status :
|
---|
592 | *
|
---|
593 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
594 | *****************************************************************************/
|
---|
595 |
|
---|
596 | ODINFUNCTION3(HANDLE, OpenSemaphoreA,
|
---|
597 | DWORD, arg1,
|
---|
598 | BOOL, arg2,
|
---|
599 | LPCSTR, arg3)
|
---|
600 | {
|
---|
601 | dprintf(("KERNEL32: OpenSemaphoreA(%s)\n",
|
---|
602 | arg3));
|
---|
603 |
|
---|
604 | return HMOpenSemaphore(arg1,
|
---|
605 | arg2,
|
---|
606 | arg3);
|
---|
607 | }
|
---|
608 |
|
---|
609 |
|
---|
610 | /*****************************************************************************
|
---|
611 | * Name : BOOL OpenSemaphoreW
|
---|
612 | * Purpose : forward call to Open32
|
---|
613 | * Parameters:
|
---|
614 | * Variables :
|
---|
615 | * Result :
|
---|
616 | * Remark : handle translation is done in OpenSemaphoreW
|
---|
617 | * Status :
|
---|
618 | *
|
---|
619 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
620 | *****************************************************************************/
|
---|
621 |
|
---|
622 | ODINFUNCTION3(HANDLE, OpenSemaphoreW,
|
---|
623 | DWORD, dwDesiredAccess,
|
---|
624 | BOOL, bInheritHandle,
|
---|
625 | LPCWSTR, lpName)
|
---|
626 | {
|
---|
627 | char *asciiname;
|
---|
628 | HANDLE rc;
|
---|
629 |
|
---|
630 | asciiname = UnicodeToAsciiString((LPWSTR)lpName);
|
---|
631 |
|
---|
632 | dprintf(("KERNEL32: OpenSemaphoreW(%s)\n",
|
---|
633 | asciiname));
|
---|
634 |
|
---|
635 | rc = HMOpenSemaphore(dwDesiredAccess,
|
---|
636 | bInheritHandle,
|
---|
637 | asciiname);
|
---|
638 | FreeAsciiString(asciiname);
|
---|
639 | return(rc);
|
---|
640 | }
|
---|
641 |
|
---|
642 |
|
---|
643 | /*****************************************************************************
|
---|
644 | * Name : BOOL PulseEvent
|
---|
645 | * Purpose : forward call to Open32
|
---|
646 | * Parameters:
|
---|
647 | * Variables :
|
---|
648 | * Result :
|
---|
649 | * Remark : handle translation is done in PulseEvent
|
---|
650 | * Status :
|
---|
651 | *
|
---|
652 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
653 | *****************************************************************************/
|
---|
654 |
|
---|
655 | ODINFUNCTION1(BOOL, PulseEvent,
|
---|
656 | HANDLE, arg1)
|
---|
657 | {
|
---|
658 | return HMPulseEvent(arg1);
|
---|
659 | }
|
---|
660 |
|
---|
661 |
|
---|
662 | /*****************************************************************************
|
---|
663 | * Name : BOOL ReleaseSemaphore
|
---|
664 | * Purpose : forward call to Open32
|
---|
665 | * Parameters:
|
---|
666 | * Variables :
|
---|
667 | * Result :
|
---|
668 | * Remark : handle translation is done in ReleaseSemaphore
|
---|
669 | * Status :
|
---|
670 | *
|
---|
671 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
672 | *****************************************************************************/
|
---|
673 |
|
---|
674 | ODINFUNCTION3(BOOL, ReleaseSemaphore,
|
---|
675 | HANDLE, arg1,
|
---|
676 | LONG, arg2,
|
---|
677 | PLONG, arg3)
|
---|
678 | {
|
---|
679 | return HMReleaseSemaphore(arg1,
|
---|
680 | arg2,
|
---|
681 | arg3);
|
---|
682 | }
|
---|
683 |
|
---|
684 |
|
---|
685 | /*****************************************************************************
|
---|
686 | * Name : BOOL ResetEvent
|
---|
687 | * Purpose : forward call to Open32
|
---|
688 | * Parameters:
|
---|
689 | * Variables :
|
---|
690 | * Result :
|
---|
691 | * Remark : handle translation is done in ResetEvent
|
---|
692 | * Status :
|
---|
693 | *
|
---|
694 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
695 | *****************************************************************************/
|
---|
696 |
|
---|
697 | ODINFUNCTION1(BOOL, ResetEvent,
|
---|
698 | HANDLE, arg1)
|
---|
699 | {
|
---|
700 | return HMResetEvent(arg1);
|
---|
701 | }
|
---|
702 |
|
---|
703 |
|
---|
704 | /*****************************************************************************
|
---|
705 | * Name : BOOL WaitForMultipleObjects
|
---|
706 | * Purpose : forward call to Open32
|
---|
707 | * Parameters:
|
---|
708 | * Variables :
|
---|
709 | * Result :
|
---|
710 | * Remark : handle translation is done in WaitForMultipleObjects
|
---|
711 | * Status :
|
---|
712 | *
|
---|
713 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
714 | *****************************************************************************/
|
---|
715 |
|
---|
716 | ODINFUNCTION4(DWORD, WaitForMultipleObjects,
|
---|
717 | DWORD, arg1,
|
---|
718 | const HANDLE *, arg2,
|
---|
719 | BOOL, arg3,
|
---|
720 | DWORD, arg4)
|
---|
721 | {
|
---|
722 | return HMWaitForMultipleObjects(arg1,
|
---|
723 | (PHANDLE)arg2,
|
---|
724 | arg3,
|
---|
725 | arg4);
|
---|
726 | }
|
---|
727 |
|
---|
728 |
|
---|
729 | /*****************************************************************************
|
---|
730 | * Name : DWORD OS2WaitForMultipleObjectsEx
|
---|
731 | * Purpose : The WaitForMultipleObjectsEx function is an extended wait
|
---|
732 | * function that can be used to perform an alertable wait. This
|
---|
733 | * enables the function to return when the system queues an I/O
|
---|
734 | * completion routine to be executed by the calling thread. The
|
---|
735 | * function also returns either when any one or when all of the
|
---|
736 | * specified objects are in the signaled state, or when the
|
---|
737 | * time-out interval elapses.
|
---|
738 | * Parameters: DWORD cObjects number of handles in handle array
|
---|
739 | * HANDLE *lphObjects address of object-handle array
|
---|
740 | * BOOL fWaitAll wait flag
|
---|
741 | * DWORD dwTimeout time-out interval in milliseconds
|
---|
742 | * BOOL fAlertable alertable wait flag
|
---|
743 | * Variables :
|
---|
744 | * Result : 0xFFFFFFFF in case of error
|
---|
745 | * Remark : only really required for async I/O
|
---|
746 | * Status : UNTESTED STUB
|
---|
747 | *
|
---|
748 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
749 | *****************************************************************************/
|
---|
750 |
|
---|
751 | ODINFUNCTION5(DWORD, WaitForMultipleObjectsEx,
|
---|
752 | DWORD, cObjects,
|
---|
753 | CONST HANDLE *, lphObjects,
|
---|
754 | BOOL, fWaitAll,
|
---|
755 | DWORD, dwTimeout,
|
---|
756 | BOOL, fAlertable)
|
---|
757 | {
|
---|
758 | return(HMWaitForMultipleObjectsEx(cObjects,
|
---|
759 | (PHANDLE)lphObjects,
|
---|
760 | fWaitAll,
|
---|
761 | dwTimeout,
|
---|
762 | fAlertable));
|
---|
763 | }
|
---|
764 |
|
---|
765 |
|
---|
766 | /*****************************************************************************
|
---|
767 | * Name : HANDLE ConvertToGlobalHandle
|
---|
768 | * Purpose : forward call to Open32
|
---|
769 | * Parameters:
|
---|
770 | * Variables :
|
---|
771 | * Result :
|
---|
772 | * Remark : handle translation is done in ConvertToGlobalHandle
|
---|
773 | * Status :
|
---|
774 | *
|
---|
775 | * Author : Patrick Haller [Fri, 1999/06/18 03:44]
|
---|
776 | *****************************************************************************/
|
---|
777 |
|
---|
778 | ODINFUNCTION1(HANDLE, ConvertToGlobalHandle,
|
---|
779 | HANDLE, hHandle)
|
---|
780 |
|
---|
781 | //ODINFUNCTION2(HANDLE, ConvertToGlobalHandle,
|
---|
782 | // HANDLE, hHandle,
|
---|
783 | // BOOL, fInherit)
|
---|
784 | {
|
---|
785 | return (hHandle);
|
---|
786 | }
|
---|
787 |
|
---|
788 |
|
---|