ntdll/tests: Test NtCreateFile with an invalid filename.
[wine.git] / dlls / ntdll / nt.c
blobfdcc163f0dec2e58eeedfbf1a3e5a0fec11fe87a
1 /*
2 * NT basis DLL
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)
7 * Copyright 1996-1998 Marcus Meissner
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * 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
24 #include "config.h"
25 #include "wine/port.h"
27 #ifdef HAVE_SYS_PARAM_H
28 # include <sys/param.h>
29 #endif
30 #ifdef HAVE_SYS_SYSCTL_H
31 # include <sys/sysctl.h>
32 #endif
33 #ifdef HAVE_MACHINE_CPU_H
34 # include <machine/cpu.h>
35 #endif
36 #ifdef HAVE_MACH_MACHINE_H
37 # include <mach/machine.h>
38 #endif
40 #include <ctype.h>
41 #include <string.h>
42 #include <stdarg.h>
43 #include <stdio.h>
44 #include <stdlib.h>
45 #ifdef HAVE_SYS_TIME_H
46 # include <sys/time.h>
47 #endif
48 #include <time.h>
50 #define NONAMELESSUNION
51 #include "ntstatus.h"
52 #define WIN32_NO_STATUS
53 #include "wine/debug.h"
54 #include "wine/unicode.h"
55 #include "windef.h"
56 #include "winternl.h"
57 #include "ntdll_misc.h"
58 #include "wine/server.h"
59 #include "ddk/wdm.h"
61 #ifdef __APPLE__
62 #include <mach/mach_init.h>
63 #include <mach/mach_host.h>
64 #include <mach/vm_map.h>
65 #endif
67 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
70 * Token
73 /******************************************************************************
74 * NtDuplicateToken [NTDLL.@]
75 * ZwDuplicateToken [NTDLL.@]
77 NTSTATUS WINAPI NtDuplicateToken(
78 IN HANDLE ExistingToken,
79 IN ACCESS_MASK DesiredAccess,
80 IN POBJECT_ATTRIBUTES ObjectAttributes,
81 IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
82 IN TOKEN_TYPE TokenType,
83 OUT PHANDLE NewToken)
85 NTSTATUS status;
87 TRACE("(%p,0x%08x,%s,0x%08x,0x%08x,%p)\n",
88 ExistingToken, DesiredAccess, debugstr_ObjectAttributes(ObjectAttributes),
89 ImpersonationLevel, TokenType, NewToken);
91 if (ObjectAttributes && ObjectAttributes->SecurityQualityOfService)
93 SECURITY_QUALITY_OF_SERVICE *SecurityQOS = ObjectAttributes->SecurityQualityOfService;
94 TRACE("ObjectAttributes->SecurityQualityOfService = {%d, %d, %d, %s}\n",
95 SecurityQOS->Length, SecurityQOS->ImpersonationLevel,
96 SecurityQOS->ContextTrackingMode,
97 SecurityQOS->EffectiveOnly ? "TRUE" : "FALSE");
98 ImpersonationLevel = SecurityQOS->ImpersonationLevel;
101 SERVER_START_REQ( duplicate_token )
103 req->handle = wine_server_obj_handle( ExistingToken );
104 req->access = DesiredAccess;
105 req->attributes = ObjectAttributes ? ObjectAttributes->Attributes : 0;
106 req->primary = (TokenType == TokenPrimary);
107 req->impersonation_level = ImpersonationLevel;
108 status = wine_server_call( req );
109 if (!status) *NewToken = wine_server_ptr_handle( reply->new_handle );
111 SERVER_END_REQ;
113 return status;
116 /******************************************************************************
117 * NtOpenProcessToken [NTDLL.@]
118 * ZwOpenProcessToken [NTDLL.@]
120 NTSTATUS WINAPI NtOpenProcessToken(
121 HANDLE ProcessHandle,
122 DWORD DesiredAccess,
123 HANDLE *TokenHandle)
125 return NtOpenProcessTokenEx( ProcessHandle, DesiredAccess, 0, TokenHandle );
128 /******************************************************************************
129 * NtOpenProcessTokenEx [NTDLL.@]
130 * ZwOpenProcessTokenEx [NTDLL.@]
132 NTSTATUS WINAPI NtOpenProcessTokenEx( HANDLE process, DWORD access, DWORD attributes,
133 HANDLE *handle )
135 NTSTATUS ret;
137 TRACE("(%p,0x%08x,0x%08x,%p)\n", process, access, attributes, handle);
139 SERVER_START_REQ( open_token )
141 req->handle = wine_server_obj_handle( process );
142 req->access = access;
143 req->attributes = attributes;
144 req->flags = 0;
145 ret = wine_server_call( req );
146 if (!ret) *handle = wine_server_ptr_handle( reply->token );
148 SERVER_END_REQ;
149 return ret;
152 /******************************************************************************
153 * NtOpenThreadToken [NTDLL.@]
154 * ZwOpenThreadToken [NTDLL.@]
156 NTSTATUS WINAPI NtOpenThreadToken(
157 HANDLE ThreadHandle,
158 DWORD DesiredAccess,
159 BOOLEAN OpenAsSelf,
160 HANDLE *TokenHandle)
162 return NtOpenThreadTokenEx( ThreadHandle, DesiredAccess, OpenAsSelf, 0, TokenHandle );
165 /******************************************************************************
166 * NtOpenThreadTokenEx [NTDLL.@]
167 * ZwOpenThreadTokenEx [NTDLL.@]
169 NTSTATUS WINAPI NtOpenThreadTokenEx( HANDLE thread, DWORD access, BOOLEAN as_self, DWORD attributes,
170 HANDLE *handle )
172 NTSTATUS ret;
174 TRACE("(%p,0x%08x,%u,0x%08x,%p)\n", thread, access, as_self, attributes, handle );
176 SERVER_START_REQ( open_token )
178 req->handle = wine_server_obj_handle( thread );
179 req->access = access;
180 req->attributes = attributes;
181 req->flags = OPEN_TOKEN_THREAD;
182 if (as_self) req->flags |= OPEN_TOKEN_AS_SELF;
183 ret = wine_server_call( req );
184 if (!ret) *handle = wine_server_ptr_handle( reply->token );
186 SERVER_END_REQ;
188 return ret;
191 /******************************************************************************
192 * NtAdjustPrivilegesToken [NTDLL.@]
193 * ZwAdjustPrivilegesToken [NTDLL.@]
195 * FIXME: parameters unsafe
197 NTSTATUS WINAPI NtAdjustPrivilegesToken(
198 IN HANDLE TokenHandle,
199 IN BOOLEAN DisableAllPrivileges,
200 IN PTOKEN_PRIVILEGES NewState,
201 IN DWORD BufferLength,
202 OUT PTOKEN_PRIVILEGES PreviousState,
203 OUT PDWORD ReturnLength)
205 NTSTATUS ret;
207 TRACE("(%p,0x%08x,%p,0x%08x,%p,%p)\n",
208 TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength);
210 SERVER_START_REQ( adjust_token_privileges )
212 req->handle = wine_server_obj_handle( TokenHandle );
213 req->disable_all = DisableAllPrivileges;
214 req->get_modified_state = (PreviousState != NULL);
215 if (!DisableAllPrivileges)
217 wine_server_add_data( req, NewState->Privileges,
218 NewState->PrivilegeCount * sizeof(NewState->Privileges[0]) );
220 if (PreviousState && BufferLength >= FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ))
221 wine_server_set_reply( req, PreviousState->Privileges,
222 BufferLength - FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) );
223 ret = wine_server_call( req );
224 if (PreviousState)
226 *ReturnLength = reply->len + FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges );
227 PreviousState->PrivilegeCount = reply->len / sizeof(LUID_AND_ATTRIBUTES);
230 SERVER_END_REQ;
232 return ret;
235 /******************************************************************************
236 * NtQueryInformationToken [NTDLL.@]
237 * ZwQueryInformationToken [NTDLL.@]
239 * NOTES
240 * Buffer for TokenUser:
241 * 0x00 TOKEN_USER the PSID field points to the SID
242 * 0x08 SID
245 NTSTATUS WINAPI NtQueryInformationToken(
246 HANDLE token,
247 TOKEN_INFORMATION_CLASS tokeninfoclass,
248 PVOID tokeninfo,
249 ULONG tokeninfolength,
250 PULONG retlen )
252 ULONG len;
253 NTSTATUS status = STATUS_SUCCESS;
255 TRACE("(%p,%d,%p,%d,%p)\n",
256 token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);
258 switch (tokeninfoclass)
260 case TokenSource:
261 len = sizeof(TOKEN_SOURCE);
262 break;
263 case TokenType:
264 len = sizeof (TOKEN_TYPE);
265 break;
266 case TokenImpersonationLevel:
267 len = sizeof(SECURITY_IMPERSONATION_LEVEL);
268 break;
269 case TokenStatistics:
270 len = sizeof(TOKEN_STATISTICS);
271 break;
272 default:
273 len = 0;
276 if (retlen) *retlen = len;
278 if (tokeninfolength < len)
279 return STATUS_BUFFER_TOO_SMALL;
281 switch (tokeninfoclass)
283 case TokenUser:
284 SERVER_START_REQ( get_token_sid )
286 TOKEN_USER * tuser = tokeninfo;
287 PSID sid = tuser + 1;
288 DWORD sid_len = tokeninfolength < sizeof(TOKEN_USER) ? 0 : tokeninfolength - sizeof(TOKEN_USER);
290 req->handle = wine_server_obj_handle( token );
291 req->which_sid = tokeninfoclass;
292 wine_server_set_reply( req, sid, sid_len );
293 status = wine_server_call( req );
294 if (retlen) *retlen = reply->sid_len + sizeof(TOKEN_USER);
295 if (status == STATUS_SUCCESS)
297 tuser->User.Sid = sid;
298 tuser->User.Attributes = 0;
301 SERVER_END_REQ;
302 break;
303 case TokenGroups:
305 char stack_buffer[256];
306 unsigned int server_buf_len = sizeof(stack_buffer);
307 void *buffer = stack_buffer;
308 BOOLEAN need_more_memory;
310 /* we cannot work out the size of the server buffer required for the
311 * input size, since there are two factors affecting how much can be
312 * stored in the buffer - number of groups and lengths of sids */
315 need_more_memory = FALSE;
317 SERVER_START_REQ( get_token_groups )
319 TOKEN_GROUPS *groups = tokeninfo;
321 req->handle = wine_server_obj_handle( token );
322 wine_server_set_reply( req, buffer, server_buf_len );
323 status = wine_server_call( req );
324 if (status == STATUS_BUFFER_TOO_SMALL)
326 if (buffer == stack_buffer)
327 buffer = RtlAllocateHeap(GetProcessHeap(), 0, reply->user_len);
328 else
329 buffer = RtlReAllocateHeap(GetProcessHeap(), 0, buffer, reply->user_len);
330 if (!buffer) return STATUS_NO_MEMORY;
332 server_buf_len = reply->user_len;
333 need_more_memory = TRUE;
335 else if (status == STATUS_SUCCESS)
337 struct token_groups *tg = buffer;
338 unsigned int *attr = (unsigned int *)(tg + 1);
339 ULONG i;
340 const int non_sid_portion = (sizeof(struct token_groups) + tg->count * sizeof(unsigned int));
341 SID *sids = (SID *)((char *)tokeninfo + FIELD_OFFSET( TOKEN_GROUPS, Groups[tg->count] ));
342 ULONG needed_bytes = FIELD_OFFSET( TOKEN_GROUPS, Groups[tg->count] ) +
343 reply->user_len - non_sid_portion;
345 if (retlen) *retlen = needed_bytes;
347 if (needed_bytes <= tokeninfolength)
349 groups->GroupCount = tg->count;
350 memcpy( sids, (char *)buffer + non_sid_portion,
351 reply->user_len - non_sid_portion );
353 for (i = 0; i < tg->count; i++)
355 groups->Groups[i].Attributes = attr[i];
356 groups->Groups[i].Sid = sids;
357 sids = (SID *)((char *)sids + RtlLengthSid(sids));
360 else status = STATUS_BUFFER_TOO_SMALL;
362 else if (retlen) *retlen = 0;
364 SERVER_END_REQ;
365 } while (need_more_memory);
366 if (buffer != stack_buffer) RtlFreeHeap(GetProcessHeap(), 0, buffer);
367 break;
369 case TokenPrimaryGroup:
370 SERVER_START_REQ( get_token_sid )
372 TOKEN_PRIMARY_GROUP *tgroup = tokeninfo;
373 PSID sid = tgroup + 1;
374 DWORD sid_len = tokeninfolength < sizeof(TOKEN_PRIMARY_GROUP) ? 0 : tokeninfolength - sizeof(TOKEN_PRIMARY_GROUP);
376 req->handle = wine_server_obj_handle( token );
377 req->which_sid = tokeninfoclass;
378 wine_server_set_reply( req, sid, sid_len );
379 status = wine_server_call( req );
380 if (retlen) *retlen = reply->sid_len + sizeof(TOKEN_PRIMARY_GROUP);
381 if (status == STATUS_SUCCESS)
382 tgroup->PrimaryGroup = sid;
384 SERVER_END_REQ;
385 break;
386 case TokenPrivileges:
387 SERVER_START_REQ( get_token_privileges )
389 TOKEN_PRIVILEGES *tpriv = tokeninfo;
390 req->handle = wine_server_obj_handle( token );
391 if (tpriv && tokeninfolength > FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ))
392 wine_server_set_reply( req, tpriv->Privileges, tokeninfolength - FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) );
393 status = wine_server_call( req );
394 if (retlen) *retlen = FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) + reply->len;
395 if (tpriv) tpriv->PrivilegeCount = reply->len / sizeof(LUID_AND_ATTRIBUTES);
397 SERVER_END_REQ;
398 break;
399 case TokenOwner:
400 SERVER_START_REQ( get_token_sid )
402 TOKEN_OWNER *towner = tokeninfo;
403 PSID sid = towner + 1;
404 DWORD sid_len = tokeninfolength < sizeof(TOKEN_OWNER) ? 0 : tokeninfolength - sizeof(TOKEN_OWNER);
406 req->handle = wine_server_obj_handle( token );
407 req->which_sid = tokeninfoclass;
408 wine_server_set_reply( req, sid, sid_len );
409 status = wine_server_call( req );
410 if (retlen) *retlen = reply->sid_len + sizeof(TOKEN_OWNER);
411 if (status == STATUS_SUCCESS)
412 towner->Owner = sid;
414 SERVER_END_REQ;
415 break;
416 case TokenImpersonationLevel:
417 SERVER_START_REQ( get_token_impersonation_level )
419 SECURITY_IMPERSONATION_LEVEL *impersonation_level = tokeninfo;
420 req->handle = wine_server_obj_handle( token );
421 status = wine_server_call( req );
422 if (status == STATUS_SUCCESS)
423 *impersonation_level = reply->impersonation_level;
425 SERVER_END_REQ;
426 break;
427 case TokenStatistics:
428 SERVER_START_REQ( get_token_statistics )
430 TOKEN_STATISTICS *statistics = tokeninfo;
431 req->handle = wine_server_obj_handle( token );
432 status = wine_server_call( req );
433 if (status == STATUS_SUCCESS)
435 statistics->TokenId.LowPart = reply->token_id.low_part;
436 statistics->TokenId.HighPart = reply->token_id.high_part;
437 statistics->AuthenticationId.LowPart = 0; /* FIXME */
438 statistics->AuthenticationId.HighPart = 0; /* FIXME */
439 statistics->ExpirationTime.u.HighPart = 0x7fffffff;
440 statistics->ExpirationTime.u.LowPart = 0xffffffff;
441 statistics->TokenType = reply->primary ? TokenPrimary : TokenImpersonation;
442 statistics->ImpersonationLevel = reply->impersonation_level;
444 /* kernel information not relevant to us */
445 statistics->DynamicCharged = 0;
446 statistics->DynamicAvailable = 0;
448 statistics->GroupCount = reply->group_count;
449 statistics->PrivilegeCount = reply->privilege_count;
450 statistics->ModifiedId.LowPart = reply->modified_id.low_part;
451 statistics->ModifiedId.HighPart = reply->modified_id.high_part;
454 SERVER_END_REQ;
455 break;
456 case TokenType:
457 SERVER_START_REQ( get_token_statistics )
459 TOKEN_TYPE *token_type = tokeninfo;
460 req->handle = wine_server_obj_handle( token );
461 status = wine_server_call( req );
462 if (status == STATUS_SUCCESS)
463 *token_type = reply->primary ? TokenPrimary : TokenImpersonation;
465 SERVER_END_REQ;
466 break;
467 case TokenDefaultDacl:
468 SERVER_START_REQ( get_token_default_dacl )
470 TOKEN_DEFAULT_DACL *default_dacl = tokeninfo;
471 ACL *acl = (ACL *)(default_dacl + 1);
472 DWORD acl_len;
474 if (tokeninfolength < sizeof(TOKEN_DEFAULT_DACL)) acl_len = 0;
475 else acl_len = tokeninfolength - sizeof(TOKEN_DEFAULT_DACL);
477 req->handle = wine_server_obj_handle( token );
478 wine_server_set_reply( req, acl, acl_len );
479 status = wine_server_call( req );
481 if (retlen) *retlen = reply->acl_len + sizeof(TOKEN_DEFAULT_DACL);
482 if (status == STATUS_SUCCESS)
484 if (reply->acl_len)
485 default_dacl->DefaultDacl = acl;
486 else
487 default_dacl->DefaultDacl = NULL;
490 SERVER_END_REQ;
491 break;
492 default:
494 ERR("Unhandled Token Information class %d!\n", tokeninfoclass);
495 return STATUS_NOT_IMPLEMENTED;
498 return status;
501 /******************************************************************************
502 * NtSetInformationToken [NTDLL.@]
503 * ZwSetInformationToken [NTDLL.@]
505 NTSTATUS WINAPI NtSetInformationToken(
506 HANDLE TokenHandle,
507 TOKEN_INFORMATION_CLASS TokenInformationClass,
508 PVOID TokenInformation,
509 ULONG TokenInformationLength)
511 NTSTATUS ret = STATUS_NOT_IMPLEMENTED;
513 TRACE("%p %d %p %u\n", TokenHandle, TokenInformationClass,
514 TokenInformation, TokenInformationLength);
516 switch (TokenInformationClass)
518 case TokenDefaultDacl:
519 if (TokenInformationLength < sizeof(TOKEN_DEFAULT_DACL))
521 ret = STATUS_INFO_LENGTH_MISMATCH;
522 break;
524 if (!TokenInformation)
526 ret = STATUS_ACCESS_VIOLATION;
527 break;
529 SERVER_START_REQ( set_token_default_dacl )
531 ACL *acl = ((TOKEN_DEFAULT_DACL *)TokenInformation)->DefaultDacl;
532 WORD size;
534 if (acl) size = acl->AclSize;
535 else size = 0;
537 req->handle = wine_server_obj_handle( TokenHandle );
538 wine_server_add_data( req, acl, size );
539 ret = wine_server_call( req );
541 SERVER_END_REQ;
542 break;
543 default:
544 FIXME("unimplemented class %u\n", TokenInformationClass);
545 break;
548 return ret;
551 /******************************************************************************
552 * NtAdjustGroupsToken [NTDLL.@]
553 * ZwAdjustGroupsToken [NTDLL.@]
555 NTSTATUS WINAPI NtAdjustGroupsToken(
556 HANDLE TokenHandle,
557 BOOLEAN ResetToDefault,
558 PTOKEN_GROUPS NewState,
559 ULONG BufferLength,
560 PTOKEN_GROUPS PreviousState,
561 PULONG ReturnLength)
563 FIXME("%p %d %p %u %p %p\n", TokenHandle, ResetToDefault,
564 NewState, BufferLength, PreviousState, ReturnLength);
565 return STATUS_NOT_IMPLEMENTED;
568 /******************************************************************************
569 * NtPrivilegeCheck [NTDLL.@]
570 * ZwPrivilegeCheck [NTDLL.@]
572 NTSTATUS WINAPI NtPrivilegeCheck(
573 HANDLE ClientToken,
574 PPRIVILEGE_SET RequiredPrivileges,
575 PBOOLEAN Result)
577 NTSTATUS status;
578 SERVER_START_REQ( check_token_privileges )
580 req->handle = wine_server_obj_handle( ClientToken );
581 req->all_required = ((RequiredPrivileges->Control & PRIVILEGE_SET_ALL_NECESSARY) ? TRUE : FALSE);
582 wine_server_add_data( req, RequiredPrivileges->Privilege,
583 RequiredPrivileges->PrivilegeCount * sizeof(RequiredPrivileges->Privilege[0]) );
584 wine_server_set_reply( req, RequiredPrivileges->Privilege,
585 RequiredPrivileges->PrivilegeCount * sizeof(RequiredPrivileges->Privilege[0]) );
587 status = wine_server_call( req );
589 if (status == STATUS_SUCCESS)
590 *Result = (reply->has_privileges ? TRUE : FALSE);
592 SERVER_END_REQ;
593 return status;
597 * Section
600 /******************************************************************************
601 * NtQuerySection [NTDLL.@]
603 NTSTATUS WINAPI NtQuerySection(
604 IN HANDLE SectionHandle,
605 IN SECTION_INFORMATION_CLASS SectionInformationClass,
606 OUT PVOID SectionInformation,
607 IN ULONG Length,
608 OUT PULONG ResultLength)
610 FIXME("(%p,%d,%p,0x%08x,%p) stub!\n",
611 SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
612 return 0;
616 * ports
619 /******************************************************************************
620 * NtCreatePort [NTDLL.@]
621 * ZwCreatePort [NTDLL.@]
623 NTSTATUS WINAPI NtCreatePort(PHANDLE PortHandle,POBJECT_ATTRIBUTES ObjectAttributes,
624 ULONG MaxConnectInfoLength,ULONG MaxDataLength,PULONG reserved)
626 FIXME("(%p,%p,%u,%u,%p),stub!\n",PortHandle,ObjectAttributes,
627 MaxConnectInfoLength,MaxDataLength,reserved);
628 return STATUS_NOT_IMPLEMENTED;
631 /******************************************************************************
632 * NtConnectPort [NTDLL.@]
633 * ZwConnectPort [NTDLL.@]
635 NTSTATUS WINAPI NtConnectPort(
636 PHANDLE PortHandle,
637 PUNICODE_STRING PortName,
638 PSECURITY_QUALITY_OF_SERVICE SecurityQos,
639 PLPC_SECTION_WRITE WriteSection,
640 PLPC_SECTION_READ ReadSection,
641 PULONG MaximumMessageLength,
642 PVOID ConnectInfo,
643 PULONG pConnectInfoLength)
645 FIXME("(%p,%s,%p,%p,%p,%p,%p,%p),stub!\n",
646 PortHandle,debugstr_w(PortName->Buffer),SecurityQos,
647 WriteSection,ReadSection,MaximumMessageLength,ConnectInfo,
648 pConnectInfoLength);
649 if (ConnectInfo && pConnectInfoLength)
650 TRACE("\tMessage = %s\n",debugstr_an(ConnectInfo,*pConnectInfoLength));
651 return STATUS_NOT_IMPLEMENTED;
654 /******************************************************************************
655 * NtSecureConnectPort (NTDLL.@)
656 * ZwSecureConnectPort (NTDLL.@)
658 NTSTATUS WINAPI NtSecureConnectPort(
659 PHANDLE PortHandle,
660 PUNICODE_STRING PortName,
661 PSECURITY_QUALITY_OF_SERVICE SecurityQos,
662 PLPC_SECTION_WRITE WriteSection,
663 PSID pSid,
664 PLPC_SECTION_READ ReadSection,
665 PULONG MaximumMessageLength,
666 PVOID ConnectInfo,
667 PULONG pConnectInfoLength)
669 FIXME("(%p,%s,%p,%p,%p,%p,%p,%p,%p),stub!\n",
670 PortHandle,debugstr_w(PortName->Buffer),SecurityQos,
671 WriteSection,pSid,ReadSection,MaximumMessageLength,ConnectInfo,
672 pConnectInfoLength);
673 return STATUS_NOT_IMPLEMENTED;
676 /******************************************************************************
677 * NtListenPort [NTDLL.@]
678 * ZwListenPort [NTDLL.@]
680 NTSTATUS WINAPI NtListenPort(HANDLE PortHandle,PLPC_MESSAGE pLpcMessage)
682 FIXME("(%p,%p),stub!\n",PortHandle,pLpcMessage);
683 return STATUS_NOT_IMPLEMENTED;
686 /******************************************************************************
687 * NtAcceptConnectPort [NTDLL.@]
688 * ZwAcceptConnectPort [NTDLL.@]
690 NTSTATUS WINAPI NtAcceptConnectPort(
691 PHANDLE PortHandle,
692 ULONG PortIdentifier,
693 PLPC_MESSAGE pLpcMessage,
694 BOOLEAN Accept,
695 PLPC_SECTION_WRITE WriteSection,
696 PLPC_SECTION_READ ReadSection)
698 FIXME("(%p,%u,%p,%d,%p,%p),stub!\n",
699 PortHandle,PortIdentifier,pLpcMessage,Accept,WriteSection,ReadSection);
700 return STATUS_NOT_IMPLEMENTED;
703 /******************************************************************************
704 * NtCompleteConnectPort [NTDLL.@]
705 * ZwCompleteConnectPort [NTDLL.@]
707 NTSTATUS WINAPI NtCompleteConnectPort(HANDLE PortHandle)
709 FIXME("(%p),stub!\n",PortHandle);
710 return STATUS_NOT_IMPLEMENTED;
713 /******************************************************************************
714 * NtRegisterThreadTerminatePort [NTDLL.@]
715 * ZwRegisterThreadTerminatePort [NTDLL.@]
717 NTSTATUS WINAPI NtRegisterThreadTerminatePort(HANDLE PortHandle)
719 FIXME("(%p),stub!\n",PortHandle);
720 return STATUS_NOT_IMPLEMENTED;
723 /******************************************************************************
724 * NtRequestWaitReplyPort [NTDLL.@]
725 * ZwRequestWaitReplyPort [NTDLL.@]
727 NTSTATUS WINAPI NtRequestWaitReplyPort(
728 HANDLE PortHandle,
729 PLPC_MESSAGE pLpcMessageIn,
730 PLPC_MESSAGE pLpcMessageOut)
732 FIXME("(%p,%p,%p),stub!\n",PortHandle,pLpcMessageIn,pLpcMessageOut);
733 if(pLpcMessageIn)
735 TRACE("Message to send:\n");
736 TRACE("\tDataSize = %u\n",pLpcMessageIn->DataSize);
737 TRACE("\tMessageSize = %u\n",pLpcMessageIn->MessageSize);
738 TRACE("\tMessageType = %u\n",pLpcMessageIn->MessageType);
739 TRACE("\tVirtualRangesOffset = %u\n",pLpcMessageIn->VirtualRangesOffset);
740 TRACE("\tClientId.UniqueProcess = %p\n",pLpcMessageIn->ClientId.UniqueProcess);
741 TRACE("\tClientId.UniqueThread = %p\n",pLpcMessageIn->ClientId.UniqueThread);
742 TRACE("\tMessageId = %lu\n",pLpcMessageIn->MessageId);
743 TRACE("\tSectionSize = %lu\n",pLpcMessageIn->SectionSize);
744 TRACE("\tData = %s\n",
745 debugstr_an((const char*)pLpcMessageIn->Data,pLpcMessageIn->DataSize));
747 return STATUS_NOT_IMPLEMENTED;
750 /******************************************************************************
751 * NtReplyWaitReceivePort [NTDLL.@]
752 * ZwReplyWaitReceivePort [NTDLL.@]
754 NTSTATUS WINAPI NtReplyWaitReceivePort(
755 HANDLE PortHandle,
756 PULONG PortIdentifier,
757 PLPC_MESSAGE ReplyMessage,
758 PLPC_MESSAGE Message)
760 FIXME("(%p,%p,%p,%p),stub!\n",PortHandle,PortIdentifier,ReplyMessage,Message);
761 return STATUS_NOT_IMPLEMENTED;
765 * Misc
768 /******************************************************************************
769 * NtSetIntervalProfile [NTDLL.@]
770 * ZwSetIntervalProfile [NTDLL.@]
772 NTSTATUS WINAPI NtSetIntervalProfile(
773 ULONG Interval,
774 KPROFILE_SOURCE Source)
776 FIXME("%u,%d\n", Interval, Source);
777 return STATUS_SUCCESS;
780 static SYSTEM_CPU_INFORMATION cached_sci;
781 static ULONGLONG cpuHz = 1000000000; /* default to a 1GHz */
783 #define AUTH 0x68747541 /* "Auth" */
784 #define ENTI 0x69746e65 /* "enti" */
785 #define CAMD 0x444d4163 /* "cAMD" */
787 /* Calls cpuid with an eax of 'ax' and returns the 16 bytes in *p
788 * We are compiled with -fPIC, so we can't clobber ebx.
790 static inline void do_cpuid(unsigned int ax, unsigned int *p)
792 #ifdef __i386__
793 __asm__("pushl %%ebx\n\t"
794 "cpuid\n\t"
795 "movl %%ebx, %%esi\n\t"
796 "popl %%ebx"
797 : "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3])
798 : "0" (ax));
799 #endif
802 /* From xf86info havecpuid.c 1.11 */
803 static inline int have_cpuid(void)
805 #ifdef __i386__
806 unsigned int f1, f2;
807 __asm__("pushfl\n\t"
808 "pushfl\n\t"
809 "popl %0\n\t"
810 "movl %0,%1\n\t"
811 "xorl %2,%0\n\t"
812 "pushl %0\n\t"
813 "popfl\n\t"
814 "pushfl\n\t"
815 "popl %0\n\t"
816 "popfl"
817 : "=&r" (f1), "=&r" (f2)
818 : "ir" (0x00200000));
819 return ((f1^f2) & 0x00200000) != 0;
820 #else
821 return 0;
822 #endif
825 static inline void get_cpuinfo(SYSTEM_CPU_INFORMATION* info)
827 unsigned int regs[4], regs2[4];
829 if (!have_cpuid()) return;
831 do_cpuid(0x00000000, regs); /* get standard cpuid level and vendor name */
832 if (regs[0]>=0x00000001) /* Check for supported cpuid version */
834 do_cpuid(0x00000001, regs2); /* get cpu features */
835 switch ((regs2[0] >> 8) & 0xf) /* cpu family */
837 case 3: info->Level = 3; break;
838 case 4: info->Level = 4; break;
839 case 5: info->Level = 5; break;
840 case 15: /* PPro/2/3/4 has same info as P1 */
841 case 6: info->Level = 6; break;
842 default:
843 FIXME("unknown cpu family %d, please report! (-> setting to 386)\n",
844 (regs2[0] >> 8)&0xf);
845 info->Level = 3;
846 break;
848 user_shared_data->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = !(regs2[3] & 1);
849 user_shared_data->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = (regs2[3] & (1 << 4 )) >> 4;
850 user_shared_data->ProcessorFeatures[PF_PAE_ENABLED] = (regs2[3] & (1 << 6 )) >> 6;
851 user_shared_data->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = (regs2[3] & (1 << 8 )) >> 8;
852 user_shared_data->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = (regs2[3] & (1 << 23)) >> 23;
853 user_shared_data->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = (regs2[3] & (1 << 25)) >> 25;
854 user_shared_data->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = (regs2[3] & (1 << 26)) >> 26;
856 if (regs[1] == AUTH && regs[3] == ENTI && regs[2] == CAMD)
858 do_cpuid(0x80000000, regs); /* get vendor cpuid level */
859 if (regs[0] >= 0x80000001)
861 do_cpuid(0x80000001, regs2); /* get vendor features */
862 user_shared_data->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = (regs2[3] & (1 << 31 )) >> 31;
868 /******************************************************************
869 * fill_cpu_info
871 * inits a couple of places with CPU related information:
872 * - cached_sci & cpuHZ in this file
873 * - Peb->NumberOfProcessors
874 * - SharedUserData->ProcessFeatures[] array
876 * It creates a registry subhierarchy, looking like:
877 * "\HARDWARE\DESCRIPTION\System\CentralProcessor\<processornumber>\Identifier (CPU x86)".
878 * Note that there is a hierarchy for every processor installed, so this
879 * supports multiprocessor systems. This is done like Win95 does it, I think.
881 * It creates some registry entries in the environment part:
882 * "\HKLM\System\CurrentControlSet\Control\Session Manager\Environment". These are
883 * always present. When deleted, Windows will add them again.
885 void fill_cpu_info(void)
887 memset(&cached_sci, 0, sizeof(cached_sci));
888 /* choose sensible defaults ...
889 * FIXME: perhaps overridable with precompiler flags?
891 cached_sci.Architecture = PROCESSOR_ARCHITECTURE_INTEL;
892 cached_sci.Level = 5; /* 586 */
893 cached_sci.Revision = 0;
894 cached_sci.Reserved = 0;
895 cached_sci.FeatureSet = 0x1fff; /* FIXME: set some sensible defaults out of ProcessFeatures[] */
897 NtCurrentTeb()->Peb->NumberOfProcessors = 1;
899 /* Hmm, reasonable processor feature defaults? */
901 #ifdef linux
903 char line[200];
904 FILE *f = fopen ("/proc/cpuinfo", "r");
906 if (!f)
907 return;
908 while (fgets(line,200,f) != NULL)
910 char *s,*value;
912 /* NOTE: the ':' is the only character we can rely on */
913 if (!(value = strchr(line,':')))
914 continue;
916 /* terminate the valuename */
917 s = value - 1;
918 while ((s >= line) && ((*s == ' ') || (*s == '\t'))) s--;
919 *(s + 1) = '\0';
921 /* and strip leading spaces from value */
922 value += 1;
923 while (*value==' ') value++;
924 if ((s = strchr(value,'\n')))
925 *s='\0';
927 if (!strcasecmp(line, "processor"))
929 /* processor number counts up... */
930 unsigned int x;
932 if (sscanf(value, "%d",&x))
933 if (x + 1 > NtCurrentTeb()->Peb->NumberOfProcessors)
934 NtCurrentTeb()->Peb->NumberOfProcessors = x + 1;
936 continue;
938 if (!strcasecmp(line, "model"))
940 /* First part of Revision */
941 int x;
943 if (sscanf(value, "%d",&x))
944 cached_sci.Revision = cached_sci.Revision | (x << 8);
946 continue;
949 /* 2.1 method */
950 if (!strcasecmp(line, "cpu family"))
952 if (isdigit(value[0]))
954 cached_sci.Level = atoi(value);
956 continue;
958 /* old 2.0 method */
959 if (!strcasecmp(line, "cpu"))
961 if (isdigit(value[0]) && value[1] == '8' && value[2] == '6' && value[3] == 0)
963 switch (cached_sci.Level = value[0] - '0')
965 case 3:
966 case 4:
967 case 5:
968 case 6:
969 break;
970 default:
971 FIXME("unknown Linux 2.0 cpu family '%s', please report ! (-> setting to 386)\n", value);
972 cached_sci.Level = 3;
973 break;
976 continue;
978 if (!strcasecmp(line, "stepping"))
980 /* Second part of Revision */
981 int x;
983 if (sscanf(value, "%d",&x))
984 cached_sci.Revision = cached_sci.Revision | x;
985 continue;
987 if (!strcasecmp(line, "cpu MHz"))
989 double cmz;
990 if (sscanf( value, "%lf", &cmz ) == 1)
992 /* SYSTEMINFO doesn't have a slot for cpu speed, so store in a global */
993 cpuHz = cmz * 1000 * 1000;
995 continue;
997 if (!strcasecmp(line, "fdiv_bug"))
999 if (!strncasecmp(value, "yes",3))
1000 user_shared_data->ProcessorFeatures[PF_FLOATING_POINT_PRECISION_ERRATA] = TRUE;
1001 continue;
1003 if (!strcasecmp(line, "fpu"))
1005 if (!strncasecmp(value, "no",2))
1006 user_shared_data->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = TRUE;
1007 continue;
1009 if (!strcasecmp(line, "flags") || !strcasecmp(line, "features"))
1011 if (strstr(value, "cx8"))
1012 user_shared_data->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
1013 if (strstr(value, "mmx"))
1014 user_shared_data->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
1015 if (strstr(value, "tsc"))
1016 user_shared_data->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
1017 if (strstr(value, "3dnow"))
1018 user_shared_data->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = TRUE;
1019 /* This will also catch sse2, but we have sse itself
1020 * if we have sse2, so no problem */
1021 if (strstr(value, "sse"))
1022 user_shared_data->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
1023 if (strstr(value, "sse2"))
1024 user_shared_data->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = TRUE;
1025 if (strstr(value, "pae"))
1026 user_shared_data->ProcessorFeatures[PF_PAE_ENABLED] = TRUE;
1028 continue;
1031 fclose(f);
1033 #elif defined (__NetBSD__)
1035 int mib[2];
1036 int value;
1037 size_t val_len;
1038 char model[256];
1039 char *cpuclass;
1040 FILE *f = fopen("/var/run/dmesg.boot", "r");
1042 /* first deduce as much as possible from the sysctls */
1043 mib[0] = CTL_MACHDEP;
1044 #ifdef CPU_FPU_PRESENT
1045 mib[1] = CPU_FPU_PRESENT;
1046 val_len = sizeof(value);
1047 if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
1048 user_shared_data->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = !value;
1049 #endif
1050 #ifdef CPU_SSE
1051 mib[1] = CPU_SSE; /* this should imply MMX */
1052 val_len = sizeof(value);
1053 if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
1054 if (value) user_shared_data->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
1055 #endif
1056 #ifdef CPU_SSE2
1057 mib[1] = CPU_SSE2; /* this should imply MMX */
1058 val_len = sizeof(value);
1059 if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
1060 if (value) user_shared_data->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
1061 #endif
1062 mib[0] = CTL_HW;
1063 mib[1] = HW_NCPU;
1064 val_len = sizeof(value);
1065 if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
1066 if (value > NtCurrentTeb()->Peb->NumberOfProcessors)
1067 NtCurrentTeb()->Peb->NumberOfProcessors = value;
1068 mib[1] = HW_MODEL;
1069 val_len = sizeof(model)-1;
1070 if (sysctl(mib, 2, model, &val_len, NULL, 0) >= 0)
1072 model[val_len] = '\0'; /* just in case */
1073 cpuclass = strstr(model, "-class");
1074 if (cpuclass != NULL) {
1075 while(cpuclass > model && cpuclass[0] != '(') cpuclass--;
1076 if (!strncmp(cpuclass+1, "386", 3))
1078 cached_sci.Level= 3;
1080 if (!strncmp(cpuclass+1, "486", 3))
1082 cached_sci.Level= 4;
1084 if (!strncmp(cpuclass+1, "586", 3))
1086 cached_sci.Level= 5;
1088 if (!strncmp(cpuclass+1, "686", 3))
1090 cached_sci.Level= 6;
1091 /* this should imply MMX */
1092 user_shared_data->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
1097 /* it may be worth reading from /var/run/dmesg.boot for
1098 additional information such as CX8, MMX and TSC
1099 (however this information should be considered less
1100 reliable than that from the sysctl calls) */
1101 if (f != NULL)
1103 while (fgets(model, 255, f) != NULL)
1105 int cpu, features;
1106 if (sscanf(model, "cpu%d: features %x<", &cpu, &features) == 2)
1108 /* we could scan the string but it is easier
1109 to test the bits directly */
1110 if (features & 0x1)
1111 user_shared_data->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = TRUE;
1112 if (features & 0x10)
1113 user_shared_data->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
1114 if (features & 0x100)
1115 user_shared_data->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
1116 if (features & 0x800000)
1117 user_shared_data->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
1119 break;
1122 fclose(f);
1125 #elif defined(__FreeBSD__)
1127 int ret, num;
1128 size_t len;
1130 get_cpuinfo( &cached_sci );
1132 /* Check for OS support of SSE -- Is this used, and should it be sse1 or sse2? */
1133 /*len = sizeof(num);
1134 ret = sysctlbyname("hw.instruction_sse", &num, &len, NULL, 0);
1135 if (!ret)
1136 user_shared_data->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = num;*/
1138 len = sizeof(num);
1139 ret = sysctlbyname("hw.ncpu", &num, &len, NULL, 0);
1140 if (!ret)
1141 NtCurrentTeb()->Peb->NumberOfProcessors = num;
1143 len = sizeof(num);
1144 if (!sysctlbyname("dev.cpu.0.freq", &num, &len, NULL, 0))
1145 cpuHz = num * 1000 * 1000;
1147 #elif defined(__sun)
1149 int num = sysconf( _SC_NPROCESSORS_ONLN );
1151 if (num == -1) num = 1;
1152 get_cpuinfo( &cached_sci );
1153 NtCurrentTeb()->Peb->NumberOfProcessors = num;
1155 #elif defined (__APPLE__)
1157 size_t valSize;
1158 unsigned long long longVal;
1159 int value;
1160 int cputype;
1161 char buffer[256];
1163 valSize = sizeof(int);
1164 if (sysctlbyname ("hw.optional.floatingpoint", &value, &valSize, NULL, 0) == 0)
1166 if (value)
1167 user_shared_data->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = FALSE;
1168 else
1169 user_shared_data->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = TRUE;
1171 valSize = sizeof(int);
1172 if (sysctlbyname ("hw.ncpu", &value, &valSize, NULL, 0) == 0)
1173 NtCurrentTeb()->Peb->NumberOfProcessors = value;
1175 /* FIXME: we don't use the "hw.activecpu" value... but the cached one */
1177 valSize = sizeof(int);
1178 if (sysctlbyname ("hw.cputype", &cputype, &valSize, NULL, 0) == 0)
1180 switch (cputype)
1182 case CPU_TYPE_POWERPC:
1183 cached_sci.Architecture = PROCESSOR_ARCHITECTURE_PPC;
1184 valSize = sizeof(int);
1185 if (sysctlbyname ("hw.cpusubtype", &value, &valSize, NULL, 0) == 0)
1187 switch (value)
1189 case CPU_SUBTYPE_POWERPC_601:
1190 case CPU_SUBTYPE_POWERPC_602: cached_sci.Level = 1; break;
1191 case CPU_SUBTYPE_POWERPC_603: cached_sci.Level = 3; break;
1192 case CPU_SUBTYPE_POWERPC_603e:
1193 case CPU_SUBTYPE_POWERPC_603ev: cached_sci.Level = 6; break;
1194 case CPU_SUBTYPE_POWERPC_604: cached_sci.Level = 4; break;
1195 case CPU_SUBTYPE_POWERPC_604e: cached_sci.Level = 9; break;
1196 case CPU_SUBTYPE_POWERPC_620: cached_sci.Level = 20; break;
1197 case CPU_SUBTYPE_POWERPC_750: /* G3/G4 derive from 603 so ... */
1198 case CPU_SUBTYPE_POWERPC_7400:
1199 case CPU_SUBTYPE_POWERPC_7450: cached_sci.Level = 6; break;
1200 case CPU_SUBTYPE_POWERPC_970: cached_sci.Level = 9;
1201 /* :o) user_shared_data->ProcessorFeatures[PF_ALTIVEC_INSTRUCTIONS_AVAILABLE] ;-) */
1202 break;
1203 default: break;
1206 break; /* CPU_TYPE_POWERPC */
1207 case CPU_TYPE_I386:
1208 cached_sci.Architecture = PROCESSOR_ARCHITECTURE_INTEL;
1209 valSize = sizeof(int);
1210 if (sysctlbyname ("machdep.cpu.family", &value, &valSize, NULL, 0) == 0)
1212 cached_sci.Level = value;
1214 valSize = sizeof(int);
1215 if (sysctlbyname ("machdep.cpu.model", &value, &valSize, NULL, 0) == 0)
1216 cached_sci.Revision = (value << 8);
1217 valSize = sizeof(int);
1218 if (sysctlbyname ("machdep.cpu.stepping", &value, &valSize, NULL, 0) == 0)
1219 cached_sci.Revision |= value;
1220 valSize = sizeof(buffer);
1221 if (sysctlbyname ("machdep.cpu.features", buffer, &valSize, NULL, 0) == 0)
1223 cached_sci.Revision |= value;
1224 if (strstr(buffer, "CX8")) user_shared_data->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
1225 if (strstr(buffer, "MMX")) user_shared_data->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
1226 if (strstr(buffer, "TSC")) user_shared_data->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
1227 if (strstr(buffer, "3DNOW")) user_shared_data->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = TRUE;
1228 if (strstr(buffer, "SSE")) user_shared_data->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
1229 if (strstr(buffer, "SSE2")) user_shared_data->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = TRUE;
1230 if (strstr(buffer, "PAE")) user_shared_data->ProcessorFeatures[PF_PAE_ENABLED] = TRUE;
1232 break; /* CPU_TYPE_I386 */
1233 default: break;
1234 } /* switch (cputype) */
1236 valSize = sizeof(longVal);
1237 if (!sysctlbyname("hw.cpufrequency", &longVal, &valSize, NULL, 0))
1238 cpuHz = longVal;
1240 #else
1241 FIXME("not yet supported on this system\n");
1242 #endif
1243 TRACE("<- CPU arch %d, level %d, rev %d, features 0x%x\n",
1244 cached_sci.Architecture, cached_sci.Level, cached_sci.Revision, cached_sci.FeatureSet);
1247 /******************************************************************************
1248 * NtQuerySystemInformation [NTDLL.@]
1249 * ZwQuerySystemInformation [NTDLL.@]
1251 * ARGUMENTS:
1252 * SystemInformationClass Index to a certain information structure
1253 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
1254 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
1255 * SystemConfigurationInformation CONFIGURATION_INFORMATION
1256 * observed (class/len):
1257 * 0x0/0x2c
1258 * 0x12/0x18
1259 * 0x2/0x138
1260 * 0x8/0x600
1261 * 0x25/0xc
1262 * SystemInformation caller supplies storage for the information structure
1263 * Length size of the structure
1264 * ResultLength Data written
1266 NTSTATUS WINAPI NtQuerySystemInformation(
1267 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
1268 OUT PVOID SystemInformation,
1269 IN ULONG Length,
1270 OUT PULONG ResultLength)
1272 NTSTATUS ret = STATUS_SUCCESS;
1273 ULONG len = 0;
1275 TRACE("(0x%08x,%p,0x%08x,%p)\n",
1276 SystemInformationClass,SystemInformation,Length,ResultLength);
1278 switch (SystemInformationClass)
1280 case SystemBasicInformation:
1282 SYSTEM_BASIC_INFORMATION sbi;
1284 virtual_get_system_info( &sbi );
1285 len = sizeof(sbi);
1287 if ( Length == len)
1289 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
1290 else memcpy( SystemInformation, &sbi, len);
1292 else ret = STATUS_INFO_LENGTH_MISMATCH;
1294 break;
1295 case SystemCpuInformation:
1296 if (Length >= (len = sizeof(cached_sci)))
1298 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
1299 else memcpy(SystemInformation, &cached_sci, len);
1301 else ret = STATUS_INFO_LENGTH_MISMATCH;
1302 break;
1303 case SystemPerformanceInformation:
1305 SYSTEM_PERFORMANCE_INFORMATION spi;
1306 static BOOL fixme_written = FALSE;
1308 memset(&spi, 0 , sizeof(spi));
1309 len = sizeof(spi);
1311 if (Length >= len)
1313 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
1314 else memcpy( SystemInformation, &spi, len);
1316 else ret = STATUS_INFO_LENGTH_MISMATCH;
1317 if(!fixme_written) {
1318 FIXME("info_class SYSTEM_PERFORMANCE_INFORMATION\n");
1319 fixme_written = TRUE;
1322 break;
1323 case SystemTimeOfDayInformation:
1325 SYSTEM_TIMEOFDAY_INFORMATION sti;
1327 memset(&sti, 0 , sizeof(sti));
1329 /* liKeSystemTime, liExpTimeZoneBias, uCurrentTimeZoneId */
1330 sti.liKeBootTime.QuadPart = server_start_time;
1332 if (Length <= sizeof(sti))
1334 len = Length;
1335 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
1336 else memcpy( SystemInformation, &sti, Length);
1338 else ret = STATUS_INFO_LENGTH_MISMATCH;
1340 break;
1341 case SystemProcessInformation:
1343 SYSTEM_PROCESS_INFORMATION* spi = SystemInformation;
1344 SYSTEM_PROCESS_INFORMATION* last = NULL;
1345 HANDLE hSnap = 0;
1346 WCHAR procname[1024];
1347 WCHAR* exename;
1348 DWORD wlen = 0;
1349 DWORD procstructlen = 0;
1351 SERVER_START_REQ( create_snapshot )
1353 req->flags = SNAP_PROCESS | SNAP_THREAD;
1354 req->attributes = 0;
1355 if (!(ret = wine_server_call( req )))
1356 hSnap = wine_server_ptr_handle( reply->handle );
1358 SERVER_END_REQ;
1359 len = 0;
1360 while (ret == STATUS_SUCCESS)
1362 SERVER_START_REQ( next_process )
1364 req->handle = wine_server_obj_handle( hSnap );
1365 req->reset = (len == 0);
1366 wine_server_set_reply( req, procname, sizeof(procname)-sizeof(WCHAR) );
1367 if (!(ret = wine_server_call( req )))
1369 /* Make sure procname is 0 terminated */
1370 procname[wine_server_reply_size(reply) / sizeof(WCHAR)] = 0;
1372 /* Get only the executable name, not the path */
1373 if ((exename = strrchrW(procname, '\\')) != NULL) exename++;
1374 else exename = procname;
1376 wlen = (strlenW(exename) + 1) * sizeof(WCHAR);
1378 procstructlen = sizeof(*spi) + wlen + ((reply->threads - 1) * sizeof(SYSTEM_THREAD_INFORMATION));
1380 if (Length >= len + procstructlen)
1382 /* ftCreationTime, ftUserTime, ftKernelTime;
1383 * vmCounters, ioCounters
1386 memset(spi, 0, sizeof(*spi));
1388 spi->NextEntryOffset = procstructlen - wlen;
1389 spi->dwThreadCount = reply->threads;
1391 /* spi->pszProcessName will be set later on */
1393 spi->dwBasePriority = reply->priority;
1394 spi->UniqueProcessId = UlongToHandle(reply->pid);
1395 spi->ParentProcessId = UlongToHandle(reply->ppid);
1396 spi->HandleCount = reply->handles;
1398 /* spi->ti will be set later on */
1400 len += procstructlen;
1402 else ret = STATUS_INFO_LENGTH_MISMATCH;
1405 SERVER_END_REQ;
1407 if (ret != STATUS_SUCCESS)
1409 if (ret == STATUS_NO_MORE_FILES) ret = STATUS_SUCCESS;
1410 break;
1412 else /* Length is already checked for */
1414 int i, j;
1416 /* set thread info */
1417 i = j = 0;
1418 while (ret == STATUS_SUCCESS)
1420 SERVER_START_REQ( next_thread )
1422 req->handle = wine_server_obj_handle( hSnap );
1423 req->reset = (j == 0);
1424 if (!(ret = wine_server_call( req )))
1426 j++;
1427 if (UlongToHandle(reply->pid) == spi->UniqueProcessId)
1429 /* ftKernelTime, ftUserTime, ftCreateTime;
1430 * dwTickCount, dwStartAddress
1433 memset(&spi->ti[i], 0, sizeof(spi->ti));
1435 spi->ti[i].CreateTime.QuadPart = 0xdeadbeef;
1436 spi->ti[i].ClientId.UniqueProcess = UlongToHandle(reply->pid);
1437 spi->ti[i].ClientId.UniqueThread = UlongToHandle(reply->tid);
1438 spi->ti[i].dwCurrentPriority = reply->base_pri + reply->delta_pri;
1439 spi->ti[i].dwBasePriority = reply->base_pri;
1440 i++;
1444 SERVER_END_REQ;
1446 if (ret == STATUS_NO_MORE_FILES) ret = STATUS_SUCCESS;
1448 /* now append process name */
1449 spi->ProcessName.Buffer = (WCHAR*)((char*)spi + spi->NextEntryOffset);
1450 spi->ProcessName.Length = wlen - sizeof(WCHAR);
1451 spi->ProcessName.MaximumLength = wlen;
1452 memcpy( spi->ProcessName.Buffer, exename, wlen );
1453 spi->NextEntryOffset += wlen;
1455 last = spi;
1456 spi = (SYSTEM_PROCESS_INFORMATION*)((char*)spi + spi->NextEntryOffset);
1459 if (ret == STATUS_SUCCESS && last) last->NextEntryOffset = 0;
1460 if (hSnap) NtClose(hSnap);
1462 break;
1463 case SystemProcessorPerformanceInformation:
1465 SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION *sppi = NULL;
1466 unsigned int cpus = 0;
1467 int out_cpus = Length / sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION);
1469 if (out_cpus == 0)
1471 len = 0;
1472 ret = STATUS_INFO_LENGTH_MISMATCH;
1473 break;
1475 else
1476 #ifdef __APPLE__
1478 processor_cpu_load_info_data_t *pinfo;
1479 mach_msg_type_number_t info_count;
1481 if (host_processor_info (mach_host_self (),
1482 PROCESSOR_CPU_LOAD_INFO,
1483 &cpus,
1484 (processor_info_array_t*)&pinfo,
1485 &info_count) == 0)
1487 int i;
1488 cpus = min(cpus,out_cpus);
1489 len = sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * cpus;
1490 sppi = RtlAllocateHeap(GetProcessHeap(), 0,len);
1491 for (i = 0; i < cpus; i++)
1493 sppi[i].IdleTime.QuadPart = pinfo[i].cpu_ticks[CPU_STATE_IDLE];
1494 sppi[i].KernelTime.QuadPart = pinfo[i].cpu_ticks[CPU_STATE_SYSTEM];
1495 sppi[i].UserTime.QuadPart = pinfo[i].cpu_ticks[CPU_STATE_USER];
1497 vm_deallocate (mach_task_self (), (vm_address_t) pinfo, info_count * sizeof(natural_t));
1500 #else
1502 FILE *cpuinfo = fopen("/proc/stat", "r");
1503 if (cpuinfo)
1505 unsigned usr,nice,sys;
1506 unsigned long idle;
1507 int count;
1508 char name[10];
1509 char line[255];
1511 /* first line is combined usage */
1512 if (fgets(line,255,cpuinfo))
1513 count = sscanf(line, "%s %u %u %u %lu", name, &usr, &nice,
1514 &sys, &idle);
1515 else
1516 count = 0;
1517 /* we set this up in the for older non-smp enabled kernels */
1518 if (count == 5 && strcmp(name, "cpu") == 0)
1520 sppi = RtlAllocateHeap(GetProcessHeap(), 0,
1521 sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION));
1522 sppi->IdleTime.QuadPart = idle;
1523 sppi->KernelTime.QuadPart = sys;
1524 sppi->UserTime.QuadPart = usr;
1525 cpus = 1;
1526 len = sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION);
1531 if (fgets(line, 255, cpuinfo))
1532 count = sscanf(line, "%s %u %u %u %lu", name, &usr,
1533 &nice, &sys, &idle);
1534 else
1535 count = 0;
1536 if (count == 5 && strncmp(name, "cpu", 3)==0)
1538 out_cpus --;
1539 if (name[3]=='0') /* first cpu */
1541 sppi->IdleTime.QuadPart = idle;
1542 sppi->KernelTime.QuadPart = sys;
1543 sppi->UserTime.QuadPart = usr;
1545 else /* new cpu */
1547 len = sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * (cpus+1);
1548 sppi = RtlReAllocateHeap(GetProcessHeap(), 0, sppi, len);
1549 sppi[cpus].IdleTime.QuadPart = idle;
1550 sppi[cpus].KernelTime.QuadPart = sys;
1551 sppi[cpus].UserTime.QuadPart = usr;
1552 cpus++;
1555 else
1556 break;
1557 } while (out_cpus > 0);
1558 fclose(cpuinfo);
1561 #endif
1563 if (cpus == 0)
1565 static int i = 1;
1567 sppi = RtlAllocateHeap(GetProcessHeap(),0,sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION));
1569 memset(sppi, 0 , sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION));
1570 FIXME("stub info_class SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION\n");
1572 /* many programs expect these values to change so fake change */
1573 len = sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION);
1574 sppi->KernelTime.QuadPart = 1 * i;
1575 sppi->UserTime.QuadPart = 2 * i;
1576 sppi->IdleTime.QuadPart = 3 * i;
1577 i++;
1580 if (Length >= len)
1582 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
1583 else memcpy( SystemInformation, sppi, len);
1585 else ret = STATUS_INFO_LENGTH_MISMATCH;
1587 RtlFreeHeap(GetProcessHeap(),0,sppi);
1589 break;
1590 case SystemModuleInformation:
1591 /* FIXME: should be system-wide */
1592 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
1593 else ret = LdrQueryProcessModuleInformation( SystemInformation, Length, &len );
1594 break;
1595 case SystemHandleInformation:
1597 SYSTEM_HANDLE_INFORMATION shi;
1599 memset(&shi, 0, sizeof(shi));
1600 len = sizeof(shi);
1602 if ( Length >= len)
1604 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
1605 else memcpy( SystemInformation, &shi, len);
1607 else ret = STATUS_INFO_LENGTH_MISMATCH;
1608 FIXME("info_class SYSTEM_HANDLE_INFORMATION\n");
1610 break;
1611 case SystemCacheInformation:
1613 SYSTEM_CACHE_INFORMATION sci;
1615 memset(&sci, 0, sizeof(sci)); /* FIXME */
1616 len = sizeof(sci);
1618 if ( Length >= len)
1620 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
1621 else memcpy( SystemInformation, &sci, len);
1623 else ret = STATUS_INFO_LENGTH_MISMATCH;
1624 FIXME("info_class SYSTEM_CACHE_INFORMATION\n");
1626 break;
1627 case SystemInterruptInformation:
1629 SYSTEM_INTERRUPT_INFORMATION sii;
1631 memset(&sii, 0, sizeof(sii));
1632 len = sizeof(sii);
1634 if ( Length >= len)
1636 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
1637 else memcpy( SystemInformation, &sii, len);
1639 else ret = STATUS_INFO_LENGTH_MISMATCH;
1640 FIXME("info_class SYSTEM_INTERRUPT_INFORMATION\n");
1642 break;
1643 case SystemKernelDebuggerInformation:
1645 SYSTEM_KERNEL_DEBUGGER_INFORMATION skdi;
1647 skdi.DebuggerEnabled = FALSE;
1648 skdi.DebuggerNotPresent = TRUE;
1649 len = sizeof(skdi);
1651 if ( Length >= len)
1653 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
1654 else memcpy( SystemInformation, &skdi, len);
1656 else ret = STATUS_INFO_LENGTH_MISMATCH;
1658 break;
1659 case SystemRegistryQuotaInformation:
1661 /* Something to do with the size of the registry *
1662 * Since we don't have a size limitation, fake it *
1663 * This is almost certainly wrong. *
1664 * This sets each of the three words in the struct to 32 MB, *
1665 * which is enough to make the IE 5 installer happy. */
1666 SYSTEM_REGISTRY_QUOTA_INFORMATION srqi;
1668 srqi.RegistryQuotaAllowed = 0x2000000;
1669 srqi.RegistryQuotaUsed = 0x200000;
1670 srqi.Reserved1 = (void*)0x200000;
1671 len = sizeof(srqi);
1673 if ( Length >= len)
1675 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
1676 else
1678 FIXME("SystemRegistryQuotaInformation: faking max registry size of 32 MB\n");
1679 memcpy( SystemInformation, &srqi, len);
1682 else ret = STATUS_INFO_LENGTH_MISMATCH;
1684 break;
1685 default:
1686 FIXME("(0x%08x,%p,0x%08x,%p) stub\n",
1687 SystemInformationClass,SystemInformation,Length,ResultLength);
1689 /* Several Information Classes are not implemented on Windows and return 2 different values
1690 * STATUS_NOT_IMPLEMENTED or STATUS_INVALID_INFO_CLASS
1691 * in 95% of the cases it's STATUS_INVALID_INFO_CLASS, so use this as the default
1693 ret = STATUS_INVALID_INFO_CLASS;
1696 if (ResultLength) *ResultLength = len;
1698 return ret;
1701 /******************************************************************************
1702 * NtSetSystemInformation [NTDLL.@]
1703 * ZwSetSystemInformation [NTDLL.@]
1705 NTSTATUS WINAPI NtSetSystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, PVOID SystemInformation, ULONG Length)
1707 FIXME("(0x%08x,%p,0x%08x) stub\n",SystemInformationClass,SystemInformation,Length);
1708 return STATUS_SUCCESS;
1711 /******************************************************************************
1712 * NtCreatePagingFile [NTDLL.@]
1713 * ZwCreatePagingFile [NTDLL.@]
1715 NTSTATUS WINAPI NtCreatePagingFile(
1716 PUNICODE_STRING PageFileName,
1717 PLARGE_INTEGER MinimumSize,
1718 PLARGE_INTEGER MaximumSize,
1719 PLARGE_INTEGER ActualSize)
1721 FIXME("(%p %p %p %p) stub\n", PageFileName, MinimumSize, MaximumSize, ActualSize);
1722 return STATUS_SUCCESS;
1725 /******************************************************************************
1726 * NtDisplayString [NTDLL.@]
1728 * writes a string to the nt-textmode screen eg. during startup
1730 NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
1732 STRING stringA;
1733 NTSTATUS ret;
1735 if (!(ret = RtlUnicodeStringToAnsiString( &stringA, string, TRUE )))
1737 MESSAGE( "%.*s", stringA.Length, stringA.Buffer );
1738 RtlFreeAnsiString( &stringA );
1740 return ret;
1743 /******************************************************************************
1744 * NtInitiatePowerAction [NTDLL.@]
1747 NTSTATUS WINAPI NtInitiatePowerAction(
1748 IN POWER_ACTION SystemAction,
1749 IN SYSTEM_POWER_STATE MinSystemState,
1750 IN ULONG Flags,
1751 IN BOOLEAN Asynchronous)
1753 FIXME("(%d,%d,0x%08x,%d),stub\n",
1754 SystemAction,MinSystemState,Flags,Asynchronous);
1755 return STATUS_NOT_IMPLEMENTED;
1759 /******************************************************************************
1760 * NtPowerInformation [NTDLL.@]
1763 NTSTATUS WINAPI NtPowerInformation(
1764 IN POWER_INFORMATION_LEVEL InformationLevel,
1765 IN PVOID lpInputBuffer,
1766 IN ULONG nInputBufferSize,
1767 IN PVOID lpOutputBuffer,
1768 IN ULONG nOutputBufferSize)
1770 TRACE("(%d,%p,%d,%p,%d)\n",
1771 InformationLevel,lpInputBuffer,nInputBufferSize,lpOutputBuffer,nOutputBufferSize);
1772 switch(InformationLevel) {
1773 case SystemPowerCapabilities: {
1774 PSYSTEM_POWER_CAPABILITIES PowerCaps = lpOutputBuffer;
1775 FIXME("semi-stub: SystemPowerCapabilities\n");
1776 if (nOutputBufferSize < sizeof(SYSTEM_POWER_CAPABILITIES))
1777 return STATUS_BUFFER_TOO_SMALL;
1778 /* FIXME: These values are based off a native XP desktop, should probably use APM/ACPI to get the 'real' values */
1779 PowerCaps->PowerButtonPresent = TRUE;
1780 PowerCaps->SleepButtonPresent = FALSE;
1781 PowerCaps->LidPresent = FALSE;
1782 PowerCaps->SystemS1 = TRUE;
1783 PowerCaps->SystemS2 = FALSE;
1784 PowerCaps->SystemS3 = FALSE;
1785 PowerCaps->SystemS4 = TRUE;
1786 PowerCaps->SystemS5 = TRUE;
1787 PowerCaps->HiberFilePresent = TRUE;
1788 PowerCaps->FullWake = TRUE;
1789 PowerCaps->VideoDimPresent = FALSE;
1790 PowerCaps->ApmPresent = FALSE;
1791 PowerCaps->UpsPresent = FALSE;
1792 PowerCaps->ThermalControl = FALSE;
1793 PowerCaps->ProcessorThrottle = FALSE;
1794 PowerCaps->ProcessorMinThrottle = 100;
1795 PowerCaps->ProcessorMaxThrottle = 100;
1796 PowerCaps->DiskSpinDown = TRUE;
1797 PowerCaps->SystemBatteriesPresent = FALSE;
1798 PowerCaps->BatteriesAreShortTerm = FALSE;
1799 PowerCaps->BatteryScale[0].Granularity = 0;
1800 PowerCaps->BatteryScale[0].Capacity = 0;
1801 PowerCaps->BatteryScale[1].Granularity = 0;
1802 PowerCaps->BatteryScale[1].Capacity = 0;
1803 PowerCaps->BatteryScale[2].Granularity = 0;
1804 PowerCaps->BatteryScale[2].Capacity = 0;
1805 PowerCaps->AcOnLineWake = PowerSystemUnspecified;
1806 PowerCaps->SoftLidWake = PowerSystemUnspecified;
1807 PowerCaps->RtcWake = PowerSystemSleeping1;
1808 PowerCaps->MinDeviceWakeState = PowerSystemUnspecified;
1809 PowerCaps->DefaultLowLatencyWake = PowerSystemUnspecified;
1810 return STATUS_SUCCESS;
1812 case SystemExecutionState: {
1813 PULONG ExecutionState = lpOutputBuffer;
1814 WARN("semi-stub: SystemExecutionState\n"); /* Needed for .NET Framework, but using a FIXME is really noisy. */
1815 if (lpInputBuffer != NULL)
1816 return STATUS_INVALID_PARAMETER;
1817 /* FIXME: The actual state should be the value set by SetThreadExecutionState which is not currently implemented. */
1818 *ExecutionState = ES_USER_PRESENT;
1819 return STATUS_SUCCESS;
1821 case ProcessorInformation: {
1822 PPROCESSOR_POWER_INFORMATION cpu_power = lpOutputBuffer;
1824 WARN("semi-stub: ProcessorInformation\n");
1825 if (nOutputBufferSize < sizeof(PROCESSOR_POWER_INFORMATION))
1826 return STATUS_BUFFER_TOO_SMALL;
1827 cpu_power->Number = NtCurrentTeb()->Peb->NumberOfProcessors;
1828 cpu_power->MaxMhz = cpuHz / 1000000;
1829 cpu_power->CurrentMhz = cpuHz / 1000000;
1830 cpu_power->MhzLimit = cpuHz / 1000000;
1831 cpu_power->MaxIdleState = 0; /* FIXME */
1832 cpu_power->CurrentIdleState = 0; /* FIXME */
1833 return STATUS_SUCCESS;
1835 default:
1836 /* FIXME: Needed by .NET Framework */
1837 WARN("Unimplemented NtPowerInformation action: %d\n", InformationLevel);
1838 return STATUS_NOT_IMPLEMENTED;
1842 /******************************************************************************
1843 * NtShutdownSystem [NTDLL.@]
1846 NTSTATUS WINAPI NtShutdownSystem(SHUTDOWN_ACTION Action)
1848 FIXME("%d\n",Action);
1849 return STATUS_SUCCESS;
1852 /******************************************************************************
1853 * NtAllocateLocallyUniqueId (NTDLL.@)
1855 NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
1857 NTSTATUS status;
1859 TRACE("%p\n", Luid);
1861 if (!Luid)
1862 return STATUS_ACCESS_VIOLATION;
1864 SERVER_START_REQ( allocate_locally_unique_id )
1866 status = wine_server_call( req );
1867 if (!status)
1869 Luid->LowPart = reply->luid.low_part;
1870 Luid->HighPart = reply->luid.high_part;
1873 SERVER_END_REQ;
1875 return status;
1878 /******************************************************************************
1879 * VerSetConditionMask (NTDLL.@)
1881 ULONGLONG WINAPI VerSetConditionMask( ULONGLONG dwlConditionMask, DWORD dwTypeBitMask,
1882 BYTE dwConditionMask)
1884 if(dwTypeBitMask == 0)
1885 return dwlConditionMask;
1886 dwConditionMask &= 0x07;
1887 if(dwConditionMask == 0)
1888 return dwlConditionMask;
1890 if(dwTypeBitMask & VER_PRODUCT_TYPE)
1891 dwlConditionMask |= dwConditionMask << 7*3;
1892 else if (dwTypeBitMask & VER_SUITENAME)
1893 dwlConditionMask |= dwConditionMask << 6*3;
1894 else if (dwTypeBitMask & VER_SERVICEPACKMAJOR)
1895 dwlConditionMask |= dwConditionMask << 5*3;
1896 else if (dwTypeBitMask & VER_SERVICEPACKMINOR)
1897 dwlConditionMask |= dwConditionMask << 4*3;
1898 else if (dwTypeBitMask & VER_PLATFORMID)
1899 dwlConditionMask |= dwConditionMask << 3*3;
1900 else if (dwTypeBitMask & VER_BUILDNUMBER)
1901 dwlConditionMask |= dwConditionMask << 2*3;
1902 else if (dwTypeBitMask & VER_MAJORVERSION)
1903 dwlConditionMask |= dwConditionMask << 1*3;
1904 else if (dwTypeBitMask & VER_MINORVERSION)
1905 dwlConditionMask |= dwConditionMask << 0*3;
1906 return dwlConditionMask;
1909 /******************************************************************************
1910 * NtAccessCheckAndAuditAlarm (NTDLL.@)
1911 * ZwAccessCheckAndAuditAlarm (NTDLL.@)
1913 NTSTATUS WINAPI NtAccessCheckAndAuditAlarm(PUNICODE_STRING SubsystemName, HANDLE HandleId, PUNICODE_STRING ObjectTypeName,
1914 PUNICODE_STRING ObjectName, PSECURITY_DESCRIPTOR SecurityDescriptor,
1915 ACCESS_MASK DesiredAccess, PGENERIC_MAPPING GenericMapping, BOOLEAN ObjectCreation,
1916 PACCESS_MASK GrantedAccess, PBOOLEAN AccessStatus, PBOOLEAN GenerateOnClose)
1918 FIXME("(%s, %p, %s, %p, 0x%08x, %p, %d, %p, %p, %p), stub\n", debugstr_us(SubsystemName), HandleId,
1919 debugstr_us(ObjectTypeName), SecurityDescriptor, DesiredAccess, GenericMapping, ObjectCreation,
1920 GrantedAccess, AccessStatus, GenerateOnClose);
1922 return STATUS_NOT_IMPLEMENTED;