nt.c 38.7 KB
Newer Older
1 2
/*
 * NT basis DLL
3
 *
4
 * This file contains the Nt* API functions of NTDLL.DLL.
5
 * In the original ntdll.dll they all seem to just call int 0x2e (down to the NTOSKRNL)
6 7
 *
 * Copyright 1996-1998 Marcus Meissner
8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * 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
#include <stdarg.h>
25
#include <stdio.h>
26 27 28
#include <stdlib.h>
#include <string.h>
#include <time.h>
29 30 31

#include "ntstatus.h"
#define WIN32_NO_STATUS
32
#include "wine/debug.h"
33
#include "wine/unicode.h"
34
#include "windef.h"
35
#include "winternl.h"
36
#include "ntdll_misc.h"
37
#include "wine/server.h"
Juergen Schmied's avatar
Juergen Schmied committed
38

39
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
40

Juergen Schmied's avatar
Juergen Schmied committed
41 42 43 44
/*
 *	Token
 */

45
/******************************************************************************
46
 *  NtDuplicateToken		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
47
 *  ZwDuplicateToken		[NTDLL.@]
48
 */
Juergen Schmied's avatar
Juergen Schmied committed
49 50 51 52 53 54 55
NTSTATUS WINAPI NtDuplicateToken(
        IN HANDLE ExistingToken,
        IN ACCESS_MASK DesiredAccess,
        IN POBJECT_ATTRIBUTES ObjectAttributes,
        IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
        IN TOKEN_TYPE TokenType,
        OUT PHANDLE NewToken)
56
{
57 58
    NTSTATUS status;

59
    TRACE("(%p,0x%08x,%p,0x%08x,0x%08x,%p)\n",
60 61 62 63 64 65
        ExistingToken, DesiredAccess, ObjectAttributes,
        ImpersonationLevel, TokenType, NewToken);
        dump_ObjectAttributes(ObjectAttributes);

    SERVER_START_REQ( duplicate_token )
    {
66 67 68 69
        req->handle              = ExistingToken;
        req->access              = DesiredAccess;
        req->attributes          = ObjectAttributes ? ObjectAttributes->Attributes : 0;
        req->primary             = (TokenType == TokenPrimary);
70 71 72 73 74 75 76
        req->impersonation_level = ImpersonationLevel;
        status = wine_server_call( req );
        if (!status) *NewToken = reply->new_handle;
    }
    SERVER_END_REQ;

    return status;
77 78 79
}

/******************************************************************************
80
 *  NtOpenProcessToken		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
81
 *  ZwOpenProcessToken		[NTDLL.@]
82
 */
Juergen Schmied's avatar
Juergen Schmied committed
83 84
NTSTATUS WINAPI NtOpenProcessToken(
	HANDLE ProcessHandle,
85 86
	DWORD DesiredAccess,
	HANDLE *TokenHandle)
87
{
88 89
    NTSTATUS ret;

90
    TRACE("(%p,0x%08x,%p)\n", ProcessHandle,DesiredAccess, TokenHandle);
91 92 93

    SERVER_START_REQ( open_token )
    {
94 95 96 97
        req->handle     = ProcessHandle;
        req->access     = DesiredAccess;
        req->attributes = 0;
        req->flags      = 0;
98 99 100 101 102 103
        ret = wine_server_call( req );
        if (!ret) *TokenHandle = reply->token;
    }
    SERVER_END_REQ;

    return ret;
104 105 106
}

/******************************************************************************
107
 *  NtOpenThreadToken		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
108
 *  ZwOpenThreadToken		[NTDLL.@]
109
 */
Juergen Schmied's avatar
Juergen Schmied committed
110 111
NTSTATUS WINAPI NtOpenThreadToken(
	HANDLE ThreadHandle,
112
	DWORD DesiredAccess,
Juergen Schmied's avatar
Juergen Schmied committed
113
	BOOLEAN OpenAsSelf,
114
	HANDLE *TokenHandle)
Juergen Schmied's avatar
Juergen Schmied committed
115
{
116 117
    NTSTATUS ret;

118
    TRACE("(%p,0x%08x,0x%08x,%p)\n",
119 120 121 122
          ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);

    SERVER_START_REQ( open_token )
    {
123 124 125 126
        req->handle     = ThreadHandle;
        req->access     = DesiredAccess;
        req->attributes = 0;
        req->flags      = OPEN_TOKEN_THREAD;
127 128 129 130 131 132 133
        if (OpenAsSelf) req->flags |= OPEN_TOKEN_AS_SELF;
        ret = wine_server_call( req );
        if (!ret) *TokenHandle = reply->token;
    }
    SERVER_END_REQ;

    return ret;
134 135 136
}

/******************************************************************************
137
 *  NtAdjustPrivilegesToken		[NTDLL.@]
138
 *  ZwAdjustPrivilegesToken		[NTDLL.@]
139 140
 *
 * FIXME: parameters unsafe
141 142
 */
NTSTATUS WINAPI NtAdjustPrivilegesToken(
143
	IN HANDLE TokenHandle,
144
	IN BOOLEAN DisableAllPrivileges,
145 146 147 148 149
	IN PTOKEN_PRIVILEGES NewState,
	IN DWORD BufferLength,
	OUT PTOKEN_PRIVILEGES PreviousState,
	OUT PDWORD ReturnLength)
{
150 151
    NTSTATUS ret;

152
    TRACE("(%p,0x%08x,%p,0x%08x,%p,%p)\n",
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
        TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength);

    SERVER_START_REQ( adjust_token_privileges )
    {
        req->handle = TokenHandle;
        req->disable_all = DisableAllPrivileges;
        req->get_modified_state = (PreviousState != NULL);
        if (!DisableAllPrivileges)
        {
            wine_server_add_data( req, &NewState->Privileges,
                                  NewState->PrivilegeCount * sizeof(NewState->Privileges[0]) );
        }
        if (PreviousState && BufferLength >= FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ))
            wine_server_set_reply( req, &PreviousState->Privileges,
                                   BufferLength - FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) );
        ret = wine_server_call( req );
        if (PreviousState)
        {
            *ReturnLength = reply->len + FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges );
            PreviousState->PrivilegeCount = reply->len / sizeof(LUID_AND_ATTRIBUTES);
        }
    }
    SERVER_END_REQ;

    return ret;
