nt.c 41.1 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
#define NONAMELESSUNION
31 32
#include "ntstatus.h"
#define WIN32_NO_STATUS
33
#include "wine/debug.h"
34
#include "wine/unicode.h"
35
#include "windef.h"
36
#include "winternl.h"
37
#include "ntdll_misc.h"
38
#include "wine/server.h"
Juergen Schmied's avatar
Juergen Schmied committed
39

40
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
41

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

46
/******************************************************************************
47
 *  NtDuplicateToken		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
48
 *  ZwDuplicateToken		[NTDLL.@]
49
 */
Juergen Schmied's avatar
Juergen Schmied committed
50 51 52 53 54 55 56
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)
57
{
58 59
    NTSTATUS status;

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

65 66 67 68 69 70 71 72 73 74
    if (ObjectAttributes && ObjectAttributes->SecurityQualityOfService)
    {
        SECURITY_QUALITY_OF_SERVICE *SecurityQOS = ObjectAttributes->SecurityQualityOfService;
        TRACE("ObjectAttributes->SecurityQualityOfService = {%d, %d, %d, %s}\n",
            SecurityQOS->Length, SecurityQOS->ImpersonationLevel,
            SecurityQOS->ContextTrackingMode,
            SecurityQOS->EffectiveOnly ? "TRUE" : "FALSE");
        ImpersonationLevel = SecurityQOS->ImpersonationLevel;
    }

75 76
    SERVER_START_REQ( duplicate_token )
    {
77 78 79 80
        req->handle              = ExistingToken;
        req->access              = DesiredAccess;
        req->attributes          = ObjectAttributes ? ObjectAttributes->Attributes : 0;
        req->primary             = (TokenType == TokenPrimary);
81 82 83 84 85 86 87
        req->impersonation_level = ImpersonationLevel;
        status = wine_server_call( req );
        if (!status) *NewToken = reply->new_handle;
    }
    SERVER_END_REQ;

    return status;
88 89 90
}

/******************************************************************************
91
 *  NtOpenProcessToken		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
92
 *  ZwOpenProcessToken		[NTDLL.@]
93
 */
Juergen Schmied's avatar
Juergen Schmied committed
94 95
NTSTATUS WINAPI NtOpenProcessToken(
	HANDLE ProcessHandle,
96 97
	DWORD DesiredAccess,
	HANDLE *TokenHandle)
98
{
99 100
    NTSTATUS ret;

101
    TRACE("(%p,0x%08x,%p)\n", ProcessHandle,DesiredAccess, TokenHandle);
102 103 104

    SERVER_START_REQ( open_token )
    {
105 106 107 108
        req->handle     = ProcessHandle;
        req->access     = DesiredAccess;
        req->attributes = 0;
        req->flags      = 0;
109 110 111 112 113 114
        ret = wine_server_call( req );
        if (!ret) *TokenHandle = reply->token;
    }
    SERVER_END_REQ;

    return ret;
115 116 117
}

/******************************************************************************
118
 *  NtOpenThreadToken		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
119
 *  ZwOpenThreadToken		[NTDLL.@]
120
 */
Juergen Schmied's avatar
Juergen Schmied committed
121 122
NTSTATUS WINAPI NtOpenThreadToken(
	HANDLE ThreadHandle,
123
	DWORD DesiredAccess,
Juergen Schmied's avatar
Juergen Schmied committed
124
	BOOLEAN OpenAsSelf,
125
	HANDLE *TokenHandle)
Juergen Schmied's avatar
Juergen Schmied committed
126
{
127 128
    NTSTATUS ret;

129
    TRACE("(%p,0x%08x,0x%08x,%p)\n",
130 131 132 133
          ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);

    SERVER_START_REQ( open_token )
    {
134 135 136 137
        req->handle     = ThreadHandle;
        req->access     = DesiredAccess;
        req->attributes = 0;
        req->flags      = OPEN_TOKEN_THREAD;
138 139 140 141 142 143 144
        if (OpenAsSelf) req->flags |= OPEN_TOKEN_AS_SELF;
        ret = wine_server_call( req );
        if (!ret) *TokenHandle = reply->token;
    }
    SERVER_END_REQ;

    return ret;
145 146 147
}

/******************************************************************************
148
 *  NtAdjustPrivilegesToken		[NTDLL.@]
149
 *  ZwAdjustPrivilegesToken		[NTDLL.@]
150 151
 *
 * FIXME: parameters unsafe
152 153
 */
