process.c 20.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * NT basis DLL
 *
 * This file contains the Nt* API functions of NTDLL.DLL.
 * In the original ntdll.dll they all seem to just call int 0x2e (down to the NTOSKRNL)
 *
 * Copyright 1996-1998 Marcus Meissner
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
21
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 23
 */

24 25
#include "config.h"

26 27 28 29 30
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
31 32 33
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
34

35 36 37
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "wine/debug.h"
38 39 40 41 42 43 44
#include "windef.h"
#include "winternl.h"
#include "ntdll_misc.h"
#include "wine/server.h"

WINE_DEFAULT_DEBUG_CHANNEL(ntdll);

45
static ULONG execute_flags = MEM_EXECUTE_OPTION_DISABLE;
46

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
/*
 *	Process object
 */

/******************************************************************************
 *  NtTerminateProcess			[NTDLL.@]
 *
 *  Native applications must kill themselves when done
 */
NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
{
    NTSTATUS ret;
    BOOL self;
    SERVER_START_REQ( terminate_process )
    {
62
        req->handle    = wine_server_obj_handle( handle );
63 64 65 66 67
        req->exit_code = exit_code;
        ret = wine_server_call( req );
        self = !ret && reply->self;
    }
    SERVER_END_REQ;
68
    if (self && handle) _exit( exit_code );
69 70 71
    return ret;
}

72 73 74 75 76 77 78 79 80
/******************************************************************************
 *  RtlGetCurrentPeb  [NTDLL.@]
 *
 */
PEB * WINAPI RtlGetCurrentPeb(void)
{
    return NtCurrentTeb()->Peb;
}

81 82 83 84 85 86
/***********************************************************************
 *           __wine_make_process_system   (NTDLL.@)
 *
 * Mark the current process as a system process.
 * Returns the event that is signaled when all non-system processes have exited.
 */
87
HANDLE CDECL __wine_make_process_system(void)
88 89 90 91
{
    HANDLE ret = 0;
    SERVER_START_REQ( make_process_system )
    {
92
        if (!wine_server_call( req )) ret = wine_server_ptr_handle( reply->event );
93 94 95 96 97
    }
    SERVER_END_REQ;
    return ret;
}

98
static UINT process_error_mode;
99