178 179 180
}

/******************************************************************************
181
*  NtQueryInformationToken		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
182
*  ZwQueryInformationToken		[NTDLL.@]
Juergen Schmied's avatar
Juergen Schmied committed
183
*
184 185 186 187 188
* NOTES
*  Buffer for TokenUser:
*   0x00 TOKEN_USER the PSID field points to the SID
*   0x08 SID
*
Juergen Schmied's avatar
Juergen Schmied committed
189 190 191
*/
NTSTATUS WINAPI NtQueryInformationToken(
	HANDLE token,
192 193 194 195
	TOKEN_INFORMATION_CLASS tokeninfoclass,
	PVOID tokeninfo,
	ULONG tokeninfolength,
	PULONG retlen )
196
{
197
    ULONG len;
198
    NTSTATUS status = STATUS_SUCCESS;
199

200
    TRACE("(%p,%d,%p,%d,%p)\n",
201 202 203 204 205
          token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);

    switch (tokeninfoclass)
    {
    case TokenOwner:
206
        len = sizeof(TOKEN_OWNER) + sizeof(SID);
207 208 209 210 211 212 213 214 215 216 217 218 219 220
        break;
    case TokenPrimaryGroup:
        len = sizeof(TOKEN_PRIMARY_GROUP);
        break;
    case TokenDefaultDacl:
        len = sizeof(TOKEN_DEFAULT_DACL);
        break;
    case TokenSource:
        len = sizeof(TOKEN_SOURCE);
        break;
    case TokenType:
        len = sizeof (TOKEN_TYPE);
        break;
    case TokenImpersonationLevel:
221 222 223
        len = sizeof(SECURITY_IMPERSONATION_LEVEL);
        break;
#if 0
224
    case TokenStatistics:
225
#endif /* 0 */
226 227
    default:
        len = 0;
228
    }
229

230
    if (retlen) *retlen = len;
231 232

    if (tokeninfolength < len)
233
        return STATUS_BUFFER_TOO_SMALL;
234 235 236 237

    switch (tokeninfoclass)
    {
    case TokenUser:
238
        SERVER_START_REQ( get_token_user )
239 240 241
        {
            TOKEN_USER * tuser = tokeninfo;
            PSID sid = (PSID) (tuser + 1);
242 243 244 245 246
            DWORD sid_len = tokeninfolength < sizeof(TOKEN_USER) ? 0 : tokeninfolength - sizeof(TOKEN_USER);

            req->handle = token;
            wine_server_set_reply( req, sid, sid_len );
            status = wine_server_call( req );
247
            if (retlen) *retlen = reply->user_len + sizeof(TOKEN_USER);
248 249 250 251 252
            if (status == STATUS_SUCCESS)
            {
                tuser->User.Sid = sid;
                tuser->User.Attributes = 0;
            }
253
        }
254
        SERVER_END_REQ;
255 256
        break;
    case TokenGroups:
257 258 259 260 261 262 263 264 265 266
    {
        char stack_buffer[256];
        unsigned int server_buf_len = sizeof(stack_buffer);
        void *buffer = stack_buffer;
        BOOLEAN need_more_memory = FALSE;

        /* we cannot work out the size of the server buffer required for the
         * input size, since there are two factors affecting how much can be
         * stored in the buffer - number of groups and lengths of sids */
        do
267
        {
268 269 270
            SERVER_START_REQ( get_token_groups )
            {
                TOKEN_GROUPS *groups = tokeninfo;
271

272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
                req->handle = token;
                wine_server_set_reply( req, buffer, server_buf_len );
                status = wine_server_call( req );
                if (status == STATUS_BUFFER_TOO_SMALL)
                {
                    if (buffer == stack_buffer)
                        buffer = RtlAllocateHeap(GetProcessHeap(), 0, reply->user_len);
                    else
                        buffer = RtlReAllocateHeap(GetProcessHeap(), 0, buffer, reply->user_len);
                    if (!buffer) return STATUS_NO_MEMORY;

                    server_buf_len = reply->user_len;
                    need_more_memory = TRUE;
                }
                else if (status == STATUS_SUCCESS)
                {
                    struct token_groups *tg = buffer;
                    unsigned int *attr = (unsigned int *)(tg + 1);
                    ULONG i;
                    const int non_sid_portion = (sizeof(struct token_groups) + tg->count * sizeof(unsigned long));
                    SID *sids = (SID *)((char *)tokeninfo + FIELD_OFFSET( TOKEN_GROUPS, Groups[tg->count] ));
                    ULONG needed_bytes = FIELD_OFFSET( TOKEN_GROUPS, Groups[tg->count] ) +
                        reply->user_len - non_sid_portion;

                    if (retlen) *retlen = needed_bytes;

                    if (needed_bytes <= tokeninfolength)
                    {
                        groups->GroupCount = tg->count;
                        memcpy( sids, (char *)buffer + non_sid_portion,
                                reply->user_len - non_sid_portion );

                        for (i = 0; i < tg->count; i++)
                        {
                            groups->Groups[i].Attributes = attr[i];
                            groups->Groups[i].Sid = sids;
                            sids = (SID *)((char *)sids + RtlLengthSid(sids));
                        }
                    }
                    else status = STATUS_BUFFER_TOO_SMALL;
                }
                else if (retlen) *retlen = 0;
            }
            SERVER_END_REQ;
        } while (need_more_memory);
        if (buffer != stack_buffer) RtlFreeHeap(GetProcessHeap(), 0, buffer);
318
        break;
319
    }
320 321 322 323 324 325 326 327 328 329 330 331 332
    case TokenPrimaryGroup:
        if (tokeninfo)
        {
            TOKEN_PRIMARY_GROUP *tgroup = tokeninfo;
            SID_IDENTIFIER_AUTHORITY sid = {SECURITY_NT_AUTHORITY};
            RtlAllocateAndInitializeSid( &sid,
                                         2,
                                         SECURITY_BUILTIN_DOMAIN_RID,
                                         DOMAIN_ALIAS_RID_ADMINS,
                                         0, 0, 0, 0, 0, 0,
                                         &(tgroup->PrimaryGroup));
        }
        break;
333
    case TokenPrivileges:
334
        SERVER_START_REQ( get_token_privileges )
335 336
        {
            TOKEN_PRIVILEGES *tpriv = tokeninfo;
337 338 339 340
            req->handle = token;
            if (tpriv && tokeninfolength > FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ))
                wine_server_set_reply( req, &tpriv->Privileges, tokeninfolength - FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) );
            status = wine_server_call( req );
341
            if (retlen) *retlen = FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) + reply->len;