NTSTATUS WINAPI NtAdjustPrivilegesToken(
154
	IN HANDLE TokenHandle,
155
	IN BOOLEAN DisableAllPrivileges,
156 157 158 159 160
	IN PTOKEN_PRIVILEGES NewState,
	IN DWORD BufferLength,
	OUT PTOKEN_PRIVILEGES PreviousState,
	OUT PDWORD ReturnLength)
{
161 162
    NTSTATUS ret;

163
    TRACE("(%p,0x%08x,%p,0x%08x,%p,%p)\n",
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
        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;
189 190 191
}

/******************************************************************************
192
*  NtQueryInformationToken		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
193
*  ZwQueryInformationToken		[NTDLL.@]
Juergen Schmied's avatar
Juergen Schmied committed
194
*
195 196 197 198 199
* NOTES
*  Buffer for TokenUser:
*   0x00 TOKEN_USER the PSID field points to the SID
*   0x08 SID
*
Juergen Schmied's avatar
Juergen Schmied committed
200 201 202
*/
NTSTATUS WINAPI NtQueryInformationToken(
	HANDLE token,
203 204 205 206
	TOKEN_INFORMATION_CLASS tokeninfoclass,
	PVOID tokeninfo,
	ULONG tokeninfolength,
	PULONG retlen )
207
{
208
    ULONG len;
209
    NTSTATUS status = STATUS_SUCCESS;
210

211
    TRACE("(%p,%d,%p,%d,%p)\n",
212 213 214 215 216
          token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);

    switch (tokeninfoclass)
    {
    case TokenOwner:
217
        len = sizeof(TOKEN_OWNER) + sizeof(SID);
218 219 220 221 222 223 224 225 226 227 228 229 230 231
        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:
232 233
        len = sizeof(SECURITY_IMPERSONATION_LEVEL);
        break;
234
    case TokenStatistics:
235 236
        len = sizeof(TOKEN_STATISTICS);
        break;
237 238
    default:
        len = 0;
239
    }
240

241
    if (retlen) *retlen = len;
242 243

    if (tokeninfolength < len)
244
        return STATUS_BUFFER_TOO_SMALL;
245 246 247 248

    switch (tokeninfoclass)
    {
    case TokenUser:
249
        SERVER_START_REQ( get_token_user )
250 251 252
        {
            TOKEN_USER * tuser = tokeninfo;
            PSID sid = (PSID) (tuser + 1);
253 254 255 256 257
            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 );
258
            if (retlen) *retlen = reply->user_len + sizeof(TOKEN_USER);
259 260 261 262 263
            if (status == STATUS_SUCCESS)
            {
                tuser->User.Sid = sid;
                tuser->User.Attributes = 0;
            }
264
        }
265
        SERVER_END_REQ;
266 267
        break;
    case TokenGroups:
268 269 270 271 272 273 274 275 276 277
    {
        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
278
        {
279 280 281
            SERVER_START_REQ( get_token_groups )
            {
                TOKEN_GROUPS *groups = tokeninfo;
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 318 319 320 321 322 323 324 325 326 327 328
                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);
329
        break;
330
    }
331 332 333 334 335 336 337 338 339 340 341 342 343
    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;
344
    case TokenPrivileges:
345
        SERVER_START_REQ( get_token_privileges )
346 347
        {
            TOKEN_PRIVILEGES *tpriv = tokeninfo;
348 349 350 351
            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 );
352
            if (retlen) *retlen = FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) + reply->len;
353
            if (tpriv) tpriv->PrivilegeCount = reply->len / sizeof(LUID_AND_ATTRIBUTES);
354
        }
355
        SERVER_END_REQ;
356
        break;
357 358 359 360 361 362 363 364 365 366 367
    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;
368 369 370 371 372 373 374 375 376 377 378
    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;
379 380 381 382 383 384 385 386 387 388 389 390
    case TokenStatistics:
        SERVER_START_REQ( get_token_statistics )
        {
            TOKEN_STATISTICS *statistics = tokeninfo;
            req->handle = token;
            status = wine_server_call( req );
            if (status == STATUS_SUCCESS)
            {
                statistics->TokenId.LowPart  = reply->token_id.low_part;
                statistics->TokenId.HighPart = reply->token_id.high_part;
                statistics->AuthenticationId.LowPart  = 0; /* FIXME */
                statistics->AuthenticationId.HighPart = 0; /* FIXME */
391 392
                statistics->ExpirationTime.u.HighPart = 0x7fffffff;
                statistics->ExpirationTime.u.LowPart  = 0xffffffff;
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
                statistics->TokenType = reply->primary ? TokenPrimary : TokenImpersonation;
                statistics->ImpersonationLevel = reply->impersonation_level;

                /* kernel information not relevant to us */
                statistics->DynamicCharged = 0;
                statistics->DynamicAvailable = 0;

                statistics->GroupCount = reply->group_count;
                statistics->PrivilegeCount = reply->privilege_count;
                statistics->ModifiedId.LowPart  = reply->modified_id.low_part;
                statistics->ModifiedId.HighPart = reply->modified_id.high_part;
            }
        }
        SERVER_END_REQ;
        break;
    case TokenType:
        SERVER_START_REQ( get_token_statistics )
        {
            TOKEN_TYPE *token_type = tokeninfo;
            req->handle = token;
            status = wine_server_call( req );
            if (status == STATUS_SUCCESS)
                *token_type = reply->primary ? TokenPrimary : TokenImpersonation;
        }
        SERVER_END_REQ;
        break;
419 420
    default:
        {
421
            ERR("Unhandled Token Information class %d!\n", tokeninfoclass);
422 423
            return STATUS_NOT_IMPLEMENTED;
        }
424
    }
