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