342
            if (tpriv) tpriv->PrivilegeCount = reply->len / sizeof(LUID_AND_ATTRIBUTES);
343
        }
344
        SERVER_END_REQ;
345
        break;
346 347 348 349 350 351 352 353 354 355 356
    case TokenOwner:
        if (tokeninfo)
        {
            TOKEN_OWNER *owner = tokeninfo;
            PSID sid = (PSID) (owner + 1);
            SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
            RtlInitializeSid(sid, &localSidAuthority, 1);
            *(RtlSubAuthoritySid(sid, 0)) = SECURITY_INTERACTIVE_RID;
            owner->Owner = sid;
        }
        break;
357 358 359 360 361 362 363 364 365 366 367
    case TokenImpersonationLevel:
        SERVER_START_REQ( get_token_impersonation_level )
        {
            SECURITY_IMPERSONATION_LEVEL *impersonation_level = tokeninfo;
            req->handle = token;
            status = wine_server_call( req );
            if (status == STATUS_SUCCESS)
                *impersonation_level = reply->impersonation_level;
        }
        SERVER_END_REQ;
        break;
368 369
    default:
        {
370
            ERR("Unhandled Token Information class %d!\n", tokeninfoclass);
371 372
            return STATUS_NOT_IMPLEMENTED;
        }
373
    }
374
    return status;
375 376
}

377 378 379 380 381 382 383 384 385 386
/******************************************************************************
*  NtSetInformationToken		[NTDLL.@]
*  ZwSetInformationToken		[NTDLL.@]
*/
NTSTATUS WINAPI NtSetInformationToken(
        HANDLE TokenHandle,
        TOKEN_INFORMATION_CLASS TokenInformationClass,
        PVOID TokenInformation,
        ULONG TokenInformationLength)
{
387
    FIXME("%p %d %p %u\n", TokenHandle, TokenInformationClass,
388 389 390 391
          TokenInformation, TokenInformationLength);
    return STATUS_NOT_IMPLEMENTED;
}

392 393 394 395 396 397 398 399 400 401 402 403
/******************************************************************************
*  NtAdjustGroupsToken		[NTDLL.@]
*  ZwAdjustGroupsToken		[NTDLL.@]
*/
NTSTATUS WINAPI NtAdjustGroupsToken(
        HANDLE TokenHandle,
        BOOLEAN ResetToDefault,
        PTOKEN_GROUPS NewState,
        ULONG BufferLength,
        PTOKEN_GROUPS PreviousState,
        PULONG ReturnLength)
{
404
    FIXME("%p %d %p %u %p %p\n", TokenHandle, ResetToDefault,
405 406 407 408
          NewState, BufferLength, PreviousState, ReturnLength);
    return STATUS_NOT_IMPLEMENTED;
}

409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
/******************************************************************************
*  NtPrivilegeCheck		[NTDLL.@]
*  ZwPrivilegeCheck		[NTDLL.@]
*/
NTSTATUS WINAPI NtPrivilegeCheck(
    HANDLE ClientToken,
    PPRIVILEGE_SET RequiredPrivileges,
    PBOOLEAN Result)
{
    NTSTATUS status;
    SERVER_START_REQ( check_token_privileges )
    {
        req->handle = ClientToken;
        req->all_required = ((RequiredPrivileges->Control & PRIVILEGE_SET_ALL_NECESSARY) ? TRUE : FALSE);
        wine_server_add_data( req, &RequiredPrivileges->Privilege,
            RequiredPrivileges->PrivilegeCount * sizeof(RequiredPrivileges->Privilege[0]) );
        wine_server_set_reply( req, &RequiredPrivileges->Privilege,
            RequiredPrivileges->PrivilegeCount * sizeof(RequiredPrivileges->Privilege[0]) );

        status = wine_server_call( req );

        if (status == STATUS_SUCCESS)
            *Result = (reply->has_privileges ? TRUE : FALSE);
    }
    SERVER_END_REQ;
    return status;
}

Juergen Schmied's avatar
Juergen Schmied committed
437 438
/*
 *	Section
439
 */
440

441
/******************************************************************************
442
 *  NtQuerySection	[NTDLL.@]
443
 */
Juergen Schmied's avatar
Juergen Schmied committed
444 445
NTSTATUS WINAPI NtQuerySection(
	IN HANDLE SectionHandle,
446
	IN SECTION_INFORMATION_CLASS SectionInformationClass,
Juergen Schmied's avatar
Juergen Schmied committed
447 448 449
	OUT PVOID SectionInformation,
	IN ULONG Length,
	OUT PULONG ResultLength)