425
    return status;
426 427
}

428 429 430 431 432 433 434 435 436 437
/******************************************************************************
*  NtSetInformationToken		[NTDLL.@]
*  ZwSetInformationToken		[NTDLL.@]
*/
NTSTATUS WINAPI NtSetInformationToken(
        HANDLE TokenHandle,
        TOKEN_INFORMATION_CLASS TokenInformationClass,
        PVOID TokenInformation,
        ULONG TokenInformationLength)
{
438
    FIXME("%p %d %p %u\n", TokenHandle, TokenInformationClass,
439 440 441 442
          TokenInformation, TokenInformationLength);
    return STATUS_NOT_IMPLEMENTED;
}

443 444 445 446 447 448 449 450 451 452 453 454
/******************************************************************************
*  NtAdjustGroupsToken		[NTDLL.@]
*  ZwAdjustGroupsToken		[NTDLL.@]
*/
NTSTATUS WINAPI NtAdjustGroupsToken(
        HANDLE TokenHandle,
        BOOLEAN ResetToDefault,
        PTOKEN_GROUPS NewState,
        ULONG BufferLength,
        PTOKEN_GROUPS PreviousState,
        PULONG ReturnLength)
{
455
    FIXME("%p %d %p %u %p %p\n", TokenHandle, ResetToDefault,
456 457 458 459
          NewState, BufferLength, PreviousState, ReturnLength);
    return STATUS_NOT_IMPLEMENTED;
}

460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
/******************************************************************************
*  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
488 489
/*
 *	Section
490
 */
491

492
/******************************************************************************
493
 *  NtQuerySection	[NTDLL.@]
494
 */
Juergen Schmied's avatar
Juergen Schmied committed
495 496
NTSTATUS WINAPI NtQuerySection(
	IN HANDLE SectionHandle,
497
	IN SECTION_INFORMATION_CLASS SectionInformationClass,
Juergen Schmied's avatar
Juergen Schmied committed
498 499 500
	OUT PVOID SectionInformation,
	IN ULONG Length,
	OUT PULONG ResultLength)
501
{
502
	FIXME("(%p,%d,%p,0x%08x,%p) stub!\n",
Juergen Schmied's avatar
Juergen Schmied committed
503
	SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
504 505 506
	return 0;
}

Juergen Schmied's avatar
Juergen Schmied committed
507 508
/*
 *	ports
509 510 511
 */

/******************************************************************************
512
 *  NtCreatePort		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
513
 *  ZwCreatePort		[NTDLL.@]
514
 */
515
NTSTATUS WINAPI NtCreatePort(PHANDLE PortHandle,POBJECT_ATTRIBUTES ObjectAttributes,
516
                             ULONG MaxConnectInfoLength,ULONG MaxDataLength,PULONG reserved)
517
{
518
  FIXME("(%p,%p,%u,%u,%p),stub!\n",PortHandle,ObjectAttributes,
519
        MaxConnectInfoLength,MaxDataLength,reserved);
520
  return STATUS_NOT_IMPLEMENTED;
521 522 523
}

/******************************************************************************
524
 *  NtConnectPort		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
525
 *  ZwConnectPort		[NTDLL.@]
526
 */
527 528 529 530 531 532 533 534 535
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)
536
{
537 538 539 540 541 542
    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));