100 101 102 103 104 105
#define UNIMPLEMENTED_INFO_CLASS(c) \
    case c: \
        FIXME("(process=%p) Unimplemented information class: " #c "\n", ProcessHandle); \
        ret = STATUS_INVALID_INFO_CLASS; \
        break

106 107 108 109 110 111 112
ULONG_PTR get_system_affinity_mask(void)
{
    ULONG num_cpus = NtCurrentTeb()->Peb->NumberOfProcessors;
    if (num_cpus >= sizeof(ULONG_PTR) * 8) return ~(ULONG_PTR)0;
    return ((ULONG_PTR)1 << num_cpus) - 1;
}

113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
/******************************************************************************
*  NtQueryInformationProcess		[NTDLL.@]
*  ZwQueryInformationProcess		[NTDLL.@]
*
*/
NTSTATUS WINAPI NtQueryInformationProcess(
	IN HANDLE ProcessHandle,
	IN PROCESSINFOCLASS ProcessInformationClass,
	OUT PVOID ProcessInformation,
	IN ULONG ProcessInformationLength,
	OUT PULONG ReturnLength)
{
    NTSTATUS ret = STATUS_SUCCESS;
    ULONG len = 0;

128
    TRACE("(%p,0x%08x,%p,0x%08x,%p)\n",
129 130 131 132
          ProcessHandle,ProcessInformationClass,
          ProcessInformation,ProcessInformationLength,
          ReturnLength);

133 134
    switch (ProcessInformationClass) 
    {
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
    UNIMPLEMENTED_INFO_CLASS(ProcessQuotaLimits);
    UNIMPLEMENTED_INFO_CLASS(ProcessBasePriority);
    UNIMPLEMENTED_INFO_CLASS(ProcessRaisePriority);
    UNIMPLEMENTED_INFO_CLASS(ProcessExceptionPort);
    UNIMPLEMENTED_INFO_CLASS(ProcessAccessToken);
    UNIMPLEMENTED_INFO_CLASS(ProcessLdtInformation);
    UNIMPLEMENTED_INFO_CLASS(ProcessLdtSize);
    UNIMPLEMENTED_INFO_CLASS(ProcessIoPortHandlers);
    UNIMPLEMENTED_INFO_CLASS(ProcessPooledUsageAndLimits);
    UNIMPLEMENTED_INFO_CLASS(ProcessWorkingSetWatch);
    UNIMPLEMENTED_INFO_CLASS(ProcessUserModeIOPL);
    UNIMPLEMENTED_INFO_CLASS(ProcessEnableAlignmentFaultFixup);
    UNIMPLEMENTED_INFO_CLASS(ProcessPriorityClass);
    UNIMPLEMENTED_INFO_CLASS(ProcessWx86Information);
    UNIMPLEMENTED_INFO_CLASS(ProcessPriorityBoost);
    UNIMPLEMENTED_INFO_CLASS(ProcessDeviceMap);
    UNIMPLEMENTED_INFO_CLASS(ProcessSessionInformation);
    UNIMPLEMENTED_INFO_CLASS(ProcessForegroundInformation);
    UNIMPLEMENTED_INFO_CLASS(ProcessLUIDDeviceMapsEnabled);
    UNIMPLEMENTED_INFO_CLASS(ProcessBreakOnTermination);
    UNIMPLEMENTED_INFO_CLASS(ProcessHandleTracing);

157 158
    case ProcessBasicInformation:
        {
159
            PROCESS_BASIC_INFORMATION pbi;
160
            const ULONG_PTR affinity_mask = get_system_affinity_mask();
161 162

            if (ProcessInformationLength >= sizeof(PROCESS_BASIC_INFORMATION))
163
            {
164 165 166 167 168
                if (!ProcessInformation)
                    ret = STATUS_ACCESS_VIOLATION;
                else if (!ProcessHandle)
                    ret = STATUS_INVALID_HANDLE;
                else
169
                {
170
                    SERVER_START_REQ(get_process_info)
171
                    {
172
                        req->handle = wine_server_obj_handle( ProcessHandle );
173 174 175
                        if ((ret = wine_server_call( req )) == STATUS_SUCCESS)
                        {
                            pbi.ExitStatus = reply->exit_code;
176
                            pbi.PebBaseAddress = wine_server_get_ptr( reply->peb );
177
                            pbi.AffinityMask = reply->affinity & affinity_mask;
178 179 180 181
                            pbi.BasePriority = reply->priority;
                            pbi.UniqueProcessId = reply->pid;
                            pbi.InheritedFromUniqueProcessId = reply->ppid;
                        }
182
                    }
183 184 185 186 187
                    SERVER_END_REQ;

                    memcpy(ProcessInformation, &pbi, sizeof(PROCESS_BASIC_INFORMATION));

                    len = sizeof(PROCESS_BASIC_INFORMATION);
188
                }
189 190 191

                if (ProcessInformationLength > sizeof(PROCESS_BASIC_INFORMATION))
                    ret = STATUS_INFO_LENGTH_MISMATCH;
192
            }
193 194 195 196 197
            else
            {
                len = sizeof(PROCESS_BASIC_INFORMATION);
                ret = STATUS_INFO_LENGTH_MISMATCH;
            }
198 199
        }
        break;
200 201
    case ProcessIoCounters:
        {
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
            IO_COUNTERS pii;

            if (ProcessInformationLength >= sizeof(IO_COUNTERS))
            {
                if (!ProcessInformation)
                    ret = STATUS_ACCESS_VIOLATION;
                else if (!ProcessHandle)
                    ret = STATUS_INVALID_HANDLE;
                else
                {
                    /* FIXME : real data */
                    memset(&pii, 0 , sizeof(IO_COUNTERS));

                    memcpy(ProcessInformation, &pii, sizeof(IO_COUNTERS));

                    len = sizeof(IO_COUNTERS);
                }
219 220 221

                if (ProcessInformationLength > sizeof(IO_COUNTERS))
                    ret = STATUS_INFO_LENGTH_MISMATCH;
222
            }
223 224 225 226 227
            else
            {
                len = sizeof(IO_COUNTERS);
                ret = STATUS_INFO_LENGTH_MISMATCH;
            }
228 229 230 231 232 233
        }
        break;
    case ProcessVmCounters:
        {
            VM_COUNTERS pvmi;

234 235
            /* older Windows versions don't have the PrivatePageCount field */
            if (ProcessInformationLength >= FIELD_OFFSET(VM_COUNTERS,PrivatePageCount))
236 237 238 239 240 241 242 243 244 245
            {
                if (!ProcessInformation)
                    ret = STATUS_ACCESS_VIOLATION;
                else if (!ProcessHandle)
                    ret = STATUS_INVALID_HANDLE;
                else
                {
                    /* FIXME : real data */
                    memset(&pvmi, 0 , sizeof(VM_COUNTERS));

246 247
                    len = ProcessInformationLength;
                    if (len != FIELD_OFFSET(VM_COUNTERS,PrivatePageCount)) len = sizeof(VM_COUNTERS);
248

249
                    memcpy(ProcessInformation, &pvmi, min(ProcessInformationLength,sizeof(VM_COUNTERS)));
250
                }
251

252 253
                if (ProcessInformationLength != FIELD_OFFSET(VM_COUNTERS,PrivatePageCount) &&
                    ProcessInformationLength != sizeof(VM_COUNTERS))
254
                    ret = STATUS_INFO_LENGTH_MISMATCH;
255
            }
256 257 258 259 260
            else
            {
                len = sizeof(pvmi);
                ret = STATUS_INFO_LENGTH_MISMATCH;
            }
261 262 263 264
        }
        break;
    case ProcessTimes:
        {
265 266 267
            KERNEL_USER_TIMES pti;

            if (ProcessInformationLength >= sizeof(KERNEL_USER_TIMES))
268
            {
269 270 271 272 273 274
                if (!ProcessInformation)
                    ret = STATUS_ACCESS_VIOLATION;
                else if (!ProcessHandle)
                    ret = STATUS_INVALID_HANDLE;
                else
                {
275
                    /* FIXME : User- and KernelTime have to be implemented */
276
                    memset(&pti, 0, sizeof(KERNEL_USER_TIMES));
277

278 279
                    SERVER_START_REQ(get_process_info)
                    {
280
                      req->handle = wine_server_obj_handle( ProcessHandle );
281 282
                      if ((ret = wine_server_call( req )) == STATUS_SUCCESS)
                      {
283 284
                          pti.CreateTime.QuadPart = reply->start_time;
                          pti.ExitTime.QuadPart = reply->end_time;
285 286 287 288
                      }
                    }
                    SERVER_END_REQ;

289 290 291
                    memcpy(ProcessInformation, &pti, sizeof(KERNEL_USER_TIMES));
                    len = sizeof(KERNEL_USER_TIMES);
                }
292

293 294
                if (ProcessInformationLength > sizeof(KERNEL_USER_TIMES))
                    ret = STATUS_INFO_LENGTH_MISMATCH;
295
            }
296 297 298 299 300
            else
            {
                len = sizeof(KERNEL_USER_TIMES);
                ret = STATUS_INFO_LENGTH_MISMATCH;
            }
301 302 303
        }
        break;
    case ProcessDebugPort:
304
        len = sizeof(DWORD_PTR);
305
        if (ProcessInformationLength == len)
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
        {
            if (!ProcessInformation)
                ret = STATUS_ACCESS_VIOLATION;
            else if (!ProcessHandle)
                ret = STATUS_INVALID_HANDLE;
            else
            {
                SERVER_START_REQ(get_process_info)
                {
                    req->handle = wine_server_obj_handle( ProcessHandle );
                    if ((ret = wine_server_call( req )) == STATUS_SUCCESS)
                    {
                        *(DWORD_PTR *)ProcessInformation = reply->debugger_present ? ~(DWORD_PTR)0 : 0;
                    }
                }
                SERVER_END_REQ;
            }
        }
324 325
        else
            ret = STATUS_INFO_LENGTH_MISMATCH;
326
        break;
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
    case ProcessDebugFlags:
        len = sizeof(DWORD);
        if (ProcessInformationLength == len)
        {
            if (!ProcessInformation)
                ret = STATUS_ACCESS_VIOLATION;
            else if (!ProcessHandle)
                ret = STATUS_INVALID_HANDLE;
            else
            {
                SERVER_START_REQ(get_process_info)
                {
                    req->handle = wine_server_obj_handle( ProcessHandle );
                    if ((ret = wine_server_call( req )) == STATUS_SUCCESS)
                    {
                        *(DWORD *)ProcessInformation = !reply->debugger_present;
                    }
                }
                SERVER_END_REQ;
            }
        }
        else
            ret = STATUS_INFO_LENGTH_MISMATCH;
        break;
351 352 353 354 355 356 357
    case ProcessDefaultHardErrorMode:
        len = sizeof(process_error_mode);
        if (ProcessInformationLength == len)
            memcpy(ProcessInformation, &process_error_mode, len);
        else
            ret = STATUS_INFO_LENGTH_MISMATCH;
        break;
358 359 360 361 362
    case ProcessDebugObjectHandle:
        /* "These are not the debuggers you are looking for." *
         * set it to 0 aka "no debugger" to satisfy copy protections */
        len = sizeof(HANDLE);
        if (ProcessInformationLength == len)
363 364 365 366 367 368
        {
            if (!ProcessInformation)
                ret = STATUS_ACCESS_VIOLATION;
            else if (!ProcessHandle)
                ret = STATUS_INVALID_HANDLE;
            else
369
            {
370
                memset(ProcessInformation, 0, ProcessInformationLength);
371 372
                ret = STATUS_PORT_NOT_SET;
            }
373
        }
374 375
        else
            ret = STATUS_INFO_LENGTH_MISMATCH;
376
        break;
377 378 379 380 381 382 383 384 385 386 387 388
    case ProcessHandleCount:
        if (ProcessInformationLength >= 4)
        {
            if (!ProcessInformation)
                ret = STATUS_ACCESS_VIOLATION;
            else if (!ProcessHandle)
                ret = STATUS_INVALID_HANDLE;
            else
            {
                memset(ProcessInformation, 0, 4);
                len = 4;
            }
389 390 391

            if (ProcessInformationLength > 4)
                ret = STATUS_INFO_LENGTH_MISMATCH;
392 393 394 395 396 397 398
        }
        else
        {
            len = 4;
            ret = STATUS_INFO_LENGTH_MISMATCH;
        }
        break;
399 400 401 402 403

    case ProcessAffinityMask:
        len = sizeof(ULONG_PTR);
        if (ProcessInformationLength == len)
        {
404
            const ULONG_PTR system_mask = get_system_affinity_mask();
405 406 407 408 409 410 411 412 413 414 415 416

            SERVER_START_REQ(get_process_info)
            {
                req->handle = wine_server_obj_handle( ProcessHandle );
                if (!(ret = wine_server_call( req )))
                    *(ULONG_PTR *)ProcessInformation = reply->affinity & system_mask;
            }
            SERVER_END_REQ;
        }
        else ret = STATUS_INFO_LENGTH_MISMATCH;
        break;

417
    case ProcessWow64Information:
418 419 420 421 422
        len = sizeof(ULONG_PTR);
        if (ProcessInformationLength != len) ret = STATUS_INFO_LENGTH_MISMATCH;
        else if (!ProcessInformation) ret = STATUS_ACCESS_VIOLATION;
        else if(!ProcessHandle) ret = STATUS_INVALID_HANDLE;
        else
423
        {
424
            ULONG_PTR val = 0;
425 426

            if (ProcessHandle == GetCurrentProcess()) val = is_wow64;
427
            else if (server_cpus & ((1 << CPU_x86_64) | (1 << CPU_ARM64)))
428 429 430 431
            {
                SERVER_START_REQ( get_process_info )
                {
                    req->handle = wine_server_obj_handle( ProcessHandle );
432 433
                    if (!(ret = wine_server_call( req )))
                        val = (reply->cpu != CPU_x86_64 && reply->cpu != CPU_ARM64);
434 435 436
                }
                SERVER_END_REQ;
            }
437
            *(ULONG_PTR *)ProcessInformation = val;
438 439
        }
        break;
440
    case ProcessImageFileName:
441 442
        /* FIXME: this will return a DOS path. Windows returns an NT path. Changing this would require also changing kernel32.QueryFullProcessImageName.
         * The latter may be harder because of the lack of RtlNtPathNameToDosPathName. */
443 444 445 446
        SERVER_START_REQ(get_dll_info)
        {
            UNICODE_STRING *image_file_name_str = ProcessInformation;

447
            req->handle = wine_server_obj_handle( ProcessHandle );
448
            req->base_address = 0; /* main module */
449 450 451 452 453 454 455 456 457 458 459 460 461 462
            wine_server_set_reply( req, image_file_name_str ? image_file_name_str + 1 : NULL,
                                   ProcessInformationLength > sizeof(UNICODE_STRING) ? ProcessInformationLength - sizeof(UNICODE_STRING) : 0 );
            ret = wine_server_call( req );
            if (ret == STATUS_BUFFER_TOO_SMALL) ret = STATUS_INFO_LENGTH_MISMATCH;

            len = sizeof(UNICODE_STRING) + reply->filename_len;
            if (ret == STATUS_SUCCESS)
            {
                image_file_name_str->MaximumLength = image_file_name_str->Length = reply->filename_len;
                image_file_name_str->Buffer = (PWSTR)(image_file_name_str + 1);
            }
        }
        SERVER_END_REQ;
        break;
463
    case ProcessExecuteFlags:
464 465
        len = sizeof(ULONG);
        if (ProcessInformationLength == len)
466
            *(ULONG *)ProcessInformation = execute_flags;
467 468
        else
            ret = STATUS_INFO_LENGTH_MISMATCH;
469
        break;
470
    default:
471
        FIXME("(%p,info_class=%d,%p,0x%08x,%p) Unknown information class\n",
472 473 474
              ProcessHandle,ProcessInformationClass,
              ProcessInformation,ProcessInformationLength,
              ReturnLength);
475
        ret = STATUS_INVALID_INFO_CLASS;
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
        break;
    }

    if (ReturnLength) *ReturnLength = len;
    
    return ret;
}

/******************************************************************************
 * NtSetInformationProcess [NTDLL.@]
 * ZwSetInformationProcess [NTDLL.@]
 */
NTSTATUS WINAPI NtSetInformationProcess(
	IN HANDLE ProcessHandle,
	IN PROCESSINFOCLASS ProcessInformationClass,
	IN PVOID ProcessInformation,
	IN ULONG ProcessInformationLength)
{
494 495 496 497
    NTSTATUS ret = STATUS_SUCCESS;

    switch (ProcessInformationClass)
    {
498 499 500 501
    case ProcessDefaultHardErrorMode:
        if (ProcessInformationLength != sizeof(UINT)) return STATUS_INVALID_PARAMETER;
        process_error_mode = *(UINT *)ProcessInformation;
        break;
502
    case ProcessAffinityMask:
503 504 505
    {
        const ULONG_PTR system_mask = get_system_affinity_mask();

506
        if (ProcessInformationLength != sizeof(DWORD_PTR)) return STATUS_INVALID_PARAMETER;
507
        if (*(PDWORD_PTR)ProcessInformation & ~system_mask)
508
            return STATUS_INVALID_PARAMETER;
509 510
        if (!*(PDWORD_PTR)ProcessInformation)
            return STATUS_INVALID_PARAMETER;
511 512
        SERVER_START_REQ( set_process_info )
        {
513
            req->handle   = wine_server_obj_handle( ProcessHandle );
514 515 516 517 518 519
            req->affinity = *(PDWORD_PTR)ProcessInformation;
            req->mask     = SET_PROCESS_INFO_AFFINITY;
            ret = wine_server_call( req );
        }
        SERVER_END_REQ;
        break;
520
    }
521 522 523 524 525 526 527 528 529
    case ProcessPriorityClass:
        if (ProcessInformationLength != sizeof(PROCESS_PRIORITY_CLASS))
            return STATUS_INVALID_PARAMETER;
        else
        {
            PROCESS_PRIORITY_CLASS* ppc = ProcessInformation;

            SERVER_START_REQ( set_process_info )
            {
530
                req->handle   = wine_server_obj_handle( ProcessHandle );
531 532 533 534 535 536 537 538
                /* FIXME Foreground isn't used */
                req->priority = ppc->PriorityClass;
                req->mask     = SET_PROCESS_INFO_PRIORITY;
                ret = wine_server_call( req );
            }
            SERVER_END_REQ;
        }
        break;
539 540 541 542

    case ProcessExecuteFlags:
        if (ProcessInformationLength != sizeof(ULONG))
            return STATUS_INVALID_PARAMETER;
543 544
        else if (execute_flags & MEM_EXECUTE_OPTION_PERMANENT)
            return STATUS_ACCESS_DENIED;
545 546 547 548 549 550
        else
        {
            BOOL enable;
            switch (*(ULONG *)ProcessInformation & (MEM_EXECUTE_OPTION_ENABLE|MEM_EXECUTE_OPTION_DISABLE))
            {
            case MEM_EXECUTE_OPTION_ENABLE:
551
                enable = TRUE;
552 553
                break;
            case MEM_EXECUTE_OPTION_DISABLE:
554
                enable = FALSE;
555 556 557 558
                break;
            default:
                return STATUS_INVALID_PARAMETER;
            }
559
            execute_flags = *(ULONG *)ProcessInformation;
560 561 562 563
            VIRTUAL_SetForceExec( enable );
        }
        break;

564
    default:
565
        FIXME("(%p,0x%08x,%p,0x%08x) stub\n",
566 567 568 569 570 571
              ProcessHandle,ProcessInformationClass,ProcessInformation,
              ProcessInformationLength);
        ret = STATUS_NOT_IMPLEMENTED;
        break;
    }
    return ret;
572
}
573 574 575 576 577 578 579 580

/******************************************************************************
 * NtFlushInstructionCache [NTDLL.@]
 * ZwFlushInstructionCache [NTDLL.@]
 */
NTSTATUS WINAPI NtFlushInstructionCache(
        IN HANDLE ProcessHandle,
        IN LPCVOID BaseAddress,
581
        IN SIZE_T Size)
582
{
583 584 585
    static int once;
    if (!once++)
    {
586 587
#if defined(__x86_64__) || defined(__i386__)
        TRACE("%p %p %ld - no-op on x86 and x86_64\n", ProcessHandle, BaseAddress, Size );
588
#else
589
        FIXME("%p %p %ld\n", ProcessHandle, BaseAddress, Size );
590
#endif
591
    }
592 593
    return STATUS_SUCCESS;
}
594 595 596 597 598 599 600 601 602 603 604 605

/******************************************************************
 *		NtOpenProcess [NTDLL.@]
 *		ZwOpenProcess [NTDLL.@]
 */
NTSTATUS  WINAPI NtOpenProcess(PHANDLE handle, ACCESS_MASK access,
                               const OBJECT_ATTRIBUTES* attr, const CLIENT_ID* cid)
{
    NTSTATUS    status;

    SERVER_START_REQ( open_process )
    {
606
        req->pid        = HandleToULong(cid->UniqueProcess);
607 608
        req->access     = access;
        req->attributes = attr ? attr->Attributes : 0;
609
        status = wine_server_call( req );
610
        if (!status) *handle = wine_server_ptr_handle( reply->handle );
611 612 613 614
    }
    SERVER_END_REQ;
    return status;
}