450
{
451
	FIXME("(%p,%d,%p,0x%08x,%p) stub!\n",
Juergen Schmied's avatar
Juergen Schmied committed
452
	SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
453 454 455
	return 0;
}

Juergen Schmied's avatar
Juergen Schmied committed
456 457
/*
 *	ports
458 459 460
 */

/******************************************************************************
461
 *  NtCreatePort		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
462
 *  ZwCreatePort		[NTDLL.@]
463
 */
464
NTSTATUS WINAPI NtCreatePort(PHANDLE PortHandle,POBJECT_ATTRIBUTES ObjectAttributes,
465
                             ULONG MaxConnectInfoLength,ULONG MaxDataLength,PULONG reserved)
466
{
467
  FIXME("(%p,%p,%u,%u,%p),stub!\n",PortHandle,ObjectAttributes,
468
        MaxConnectInfoLength,MaxDataLength,reserved);
469
  return STATUS_NOT_IMPLEMENTED;
470 471 472
}

/******************************************************************************
473
 *  NtConnectPort		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
474
 *  ZwConnectPort		[NTDLL.@]
475
 */
476 477 478 479 480 481 482 483 484
NTSTATUS WINAPI NtConnectPort(
        PHANDLE PortHandle,
        PUNICODE_STRING PortName,
        PSECURITY_QUALITY_OF_SERVICE SecurityQos,
        PLPC_SECTION_WRITE WriteSection,
        PLPC_SECTION_READ ReadSection,
        PULONG MaximumMessageLength,
        PVOID ConnectInfo,
        PULONG pConnectInfoLength)
485
{
486 487 488 489 490 491
    FIXME("(%p,%s,%p,%p,%p,%p,%p,%p),stub!\n",
          PortHandle,debugstr_w(PortName->Buffer),SecurityQos,
          WriteSection,ReadSection,MaximumMessageLength,ConnectInfo,
          pConnectInfoLength);
    if (ConnectInfo && pConnectInfoLength)
        TRACE("\tMessage = %s\n",debugstr_an(ConnectInfo,*pConnectInfoLength));
492
    return STATUS_NOT_IMPLEMENTED;
493 494 495
}

/******************************************************************************
496
 *  NtListenPort		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
497
 *  ZwListenPort		[NTDLL.@]
498
 */
499
NTSTATUS WINAPI NtListenPort(HANDLE PortHandle,PLPC_MESSAGE pLpcMessage)
Juergen Schmied's avatar
Juergen Schmied committed
500
{
501
  FIXME("(%p,%p),stub!\n",PortHandle,pLpcMessage);
502
  return STATUS_NOT_IMPLEMENTED;
503 504 505
}

/******************************************************************************
506
 *  NtAcceptConnectPort	[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
507
 *  ZwAcceptConnectPort	[NTDLL.@]
508
 */
509 510 511 512 513 514 515
NTSTATUS WINAPI NtAcceptConnectPort(
        PHANDLE PortHandle,
        ULONG PortIdentifier,
        PLPC_MESSAGE pLpcMessage,
        BOOLEAN Accept,
        PLPC_SECTION_WRITE WriteSection,
        PLPC_SECTION_READ ReadSection)
Juergen Schmied's avatar
Juergen Schmied committed
516
{
517
  FIXME("(%p,%u,%p,%d,%p,%p),stub!\n",
518
        PortHandle,PortIdentifier,pLpcMessage,Accept,WriteSection,ReadSection);
519
  return STATUS_NOT_IMPLEMENTED;
520 521 522
}

/******************************************************************************
523
 *  NtCompleteConnectPort	[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
524
 *  ZwCompleteConnectPort	[NTDLL.@]
525
 */
526
NTSTATUS WINAPI NtCompleteConnectPort(HANDLE PortHandle)
Juergen Schmied's avatar
Juergen Schmied committed
527
{
528
  FIXME("(%p),stub!\n",PortHandle);
529
  return STATUS_NOT_IMPLEMENTED;
530 531 532
}

/******************************************************************************
533
 *  NtRegisterThreadTerminatePort	[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
534
 *  ZwRegisterThreadTerminatePort	[NTDLL.@]
535
 */
536
NTSTATUS WINAPI NtRegisterThreadTerminatePort(HANDLE PortHandle)
Juergen Schmied's avatar
Juergen Schmied committed
537
{
538
  FIXME("(%p),stub!\n",PortHandle);
539
  return STATUS_NOT_IMPLEMENTED;
540 541 542
}

/******************************************************************************
543
 *  NtRequestWaitReplyPort		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
544
 *  ZwRequestWaitReplyPort		[NTDLL.@]
545
 */
546 547 548 549
NTSTATUS WINAPI NtRequestWaitReplyPort(
        HANDLE PortHandle,
        PLPC_MESSAGE pLpcMessageIn,
        PLPC_MESSAGE pLpcMessageOut)
550
{
551 552 553 554
  FIXME("(%p,%p,%p),stub!\n",PortHandle,pLpcMessageIn,pLpcMessageOut);
  if(pLpcMessageIn)
  {
    TRACE("Message to send:\n");
555 556 557 558 559 560
    TRACE("\tDataSize            = %u\n",pLpcMessageIn->DataSize);
    TRACE("\tMessageSize         = %u\n",pLpcMessageIn->MessageSize);
    TRACE("\tMessageType         = %u\n",pLpcMessageIn->MessageType);
    TRACE("\tVirtualRangesOffset = %u\n",pLpcMessageIn->VirtualRangesOffset);
    TRACE("\tClientId.UniqueProcess = %p\n",pLpcMessageIn->ClientId.UniqueProcess);
    TRACE("\tClientId.UniqueThread  = %p\n",pLpcMessageIn->ClientId.UniqueThread);
561 562
    TRACE("\tMessageId           = %u\n",pLpcMessageIn->MessageId);
    TRACE("\tSectionSize         = %u\n",pLpcMessageIn->SectionSize);
563
    TRACE("\tData                = %s\n",
Mike McCormack's avatar
Mike McCormack committed
564
      debugstr_an((const char*)pLpcMessageIn->Data,pLpcMessageIn->DataSize));
565
  }
566
  return STATUS_NOT_IMPLEMENTED;
567 568 569
}

/******************************************************************************
570
 *  NtReplyWaitReceivePort	[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
571
 *  ZwReplyWaitReceivePort	[NTDLL.@]
572
 */
573 574 575 576 577
NTSTATUS WINAPI NtReplyWaitReceivePort(
        HANDLE PortHandle,
        PULONG PortIdentifier,
        PLPC_MESSAGE ReplyMessage,
        PLPC_MESSAGE Message)
Juergen Schmied's avatar
Juergen Schmied committed
578
{
579
  FIXME("(%p,%p,%p,%p),stub!\n",PortHandle,PortIdentifier,ReplyMessage,Message);
580
  return STATUS_NOT_IMPLEMENTED;
581 582
}

Juergen Schmied's avatar
Juergen Schmied committed
583 584
/*
 *	Misc
585
 */
Juergen Schmied's avatar
Juergen Schmied committed
586 587

 /******************************************************************************
588
 *  NtSetIntervalProfile	[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
589
 *  ZwSetIntervalProfile	[NTDLL.@]
Juergen Schmied's avatar
Juergen Schmied committed
590
 */
591 592 593 594
NTSTATUS WINAPI NtSetIntervalProfile(
        ULONG Interval,
        KPROFILE_SOURCE Source)
{
595
    FIXME("%u,%d\n", Interval, Source);
596
    return STATUS_SUCCESS;
597
}
Juergen Schmied's avatar
Juergen Schmied committed
598

Juergen Schmied's avatar
Juergen Schmied committed
599
/******************************************************************************
600
 * NtQuerySystemInformation [NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
601
 * ZwQuerySystemInformation [NTDLL.@]
Juergen Schmied's avatar
Juergen Schmied committed
602 603 604 605 606 607
 *
 * ARGUMENTS:
 *  SystemInformationClass	Index to a certain information structure
 *	SystemTimeAdjustmentInformation	SYSTEM_TIME_ADJUSTMENT
 *	SystemCacheInformation		SYSTEM_CACHE_INFORMATION
 *	SystemConfigurationInformation	CONFIGURATION_INFORMATION
608
 *	observed (class/len):
Juergen Schmied's avatar
Juergen Schmied committed
609 610 611 612
 *		0x0/0x2c
 *		0x12/0x18
 *		0x2/0x138
 *		0x8/0x600
613
 *              0x25/0xc
Juergen Schmied's avatar
Juergen Schmied committed
614 615 616
 *  SystemInformation	caller supplies storage for the information structure
 *  Length		size of the structure
 *  ResultLength	Data written
617
 */
Juergen Schmied's avatar
Juergen Schmied committed
618 619 620 621 622
NTSTATUS WINAPI NtQuerySystemInformation(
	IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
	OUT PVOID SystemInformation,
	IN ULONG Length,
	OUT PULONG ResultLength)
623
{
624 625 626
    NTSTATUS    ret = STATUS_SUCCESS;
    ULONG       len = 0;

627
    TRACE("(0x%08x,%p,0x%08x,%p)\n",
628 629 630
          SystemInformationClass,SystemInformation,Length,ResultLength);

    switch (SystemInformationClass)
631
    {
632 633
    case SystemBasicInformation:
        {
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648
            SYSTEM_BASIC_INFORMATION sbi;

            sbi.dwUnknown1 = 0;
            sbi.uKeMaximumIncrement = 0;
            sbi.uPageSize = 1024; /* FIXME */
            sbi.uMmNumberOfPhysicalPages = 12345; /* FIXME */
            sbi.uMmLowestPhysicalPage = 0; /* FIXME */
            sbi.uMmHighestPhysicalPage = 12345; /* FIXME */
            sbi.uAllocationGranularity = 65536; /* FIXME */
            sbi.pLowestUserAddress = 0; /* FIXME */
            sbi.pMmHighestUserAddress = (void*)~0; /* FIXME */
            sbi.uKeActiveProcessors = 1; /* FIXME */
            sbi.bKeNumberProcessors = 1; /* FIXME */
            len = sizeof(sbi);

649
            if ( Length == len)
650
            {
651 652
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &sbi, len);
653 654 655 656
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
        }
        break;
657 658
    case SystemCpuInformation:
        {
659 660 661 662 663 664 665 666 667 668 669
            SYSTEM_CPU_INFORMATION sci;

            /* FIXME: move some code from kernel/cpu.c to process this */
            sci.Architecture = PROCESSOR_ARCHITECTURE_INTEL;
            sci.Level = 6; /* 686, aka Pentium II+ */
            sci.Revision = 0;
            sci.Reserved = 0;
            sci.FeatureSet = 0x1fff;
            len = sizeof(sci);

            if ( Length >= len)
670
            {
671 672
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &sci, len);
673 674 675 676
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
        }
        break;
677 678
    case SystemPerformanceInformation:
        {
679 680 681 682 683 684
            SYSTEM_PERFORMANCE_INFORMATION spi;

            memset(&spi, 0 , sizeof(spi));
            len = sizeof(spi);

            if (Length >= len)
685
            {
686 687
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &spi, len);
688 689 690 691 692 693
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
        }
        break;
    case SystemTimeOfDayInformation:
        {
694 695 696 697 698
            SYSTEM_TIMEOFDAY_INFORMATION sti;

            memset(&sti, 0 , sizeof(sti));

            /* liKeSystemTime, liExpTimeZoneBias, uCurrentTimeZoneId */
699
            sti.liKeBootTime.QuadPart = server_start_time;
700 701

            if (Length <= sizeof(sti))
702
            {
703 704 705
                len = Length;
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &sti, Length);
706 707 708 709 710 711 712 713 714
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
        }
        break;
    case SystemProcessInformation:
        {
            SYSTEM_PROCESS_INFORMATION* spi = (SYSTEM_PROCESS_INFORMATION*)SystemInformation;
            SYSTEM_PROCESS_INFORMATION* last = NULL;
            HANDLE hSnap = 0;
715
            WCHAR procname[1024];
716
            WCHAR* exename;
717
            DWORD wlen = 0;
718
            DWORD procstructlen = 0;
719 720 721

            SERVER_START_REQ( create_snapshot )
            {
722 723 724
                req->flags      = SNAP_PROCESS | SNAP_THREAD;
                req->attributes = 0;
                req->pid        = 0;
725 726 727 728 729 730 731 732 733 734
                if (!(ret = wine_server_call( req ))) hSnap = reply->handle;
            }
            SERVER_END_REQ;
            len = 0;
            while (ret == STATUS_SUCCESS)
            {
                SERVER_START_REQ( next_process )
                {
                    req->handle = hSnap;
                    req->reset = (len == 0);
735
                    wine_server_set_reply( req, procname, sizeof(procname)-sizeof(WCHAR) );
736 737
                    if (!(ret = wine_server_call( req )))
                    {
738 739 740 741 742 743 744 745 746
                        /* Make sure procname is 0 terminated */
                        procname[wine_server_reply_size(reply) / sizeof(WCHAR)] = 0;

                        /* Get only the executable name, not the path */
                        if ((exename = strrchrW(procname, '\\')) != NULL) exename++;
                        else exename = procname;

                        wlen = (strlenW(exename) + 1) * sizeof(WCHAR);

747
                        procstructlen = sizeof(*spi) + wlen + ((reply->threads - 1) * sizeof(SYSTEM_THREAD_INFORMATION));
748

749
                        if (Length >= len + procstructlen)
750
                        {
Paul Vriens's avatar
Paul Vriens committed
751
                            /* ftCreationTime, ftUserTime, ftKernelTime;
752 753 754
                             * vmCounters, ioCounters
                             */
 
755
                            memset(spi, 0, sizeof(*spi));
756

757
                            spi->dwOffset = procstructlen - wlen;
758
                            spi->dwThreadCount = reply->threads;
759

760
                            /* spi->pszProcessName will be set later on */
761

762 763 764 765
                            spi->dwBasePriority = reply->priority;
                            spi->dwProcessID = (DWORD)reply->pid;
                            spi->dwParentProcessID = (DWORD)reply->ppid;
                            spi->dwHandleCount = reply->handles;
766

767
                            /* spi->ti will be set later on */
768

769
                            len += procstructlen;
770 771 772 773 774
                        }
                        else ret = STATUS_INFO_LENGTH_MISMATCH;
                    }
                }
                SERVER_END_REQ;
775
 
776 777 778 779 780
                if (ret != STATUS_SUCCESS)
                {
                    if (ret == STATUS_NO_MORE_FILES) ret = STATUS_SUCCESS;
                    break;
                }
781
                else /* Length is already checked for */
782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800
                {
                    int     i, j;

                    /* set thread info */
                    i = j = 0;
                    while (ret == STATUS_SUCCESS)
                    {
                        SERVER_START_REQ( next_thread )
                        {
                            req->handle = hSnap;
                            req->reset = (j == 0);
                            if (!(ret = wine_server_call( req )))
                            {
                                j++;
                                if (reply->pid == spi->dwProcessID)
                                {
                                    /* ftKernelTime, ftUserTime, ftCreateTime;
                                     * dwTickCount, dwStartAddress
                                     */
Paul Vriens's avatar
Paul Vriens committed
801 802 803

                                    memset(&spi->ti[i], 0, sizeof(spi->ti));

804 805 806 807 808 809 810 811 812 813 814 815 816
                                    spi->ti[i].dwOwningPID = reply->pid;
                                    spi->ti[i].dwThreadID  = reply->tid;
                                    spi->ti[i].dwCurrentPriority = reply->base_pri + reply->delta_pri;
                                    spi->ti[i].dwBasePriority = reply->base_pri;
                                    i++;
                                }
                            }
                        }
                        SERVER_END_REQ;
                    }
                    if (ret == STATUS_NO_MORE_FILES) ret = STATUS_SUCCESS;

                    /* now append process name */
817 818 819
                    spi->ProcessName.Buffer = (WCHAR*)((char*)spi + spi->dwOffset);
                    spi->ProcessName.Length = wlen - sizeof(WCHAR);
                    spi->ProcessName.MaximumLength = wlen;
820
                    memcpy( spi->ProcessName.Buffer, exename, wlen );
821 822 823 824 825 826 827 828 829 830 831 832
                    spi->dwOffset += wlen;

                    last = spi;
                    spi = (SYSTEM_PROCESS_INFORMATION*)((char*)spi + spi->dwOffset);
                }
            }
            if (ret == STATUS_SUCCESS && last) last->dwOffset = 0;
            if (hSnap) NtClose(hSnap);
        }
        break;
    case SystemProcessorPerformanceInformation:
        {
833 834 835 836 837 838
            SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION sppi;

            memset(&sppi, 0 , sizeof(sppi)); /* FIXME */
            len = sizeof(sppi);

            if (Length >= len)
839
            {
840 841
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &sppi, len);
842 843 844 845
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
        }
        break;
846
    case SystemModuleInformation:
847
        {
848
            SYSTEM_MODULE_INFORMATION smi;
849

850 851
            memset(&smi, 0, sizeof(smi));
            len = sizeof(smi);
852 853 854 855

            if ( Length >= len)
            {
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
856
                else memcpy( SystemInformation, &smi, len);
857 858 859 860
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
        }
        break;
861 862 863 864 865 866
    case SystemHandleInformation:
        {
            SYSTEM_HANDLE_INFORMATION shi;

            memset(&shi, 0, sizeof(shi));
            len = sizeof(shi);
867

868 869 870 871 872 873 874 875
            if ( Length >= len)
            {
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &shi, len);
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
        }
        break;
876 877
    case SystemCacheInformation:
        {
878 879 880 881 882 883
            SYSTEM_CACHE_INFORMATION sci;

            memset(&sci, 0, sizeof(sci)); /* FIXME */
            len = sizeof(sci);

            if ( Length >= len)
884
            {
885 886
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &sci, len);
887 888 889 890
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
        }
        break;
891 892 893 894 895 896 897 898 899 900 901 902 903 904 905
    case SystemInterruptInformation:
        {
            SYSTEM_INTERRUPT_INFORMATION sii;

            memset(&sii, 0, sizeof(sii));
            len = sizeof(sii);

            if ( Length >= len)
            {
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &sii, len);
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
        }
        break;
906 907
    case SystemKernelDebuggerInformation:
        {
908 909 910 911 912 913 914
            SYSTEM_KERNEL_DEBUGGER_INFORMATION skdi;

            skdi.DebuggerEnabled = FALSE;
            skdi.DebuggerNotPresent = TRUE;
            len = sizeof(skdi);

            if ( Length >= len)
915
            {
916 917
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &skdi, len);
918 919 920 921
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
        }
        break;
922 923
    case SystemRegistryQuotaInformation:
        {
924 925 926 927 928 929 930 931 932 933 934 935 936
	    /* Something to do with the size of the registry             *
	     * Since we don't have a size limitation, fake it            *
	     * This is almost certainly wrong.                           *
	     * This sets each of the three words in the struct to 32 MB, *
	     * which is enough to make the IE 5 installer happy.         */
            SYSTEM_REGISTRY_QUOTA_INFORMATION srqi;

            srqi.RegistryQuotaAllowed = 0x2000000;
            srqi.RegistryQuotaUsed = 0x200000;
            srqi.Reserved1 = (void*)0x200000;
            len = sizeof(srqi);

            if ( Length >= len)
937
            {
938 939 940 941 942 943
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else
                {
                    FIXME("SystemRegistryQuotaInformation: faking max registry size of 32 MB\n");
                    memcpy( SystemInformation, &srqi, len);
                }
944 945 946
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
        }
947 948
	break;
    default:
949
	FIXME("(0x%08x,%p,0x%08x,%p) stub\n",
950
	      SystemInformationClass,SystemInformation,Length,ResultLength);
951 952 953 954 955 956

        /* Several Information Classes are not implemented on Windows and return 2 different values 
         * STATUS_NOT_IMPLEMENTED or STATUS_INVALID_INFO_CLASS
         * in 95% of the cases it's STATUS_INVALID_INFO_CLASS, so use this as the default
        */
        ret = STATUS_INVALID_INFO_CLASS;
957
    }
958

959
    if (ResultLength) *ResultLength = len;
960

961
    return ret;
Juergen Schmied's avatar
Juergen Schmied committed
962 963
}

964 965 966 967 968 969
/******************************************************************************
 * NtSetSystemInformation [NTDLL.@]
 * ZwSetSystemInformation [NTDLL.@]
 */
NTSTATUS WINAPI NtSetSystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, PVOID SystemInformation, ULONG Length)
{
970
    FIXME("(0x%08x,%p,0x%08x) stub\n",SystemInformationClass,SystemInformation,Length);
971 972
    return STATUS_SUCCESS;
}
973

974
/******************************************************************************
975
 *  NtCreatePagingFile		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
976
 *  ZwCreatePagingFile		[NTDLL.@]
977
 */
Juergen Schmied's avatar
Juergen Schmied committed
978
NTSTATUS WINAPI NtCreatePagingFile(
979
	PUNICODE_STRING PageFileName,
980 981
	PLARGE_INTEGER MinimumSize,
	PLARGE_INTEGER MaximumSize,
982
	PLARGE_INTEGER ActualSize)
983
{
984
    FIXME("(%p %p %p %p) stub\n", PageFileName, MinimumSize, MaximumSize, ActualSize);
985
    return STATUS_SUCCESS;
986 987
}

988
/******************************************************************************
989
 *  NtDisplayString				[NTDLL.@]
990
 *
991 992
 * writes a string to the nt-textmode screen eg. during startup
 */
993
NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
994
{
995 996 997 998 999 1000 1001 1002 1003
    STRING stringA;
    NTSTATUS ret;

    if (!(ret = RtlUnicodeStringToAnsiString( &stringA, string, TRUE )))
    {
        MESSAGE( "%.*s", stringA.Length, stringA.Buffer );
        RtlFreeAnsiString( &stringA );
    }
    return ret;
1004
}
1005

1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
/******************************************************************************
 *  NtInitiatePowerAction                       [NTDLL.@]
 *
 */
NTSTATUS WINAPI NtInitiatePowerAction(
	IN POWER_ACTION SystemAction,
	IN SYSTEM_POWER_STATE MinSystemState,
	IN ULONG Flags,
	IN BOOLEAN Asynchronous)
{
1016
        FIXME("(%d,%d,0x%08x,%d),stub\n",
1017 1018 1019 1020 1021
		SystemAction,MinSystemState,Flags,Asynchronous);
        return STATUS_NOT_IMPLEMENTED;
}
	

1022
/******************************************************************************
1023
 *  NtPowerInformation				[NTDLL.@]
1024
 *
1025
 */
1026 1027 1028 1029 1030 1031
NTSTATUS WINAPI NtPowerInformation(
	IN POWER_INFORMATION_LEVEL InformationLevel,
	IN PVOID lpInputBuffer,
	IN ULONG nInputBufferSize,
	IN PVOID lpOutputBuffer,
	IN ULONG nOutputBufferSize)
1032
{
1033
	TRACE("(%d,%p,%d,%p,%d)\n",
1034
		InformationLevel,lpInputBuffer,nInputBufferSize,lpOutputBuffer,nOutputBufferSize);
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078
	switch(InformationLevel) {
		case SystemPowerCapabilities: {
			PSYSTEM_POWER_CAPABILITIES PowerCaps = (PSYSTEM_POWER_CAPABILITIES)lpOutputBuffer;
			FIXME("semi-stub: SystemPowerCapabilities\n");
			if (nOutputBufferSize < sizeof(SYSTEM_POWER_CAPABILITIES))
				return STATUS_BUFFER_TOO_SMALL;
			/* FIXME: These values are based off a native XP desktop, should probably use APM/ACPI to get the 'real' values */
			PowerCaps->PowerButtonPresent = TRUE;
			PowerCaps->SleepButtonPresent = FALSE;
			PowerCaps->LidPresent = FALSE;
			PowerCaps->SystemS1 = TRUE;
			PowerCaps->SystemS2 = FALSE;
			PowerCaps->SystemS3 = FALSE;
			PowerCaps->SystemS4 = TRUE;
			PowerCaps->SystemS5 = TRUE;
			PowerCaps->HiberFilePresent = TRUE;
			PowerCaps->FullWake = TRUE;
			PowerCaps->VideoDimPresent = FALSE;
			PowerCaps->ApmPresent = FALSE;
			PowerCaps->UpsPresent = FALSE;
			PowerCaps->ThermalControl = FALSE;
			PowerCaps->ProcessorThrottle = FALSE;
			PowerCaps->ProcessorMinThrottle = 100;
			PowerCaps->ProcessorMaxThrottle = 100;
			PowerCaps->DiskSpinDown = TRUE;
			PowerCaps->SystemBatteriesPresent = FALSE;
			PowerCaps->BatteriesAreShortTerm = FALSE;
			PowerCaps->BatteryScale[0].Granularity = 0;
			PowerCaps->BatteryScale[0].Capacity = 0;
			PowerCaps->BatteryScale[1].Granularity = 0;
			PowerCaps->BatteryScale[1].Capacity = 0;
			PowerCaps->BatteryScale[2].Granularity = 0;
			PowerCaps->BatteryScale[2].Capacity = 0;
			PowerCaps->AcOnLineWake = PowerSystemUnspecified;
			PowerCaps->SoftLidWake = PowerSystemUnspecified;
			PowerCaps->RtcWake = PowerSystemSleeping1;
			PowerCaps->MinDeviceWakeState = PowerSystemUnspecified;
			PowerCaps->DefaultLowLatencyWake = PowerSystemUnspecified;
			return STATUS_SUCCESS;
		}
		default:
			FIXME("Unimplemented NtPowerInformation action: %d\n", InformationLevel);
			return STATUS_NOT_IMPLEMENTED;
	}
1079
}
1080

1081 1082 1083 1084
/******************************************************************************
 *  NtShutdownSystem				[NTDLL.@]
 *
 */
1085
NTSTATUS WINAPI NtShutdownSystem(SHUTDOWN_ACTION Action)
1086
{
1087 1088
    FIXME("%d\n",Action);
    return STATUS_SUCCESS;
1089 1090
}

1091
/******************************************************************************
1092
 *  NtAllocateLocallyUniqueId (NTDLL.@)
1093 1094 1095
 */
NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
{
1096
    NTSTATUS status;
1097

1098
    TRACE("%p\n", Luid);
1099 1100 1101

    if (!Luid)
        return STATUS_ACCESS_VIOLATION;
1102

1103 1104 1105 1106 1107 1108 1109 1110 1111 1112
    SERVER_START_REQ( allocate_locally_unique_id )
    {
        status = wine_server_call( req );
        if (!status)
        {
            Luid->LowPart = reply->luid.low_part;
            Luid->HighPart = reply->luid.high_part;
        }
    }
    SERVER_END_REQ;
Francois Gouget's avatar
Francois Gouget committed
1113

1114
    return status;
1115
}
1116 1117 1118 1119 1120 1121 1122

/******************************************************************************
 *        VerSetConditionMask   (NTDLL.@)
 */
ULONGLONG WINAPI VerSetConditionMask( ULONGLONG dwlConditionMask, DWORD dwTypeBitMask,
                                      BYTE dwConditionMask)
{
1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144
    if(dwTypeBitMask == 0)
	return dwlConditionMask;
    dwConditionMask &= 0x07;
    if(dwConditionMask == 0)
	return dwlConditionMask;

    if(dwTypeBitMask & VER_PRODUCT_TYPE)
	dwlConditionMask |= dwConditionMask << 7*3;
    else if (dwTypeBitMask & VER_SUITENAME)
	dwlConditionMask |= dwConditionMask << 6*3;
    else if (dwTypeBitMask & VER_SERVICEPACKMAJOR)
	dwlConditionMask |= dwConditionMask << 5*3;
    else if (dwTypeBitMask & VER_SERVICEPACKMINOR)
	dwlConditionMask |= dwConditionMask << 4*3;
    else if (dwTypeBitMask & VER_PLATFORMID)
	dwlConditionMask |= dwConditionMask << 3*3;
    else if (dwTypeBitMask & VER_BUILDNUMBER)
	dwlConditionMask |= dwConditionMask << 2*3;
    else if (dwTypeBitMask & VER_MAJORVERSION)
	dwlConditionMask |= dwConditionMask << 1*3;
    else if (dwTypeBitMask & VER_MINORVERSION)
	dwlConditionMask |= dwConditionMask << 0*3;
1145 1146
    return dwlConditionMask;
}
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156

/******************************************************************************
 *  NtAccessCheckAndAuditAlarm   (NTDLL.@)
 *  ZwAccessCheckAndAuditAlarm   (NTDLL.@)
 */
NTSTATUS WINAPI NtAccessCheckAndAuditAlarm(PUNICODE_STRING SubsystemName, HANDLE HandleId, PUNICODE_STRING ObjectTypeName,
                                           PUNICODE_STRING ObjectName, PSECURITY_DESCRIPTOR SecurityDescriptor,
                                           ACCESS_MASK DesiredAccess, PGENERIC_MAPPING GenericMapping, BOOLEAN ObjectCreation,
                                           PACCESS_MASK GrantedAccess, PBOOLEAN AccessStatus, PBOOLEAN GenerateOnClose)
{
1157
    FIXME("(%s, %p, %s, %p, 0x%08x, %p, %d, %p, %p, %p), stub\n", debugstr_us(SubsystemName), HandleId,
1158 1159 1160 1161 1162
          debugstr_us(ObjectTypeName), SecurityDescriptor, DesiredAccess, GenericMapping, ObjectCreation,
          GrantedAccess, AccessStatus, GenerateOnClose);

    return STATUS_NOT_IMPLEMENTED;
}