543
    return STATUS_NOT_IMPLEMENTED;
544 545 546
}

/******************************************************************************
547
 *  NtListenPort		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
548
 *  ZwListenPort		[NTDLL.@]
549
 */
550
NTSTATUS WINAPI NtListenPort(HANDLE PortHandle,PLPC_MESSAGE pLpcMessage)
Juergen Schmied's avatar
Juergen Schmied committed
551
{
552
  FIXME("(%p,%p),stub!\n",PortHandle,pLpcMessage);
553
  return STATUS_NOT_IMPLEMENTED;
554 555 556
}

/******************************************************************************
557
 *  NtAcceptConnectPort	[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
558
 *  ZwAcceptConnectPort	[NTDLL.@]
559
 */
560 561 562 563 564 565 566
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
567
{
568
  FIXME("(%p,%u,%p,%d,%p,%p),stub!\n",
569
        PortHandle,PortIdentifier,pLpcMessage,Accept,WriteSection,ReadSection);
570
  return STATUS_NOT_IMPLEMENTED;
571 572 573
}

/******************************************************************************
574
 *  NtCompleteConnectPort	[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
575
 *  ZwCompleteConnectPort	[NTDLL.@]
576
 */
577
NTSTATUS WINAPI NtCompleteConnectPort(HANDLE PortHandle)
Juergen Schmied's avatar
Juergen Schmied committed
578
{
579
  FIXME("(%p),stub!\n",PortHandle);
580
  return STATUS_NOT_IMPLEMENTED;
581 582 583
}

/******************************************************************************
584
 *  NtRegisterThreadTerminatePort	[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
585
 *  ZwRegisterThreadTerminatePort	[NTDLL.@]
586
 */
587
NTSTATUS WINAPI NtRegisterThreadTerminatePort(HANDLE PortHandle)
Juergen Schmied's avatar
Juergen Schmied committed
588
{
589
  FIXME("(%p),stub!\n",PortHandle);
590
  return STATUS_NOT_IMPLEMENTED;
591 592 593
}

/******************************************************************************
594
 *  NtRequestWaitReplyPort		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
595
 *  ZwRequestWaitReplyPort		[NTDLL.@]
596
 */
597 598 599 600
NTSTATUS WINAPI NtRequestWaitReplyPort(
        HANDLE PortHandle,
        PLPC_MESSAGE pLpcMessageIn,
        PLPC_MESSAGE pLpcMessageOut)
601
{
602 603 604 605
  FIXME("(%p,%p,%p),stub!\n",PortHandle,pLpcMessageIn,pLpcMessageOut);
  if(pLpcMessageIn)
  {
    TRACE("Message to send:\n");
606 607 608 609 610 611
    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);
612 613
    TRACE("\tMessageId           = %u\n",pLpcMessageIn->MessageId);
    TRACE("\tSectionSize         = %u\n",pLpcMessageIn->SectionSize);
614
    TRACE("\tData                = %s\n",
Mike McCormack's avatar
Mike McCormack committed
615
      debugstr_an((const char*)pLpcMessageIn->Data,pLpcMessageIn->DataSize));
616
  }
617
  return STATUS_NOT_IMPLEMENTED;
618 619 620
}

/******************************************************************************
621
 *  NtReplyWaitReceivePort	[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
622
 *  ZwReplyWaitReceivePort	[NTDLL.@]
623
 */
624 625 626 627 628
NTSTATUS WINAPI NtReplyWaitReceivePort(
        HANDLE PortHandle,
        PULONG PortIdentifier,
        PLPC_MESSAGE ReplyMessage,
        PLPC_MESSAGE Message)
Juergen Schmied's avatar
Juergen Schmied committed
629
{
630
  FIXME("(%p,%p,%p,%p),stub!\n",PortHandle,PortIdentifier,ReplyMessage,Message);
631
  return STATUS_NOT_IMPLEMENTED;
632 633
}

Juergen Schmied's avatar
Juergen Schmied committed
634 635
/*
 *	Misc
636
 */
Juergen Schmied's avatar
Juergen Schmied committed
637 638

 /******************************************************************************
639
 *  NtSetIntervalProfile	[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
640
 *  ZwSetIntervalProfile	[NTDLL.@]
Juergen Schmied's avatar
Juergen Schmied committed
641
 */
642 643 644 645
NTSTATUS WINAPI NtSetIntervalProfile(
        ULONG Interval,
        KPROFILE_SOURCE Source)
{
646
    FIXME("%u,%d\n", Interval, Source);
647
    return STATUS_SUCCESS;
648
}
Juergen Schmied's avatar
Juergen Schmied committed
649

Juergen Schmied's avatar
Juergen Schmied committed
650
/******************************************************************************
651
 * NtQuerySystemInformation [NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
652
 * ZwQuerySystemInformation [NTDLL.@]
Juergen Schmied's avatar
Juergen Schmied committed
653 654 655 656 657 658
 *
 * ARGUMENTS:
 *  SystemInformationClass	Index to a certain information structure
 *	SystemTimeAdjustmentInformation	SYSTEM_TIME_ADJUSTMENT
 *	SystemCacheInformation		SYSTEM_CACHE_INFORMATION
 *	SystemConfigurationInformation	CONFIGURATION_INFORMATION
659
 *	observed (class/len):
Juergen Schmied's avatar
Juergen Schmied committed
660 661 662 663
 *		0x0/0x2c
 *		0x12/0x18
 *		0x2/0x138
 *		0x8/0x600
664
 *              0x25/0xc
Juergen Schmied's avatar
Juergen Schmied committed
665 666 667
 *  SystemInformation	caller supplies storage for the information structure
 *  Length		size of the structure
 *  ResultLength	Data written
668
 */
Juergen Schmied's avatar
Juergen Schmied committed
669 670 671 672 673
NTSTATUS WINAPI NtQuerySystemInformation(
	IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
	OUT PVOID SystemInformation,
	IN ULONG Length,
	OUT PULONG ResultLength)
674
{
675 676 677
    NTSTATUS    ret = STATUS_SUCCESS;
    ULONG       len = 0;

678
    TRACE("(0x%08x,%p,0x%08x,%p)\n",
679 680 681
          SystemInformationClass,SystemInformation,Length,ResultLength);

    switch (SystemInformationClass)
682
    {
683 684
    case SystemBasicInformation:
        {
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699
            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);

700
            if ( Length == len)
701
            {
702 703
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &sbi, len);
704 705 706 707
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
        }
        break;
708 709
    case SystemCpuInformation:
        {
710 711 712 713 714 715 716 717 718 719 720
            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)
721
            {
722 723
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &sci, len);
724 725 726 727
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
        }
        break;
728 729
    case SystemPerformanceInformation:
        {
730 731 732 733 734 735
            SYSTEM_PERFORMANCE_INFORMATION spi;

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

            if (Length >= len)
736
            {
737 738
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &spi, len);
739 740
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
741
            FIXME("info_class SYSTEM_PERFORMANCE_INFORMATION\n");
742 743 744 745
        }
        break;
    case SystemTimeOfDayInformation:
        {
746 747 748 749 750
            SYSTEM_TIMEOFDAY_INFORMATION sti;

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

            /* liKeSystemTime, liExpTimeZoneBias, uCurrentTimeZoneId */
751
            sti.liKeBootTime.QuadPart = server_start_time;
752 753

            if (Length <= sizeof(sti))
754
            {
755 756 757
                len = Length;
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &sti, Length);
758 759 760 761 762 763 764 765 766
            }
            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;
767
            WCHAR procname[1024];
768
            WCHAR* exename;
769
            DWORD wlen = 0;
770
            DWORD procstructlen = 0;
771 772 773

            SERVER_START_REQ( create_snapshot )
            {
774 775 776
                req->flags      = SNAP_PROCESS | SNAP_THREAD;
                req->attributes = 0;
                req->pid        = 0;
777 778 779 780 781 782 783 784 785 786
                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);
787
                    wine_server_set_reply( req, procname, sizeof(procname)-sizeof(WCHAR) );
788 789
                    if (!(ret = wine_server_call( req )))
                    {
790 791 792 793 794 795 796 797 798
                        /* 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);

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

801
                        if (Length >= len + procstructlen)
802
                        {
Paul Vriens's avatar
Paul Vriens committed
803
                            /* ftCreationTime, ftUserTime, ftKernelTime;
804 805 806
                             * vmCounters, ioCounters
                             */
 
807
                            memset(spi, 0, sizeof(*spi));
808

809
                            spi->dwOffset = procstructlen - wlen;
810
                            spi->dwThreadCount = reply->threads;
811

812
                            /* spi->pszProcessName will be set later on */
813

814 815 816 817
                            spi->dwBasePriority = reply->priority;
                            spi->dwProcessID = (DWORD)reply->pid;
                            spi->dwParentProcessID = (DWORD)reply->ppid;
                            spi->dwHandleCount = reply->handles;
818

819
                            /* spi->ti will be set later on */
820

821
                            len += procstructlen;
822 823 824 825 826
                        }
                        else ret = STATUS_INFO_LENGTH_MISMATCH;
                    }
                }
                SERVER_END_REQ;
827
 
828 829 830 831 832
                if (ret != STATUS_SUCCESS)
                {
                    if (ret == STATUS_NO_MORE_FILES) ret = STATUS_SUCCESS;
                    break;
                }
833
                else /* Length is already checked for */
834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852
                {
                    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
853 854 855

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

856 857 858 859 860 861 862 863 864 865 866 867 868
                                    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 */
869 870 871
                    spi->ProcessName.Buffer = (WCHAR*)((char*)spi + spi->dwOffset);
                    spi->ProcessName.Length = wlen - sizeof(WCHAR);
                    spi->ProcessName.MaximumLength = wlen;
872
                    memcpy( spi->ProcessName.Buffer, exename, wlen );
873 874 875 876 877 878 879 880 881 882 883 884
                    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:
        {
885 886 887 888 889 890
            SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION sppi;

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

            if (Length >= len)
891
            {
892 893
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &sppi, len);
894 895
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
896
            FIXME("info_class SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION\n");
897 898
        }
        break;
899
    case SystemModuleInformation:
900
        /* FIXME: should be system-wide */
901 902
        if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
        else ret = LdrQueryProcessModuleInformation( SystemInformation, Length, &len );
903
        break;
904 905 906 907 908 909
    case SystemHandleInformation:
        {
            SYSTEM_HANDLE_INFORMATION shi;

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

911 912 913 914 915 916
            if ( Length >= len)
            {
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &shi, len);
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
917
            FIXME("info_class SYSTEM_HANDLE_INFORMATION\n");
918 919
        }
        break;
920 921
    case SystemCacheInformation:
        {
922 923 924 925 926 927
            SYSTEM_CACHE_INFORMATION sci;

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

            if ( Length >= len)
928
            {
929 930
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &sci, len);
931 932
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
933
            FIXME("info_class SYSTEM_CACHE_INFORMATION\n");
934 935
        }
        break;
936 937 938 939 940 941 942 943 944 945 946 947 948
    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;
949
            FIXME("info_class SYSTEM_INTERRUPT_INFORMATION\n");
950 951
        }
        break;
952 953
    case SystemKernelDebuggerInformation:
        {
954 955 956 957 958 959 960
            SYSTEM_KERNEL_DEBUGGER_INFORMATION skdi;

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

            if ( Length >= len)
961
            {
962 963
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else memcpy( SystemInformation, &skdi, len);
964 965 966 967
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
        }
        break;
968 969
    case SystemRegistryQuotaInformation:
        {
970 971 972 973 974 975 976 977 978 979 980 981 982
	    /* 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)
983
            {
984 985 986 987 988 989
                if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
                else
                {
                    FIXME("SystemRegistryQuotaInformation: faking max registry size of 32 MB\n");
                    memcpy( SystemInformation, &srqi, len);
                }
990 991 992
            }
            else ret = STATUS_INFO_LENGTH_MISMATCH;
        }
993 994
	break;
    default:
995
	FIXME("(0x%08x,%p,0x%08x,%p) stub\n",
996
	      SystemInformationClass,SystemInformation,Length,ResultLength);
997 998 999 1000 1001 1002

        /* 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;
1003
    }
1004

1005
    if (ResultLength) *ResultLength = len;
1006

1007
    return ret;
Juergen Schmied's avatar
Juergen Schmied committed
1008 1009
}

1010 1011 1012 1013 1014 1015
/******************************************************************************
 * NtSetSystemInformation [NTDLL.@]
 * ZwSetSystemInformation [NTDLL.@]
 */
NTSTATUS WINAPI NtSetSystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, PVOID SystemInformation, ULONG Length)
{
1016
    FIXME("(0x%08x,%p,0x%08x) stub\n",SystemInformationClass,SystemInformation,Length);
1017 1018
    return STATUS_SUCCESS;
}
1019

1020
/******************************************************************************
1021
 *  NtCreatePagingFile		[NTDLL.@]
Patrik Stridvall's avatar
Patrik Stridvall committed
1022
 *  ZwCreatePagingFile		[NTDLL.@]
1023
 */
Juergen Schmied's avatar
Juergen Schmied committed
1024
NTSTATUS WINAPI NtCreatePagingFile(
1025
	PUNICODE_STRING PageFileName,
1026 1027
	PLARGE_INTEGER MinimumSize,
	PLARGE_INTEGER MaximumSize,
1028
	PLARGE_INTEGER ActualSize)
1029
{
1030
    FIXME("(%p %p %p %p) stub\n", PageFileName, MinimumSize, MaximumSize, ActualSize);
1031
    return STATUS_SUCCESS;
1032 1033
}

1034
/******************************************************************************
1035
 *  NtDisplayString				[NTDLL.@]
1036
 *
1037 1038
 * writes a string to the nt-textmode screen eg. during startup
 */
1039
NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
1040
{
1041 1042 1043 1044 1045 1046 1047 1048 1049
    STRING stringA;
    NTSTATUS ret;

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

1052 1053 1054 1055 1056 1057 1058 1059 1060 1061
/******************************************************************************
 *  NtInitiatePowerAction                       [NTDLL.@]
 *
 */
NTSTATUS WINAPI NtInitiatePowerAction(
	IN POWER_ACTION SystemAction,
	IN SYSTEM_POWER_STATE MinSystemState,
	IN ULONG Flags,
	IN BOOLEAN Asynchronous)
{
1062
        FIXME("(%d,%d,0x%08x,%d),stub\n",
1063 1064 1065 1066 1067
		SystemAction,MinSystemState,Flags,Asynchronous);
        return STATUS_NOT_IMPLEMENTED;
}
	

1068
/******************************************************************************
1069
 *  NtPowerInformation				[NTDLL.@]
1070
 *
1071
 */
1072 1073 1074 1075 1076 1077
NTSTATUS WINAPI NtPowerInformation(
	IN POWER_INFORMATION_LEVEL InformationLevel,
	IN PVOID lpInputBuffer,
	IN ULONG nInputBufferSize,
	IN PVOID lpOutputBuffer,
	IN ULONG nOutputBufferSize)
1078
{
1079
	TRACE("(%d,%p,%d,%p,%d)\n",
1080
		InformationLevel,lpInputBuffer,nInputBufferSize,lpOutputBuffer,nOutputBufferSize);
1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124
	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;
	}
1125
}
1126

1127 1128 1129 1130
/******************************************************************************
 *  NtShutdownSystem				[NTDLL.@]
 *
 */
1131
NTSTATUS WINAPI NtShutdownSystem(SHUTDOWN_ACTION Action)
1132
{
1133 1134
    FIXME("%d\n",Action);
    return STATUS_SUCCESS;
1135 1136
}

1137
/******************************************************************************
1138
 *  NtAllocateLocallyUniqueId (NTDLL.@)
1139 1140 1141
 */
NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
{
1142
    NTSTATUS status;
1143

1144
    TRACE("%p\n", Luid);
1145 1146 1147

    if (!Luid)
        return STATUS_ACCESS_VIOLATION;
1148

1149 1150 1151 1152 1153 1154 1155 1156 1157 1158
    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
1159

1160
    return status;
1161
}
1162 1163 1164 1165 1166 1167 1168

/******************************************************************************
 *        VerSetConditionMask   (NTDLL.@)
 */
ULONGLONG WINAPI VerSetConditionMask( ULONGLONG dwlConditionMask, DWORD dwTypeBitMask,
                                      BYTE dwConditionMask)
{
1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190
    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;
1191 1192
    return dwlConditionMask;
}
1193 1194 1195 1196 1197 1198 1199 1200 1201 1202

/******************************************************************************
 *  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)
{
1203
    FIXME("(%s, %p, %s, %p, 0x%08x, %p, %d, %p, %p, %p), stub\n", debugstr_us(SubsystemName), HandleId,
1204 1205 1206 1207 1208
          debugstr_us(ObjectTypeName), SecurityDescriptor, DesiredAccess, GenericMapping, ObjectCreation,
          GrantedAccess, AccessStatus, GenerateOnClose);

    return STATUS_NOT_IMPLEMENTED;
}