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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #define WIN32_NO_STATUS
32 #include "wine/debug.h"
33 #include "wine/unicode.h"
36 #include "ntdll_misc.h"
37 #include "wine/server.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
45 /******************************************************************************
46 * NtDuplicateToken [NTDLL.@]
47 * ZwDuplicateToken [NTDLL.@]
49 NTSTATUS WINAPI NtDuplicateToken(
50 IN HANDLE ExistingToken,
51 IN ACCESS_MASK DesiredAccess,
52 IN POBJECT_ATTRIBUTES ObjectAttributes,
53 IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
54 IN TOKEN_TYPE TokenType,
59 TRACE("(%p,0x%08lx,%p,0x%08x,0x%08x,%p)\n",
60 ExistingToken, DesiredAccess, ObjectAttributes,
61 ImpersonationLevel, TokenType, NewToken);
62 dump_ObjectAttributes(ObjectAttributes);
64 SERVER_START_REQ( duplicate_token )
66 req->handle = ExistingToken;
67 req->access = DesiredAccess;
68 req->inherit = ObjectAttributes && (ObjectAttributes->Attributes & OBJ_INHERIT);
69 req->primary = (TokenType == TokenPrimary);
70 req->impersonation_level = ImpersonationLevel;
71 status = wine_server_call( req );
72 if (!status) *NewToken = reply->new_handle;
79 /******************************************************************************
80 * NtOpenProcessToken [NTDLL.@]
81 * ZwOpenProcessToken [NTDLL.@]
83 NTSTATUS WINAPI NtOpenProcessToken(
90 TRACE("(%p,0x%08lx,%p)\n", ProcessHandle,DesiredAccess, TokenHandle);
92 SERVER_START_REQ( open_token )
94 req->handle = ProcessHandle;
96 ret = wine_server_call( req );
97 if (!ret) *TokenHandle = reply->token;
104 /******************************************************************************
105 * NtOpenThreadToken [NTDLL.@]
106 * ZwOpenThreadToken [NTDLL.@]
108 NTSTATUS WINAPI NtOpenThreadToken(
116 TRACE("(%p,0x%08lx,0x%08x,%p)\n",
117 ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);
119 SERVER_START_REQ( open_token )
121 req->handle = ThreadHandle;
122 req->flags = OPEN_TOKEN_THREAD;
123 if (OpenAsSelf) req->flags |= OPEN_TOKEN_AS_SELF;
124 ret = wine_server_call( req );
125 if (!ret) *TokenHandle = reply->token;
132 /******************************************************************************
133 * NtAdjustPrivilegesToken [NTDLL.@]
134 * ZwAdjustPrivilegesToken [NTDLL.@]
136 * FIXME: parameters unsafe
138 NTSTATUS WINAPI NtAdjustPrivilegesToken(
139 IN HANDLE TokenHandle,
140 IN BOOLEAN DisableAllPrivileges,
141 IN PTOKEN_PRIVILEGES NewState,
142 IN DWORD BufferLength,
143 OUT PTOKEN_PRIVILEGES PreviousState,
144 OUT PDWORD ReturnLength)
148 TRACE("(%p,0x%08x,%p,0x%08lx,%p,%p)\n",
149 TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength);
151 SERVER_START_REQ( adjust_token_privileges )
153 req->handle = TokenHandle;
154 req->disable_all = DisableAllPrivileges;
155 req->get_modified_state = (PreviousState != NULL);
156 if (!DisableAllPrivileges)
158 wine_server_add_data( req, &NewState->Privileges,
159 NewState->PrivilegeCount * sizeof(NewState->Privileges[0]) );
161 if (PreviousState && BufferLength >= FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ))
162 wine_server_set_reply( req, &PreviousState->Privileges,
163 BufferLength - FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) );
164 ret = wine_server_call( req );
167 *ReturnLength = reply->len + FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges );
168 PreviousState->PrivilegeCount = reply->len / sizeof(LUID_AND_ATTRIBUTES);
176 /******************************************************************************
177 * NtQueryInformationToken [NTDLL.@]
178 * ZwQueryInformationToken [NTDLL.@]
181 * Buffer for TokenUser:
182 * 0x00 TOKEN_USER the PSID field points to the SID
186 NTSTATUS WINAPI NtQueryInformationToken(
188 DWORD tokeninfoclass,
190 DWORD tokeninfolength,
193 unsigned int len = 0;
194 NTSTATUS status = STATUS_SUCCESS;
196 TRACE("(%p,%ld,%p,%ld,%p)\n",
197 token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);
199 switch (tokeninfoclass)
202 len = sizeof(TOKEN_GROUPS);
205 len = sizeof(TOKEN_OWNER) + sizeof(SID);
207 case TokenPrimaryGroup:
208 len = sizeof(TOKEN_PRIMARY_GROUP);
210 case TokenDefaultDacl:
211 len = sizeof(TOKEN_DEFAULT_DACL);
214 len = sizeof(TOKEN_SOURCE);
217 len = sizeof (TOKEN_TYPE);
220 case TokenImpersonationLevel:
221 case TokenStatistics:
225 /* FIXME: what if retlen == NULL ? */
228 if (tokeninfolength < len)
229 return STATUS_BUFFER_TOO_SMALL;
231 switch (tokeninfoclass)
234 SERVER_START_REQ( get_token_user )
236 TOKEN_USER * tuser = tokeninfo;
237 PSID sid = (PSID) (tuser + 1);
238 DWORD sid_len = tokeninfolength < sizeof(TOKEN_USER) ? 0 : tokeninfolength - sizeof(TOKEN_USER);
241 wine_server_set_reply( req, sid, sid_len );
242 status = wine_server_call( req );
243 *retlen = reply->user_len + sizeof(TOKEN_USER);
244 if (status == STATUS_SUCCESS)
246 tuser->User.Sid = sid;
247 tuser->User.Attributes = 0;
255 TOKEN_GROUPS *tgroups = tokeninfo;
256 SID_IDENTIFIER_AUTHORITY sid = {SECURITY_NT_AUTHORITY};
258 /* we need to show admin privileges ! */
259 tgroups->GroupCount = 1;
260 tgroups->Groups->Attributes = SE_GROUP_ENABLED;
261 RtlAllocateAndInitializeSid( &sid,
263 SECURITY_BUILTIN_DOMAIN_RID,
264 DOMAIN_ALIAS_RID_ADMINS,
266 &(tgroups->Groups->Sid));
269 case TokenPrimaryGroup:
272 TOKEN_PRIMARY_GROUP *tgroup = tokeninfo;
273 SID_IDENTIFIER_AUTHORITY sid = {SECURITY_NT_AUTHORITY};
274 RtlAllocateAndInitializeSid( &sid,
276 SECURITY_BUILTIN_DOMAIN_RID,
277 DOMAIN_ALIAS_RID_ADMINS,
279 &(tgroup->PrimaryGroup));
282 case TokenPrivileges:
283 SERVER_START_REQ( get_token_privileges )
285 TOKEN_PRIVILEGES *tpriv = tokeninfo;
287 if (tpriv && tokeninfolength > FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ))
288 wine_server_set_reply( req, &tpriv->Privileges, tokeninfolength - FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) );
289 status = wine_server_call( req );
290 *retlen = FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) + reply->len;
291 if (tpriv) tpriv->PrivilegeCount = reply->len / sizeof(LUID_AND_ATTRIBUTES);
298 TOKEN_OWNER *owner = tokeninfo;
299 PSID sid = (PSID) (owner + 1);
300 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
301 RtlInitializeSid(sid, &localSidAuthority, 1);
302 *(RtlSubAuthoritySid(sid, 0)) = SECURITY_INTERACTIVE_RID;
308 ERR("Unhandled Token Information class %ld!\n", tokeninfoclass);
309 return STATUS_NOT_IMPLEMENTED;
315 /******************************************************************************
316 * NtSetInformationToken [NTDLL.@]
317 * ZwSetInformationToken [NTDLL.@]
319 NTSTATUS WINAPI NtSetInformationToken(
321 TOKEN_INFORMATION_CLASS TokenInformationClass,
322 PVOID TokenInformation,
323 ULONG TokenInformationLength)
325 FIXME("%p %d %p %lu\n", TokenHandle, TokenInformationClass,
326 TokenInformation, TokenInformationLength);
327 return STATUS_NOT_IMPLEMENTED;
330 /******************************************************************************
331 * NtAdjustGroupsToken [NTDLL.@]
332 * ZwAdjustGroupsToken [NTDLL.@]
334 NTSTATUS WINAPI NtAdjustGroupsToken(
336 BOOLEAN ResetToDefault,
337 PTOKEN_GROUPS NewState,
339 PTOKEN_GROUPS PreviousState,
342 FIXME("%p %d %p %lu %p %p\n", TokenHandle, ResetToDefault,
343 NewState, BufferLength, PreviousState, ReturnLength);
344 return STATUS_NOT_IMPLEMENTED;
347 /******************************************************************************
348 * NtPrivilegeCheck [NTDLL.@]
349 * ZwPrivilegeCheck [NTDLL.@]
351 NTSTATUS WINAPI NtPrivilegeCheck(
353 PPRIVILEGE_SET RequiredPrivileges,
357 SERVER_START_REQ( check_token_privileges )
359 req->handle = ClientToken;
360 req->all_required = ((RequiredPrivileges->Control & PRIVILEGE_SET_ALL_NECESSARY) ? TRUE : FALSE);
361 wine_server_add_data( req, &RequiredPrivileges->Privilege,
362 RequiredPrivileges->PrivilegeCount * sizeof(RequiredPrivileges->Privilege[0]) );
363 wine_server_set_reply( req, &RequiredPrivileges->Privilege,
364 RequiredPrivileges->PrivilegeCount * sizeof(RequiredPrivileges->Privilege[0]) );
366 status = wine_server_call( req );
368 if (status == STATUS_SUCCESS)
369 *Result = (reply->has_privileges ? TRUE : FALSE);
379 /******************************************************************************
380 * NtQuerySection [NTDLL.@]
382 NTSTATUS WINAPI NtQuerySection(
383 IN HANDLE SectionHandle,
384 IN SECTION_INFORMATION_CLASS SectionInformationClass,
385 OUT PVOID SectionInformation,
387 OUT PULONG ResultLength)
389 FIXME("(%p,%d,%p,0x%08lx,%p) stub!\n",
390 SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
398 /******************************************************************************
399 * NtCreatePort [NTDLL.@]
400 * ZwCreatePort [NTDLL.@]
402 NTSTATUS WINAPI NtCreatePort(PHANDLE PortHandle,POBJECT_ATTRIBUTES ObjectAttributes,
403 ULONG MaxConnectInfoLength,ULONG MaxDataLength,PULONG reserved)
405 FIXME("(%p,%p,%lu,%lu,%p),stub!\n",PortHandle,ObjectAttributes,
406 MaxConnectInfoLength,MaxDataLength,reserved);
410 /******************************************************************************
411 * NtConnectPort [NTDLL.@]
412 * ZwConnectPort [NTDLL.@]
414 NTSTATUS WINAPI NtConnectPort(
416 PUNICODE_STRING PortName,
417 PSECURITY_QUALITY_OF_SERVICE SecurityQos,
418 PLPC_SECTION_WRITE WriteSection,
419 PLPC_SECTION_READ ReadSection,
420 PULONG MaximumMessageLength,
422 PULONG pConnectInfoLength)
424 FIXME("(%p,%s,%p,%p,%p,%p,%p,%p),stub!\n",
425 PortHandle,debugstr_w(PortName->Buffer),SecurityQos,
426 WriteSection,ReadSection,MaximumMessageLength,ConnectInfo,
428 if (ConnectInfo && pConnectInfoLength)
429 TRACE("\tMessage = %s\n",debugstr_an(ConnectInfo,*pConnectInfoLength));
433 /******************************************************************************
434 * NtListenPort [NTDLL.@]
435 * ZwListenPort [NTDLL.@]
437 NTSTATUS WINAPI NtListenPort(HANDLE PortHandle,PLPC_MESSAGE pLpcMessage)
439 FIXME("(%p,%p),stub!\n",PortHandle,pLpcMessage);
443 /******************************************************************************
444 * NtAcceptConnectPort [NTDLL.@]
445 * ZwAcceptConnectPort [NTDLL.@]
447 NTSTATUS WINAPI NtAcceptConnectPort(
449 ULONG PortIdentifier,
450 PLPC_MESSAGE pLpcMessage,
452 PLPC_SECTION_WRITE WriteSection,
453 PLPC_SECTION_READ ReadSection)
455 FIXME("(%p,%lu,%p,%d,%p,%p),stub!\n",
456 PortHandle,PortIdentifier,pLpcMessage,Accept,WriteSection,ReadSection);
460 /******************************************************************************
461 * NtCompleteConnectPort [NTDLL.@]
462 * ZwCompleteConnectPort [NTDLL.@]
464 NTSTATUS WINAPI NtCompleteConnectPort(HANDLE PortHandle)
466 FIXME("(%p),stub!\n",PortHandle);
470 /******************************************************************************
471 * NtRegisterThreadTerminatePort [NTDLL.@]
472 * ZwRegisterThreadTerminatePort [NTDLL.@]
474 NTSTATUS WINAPI NtRegisterThreadTerminatePort(HANDLE PortHandle)
476 FIXME("(%p),stub!\n",PortHandle);
480 /******************************************************************************
481 * NtRequestWaitReplyPort [NTDLL.@]
482 * ZwRequestWaitReplyPort [NTDLL.@]
484 NTSTATUS WINAPI NtRequestWaitReplyPort(
486 PLPC_MESSAGE pLpcMessageIn,
487 PLPC_MESSAGE pLpcMessageOut)
489 FIXME("(%p,%p,%p),stub!\n",PortHandle,pLpcMessageIn,pLpcMessageOut);
492 TRACE("Message to send:\n");
493 TRACE("\tDataSize = %u\n",pLpcMessageIn->DataSize);
494 TRACE("\tMessageSize = %u\n",pLpcMessageIn->MessageSize);
495 TRACE("\tMessageType = %u\n",pLpcMessageIn->MessageType);
496 TRACE("\tVirtualRangesOffset = %u\n",pLpcMessageIn->VirtualRangesOffset);
497 TRACE("\tClientId.UniqueProcess = %p\n",pLpcMessageIn->ClientId.UniqueProcess);
498 TRACE("\tClientId.UniqueThread = %p\n",pLpcMessageIn->ClientId.UniqueThread);
499 TRACE("\tMessageId = %lu\n",pLpcMessageIn->MessageId);
500 TRACE("\tSectionSize = %lu\n",pLpcMessageIn->SectionSize);
501 TRACE("\tData = %s\n",
502 debugstr_an((const char*)pLpcMessageIn->Data,pLpcMessageIn->DataSize));
507 /******************************************************************************
508 * NtReplyWaitReceivePort [NTDLL.@]
509 * ZwReplyWaitReceivePort [NTDLL.@]
511 NTSTATUS WINAPI NtReplyWaitReceivePort(
513 PULONG PortIdentifier,
514 PLPC_MESSAGE ReplyMessage,
515 PLPC_MESSAGE Message)
517 FIXME("(%p,%p,%p,%p),stub!\n",PortHandle,PortIdentifier,ReplyMessage,Message);
525 /******************************************************************************
526 * NtSetIntervalProfile [NTDLL.@]
527 * ZwSetIntervalProfile [NTDLL.@]
529 NTSTATUS WINAPI NtSetIntervalProfile(
531 KPROFILE_SOURCE Source)
533 FIXME("%lu,%d\n", Interval, Source);
534 return STATUS_SUCCESS;
537 /******************************************************************************
538 * NtQuerySystemInformation [NTDLL.@]
539 * ZwQuerySystemInformation [NTDLL.@]
542 * SystemInformationClass Index to a certain information structure
543 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
544 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
545 * SystemConfigurationInformation CONFIGURATION_INFORMATION
546 * observed (class/len):
552 * SystemInformation caller supplies storage for the information structure
553 * Length size of the structure
554 * ResultLength Data written
556 NTSTATUS WINAPI NtQuerySystemInformation(
557 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
558 OUT PVOID SystemInformation,
560 OUT PULONG ResultLength)
562 NTSTATUS ret = STATUS_SUCCESS;
565 TRACE("(0x%08x,%p,0x%08lx,%p)\n",
566 SystemInformationClass,SystemInformation,Length,ResultLength);
568 switch (SystemInformationClass)
570 case SystemBasicInformation:
572 SYSTEM_BASIC_INFORMATION sbi;
575 sbi.uKeMaximumIncrement = 0;
576 sbi.uPageSize = 1024; /* FIXME */
577 sbi.uMmNumberOfPhysicalPages = 12345; /* FIXME */
578 sbi.uMmLowestPhysicalPage = 0; /* FIXME */
579 sbi.uMmHighestPhysicalPage = 12345; /* FIXME */
580 sbi.uAllocationGranularity = 65536; /* FIXME */
581 sbi.pLowestUserAddress = 0; /* FIXME */
582 sbi.pMmHighestUserAddress = (void*)~0; /* FIXME */
583 sbi.uKeActiveProcessors = 1; /* FIXME */
584 sbi.bKeNumberProcessors = 1; /* FIXME */
589 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
590 else memcpy( SystemInformation, &sbi, len);
592 else ret = STATUS_INFO_LENGTH_MISMATCH;
595 case SystemCpuInformation:
597 SYSTEM_CPU_INFORMATION sci;
599 /* FIXME: move some code from kernel/cpu.c to process this */
600 sci.Architecture = PROCESSOR_ARCHITECTURE_INTEL;
601 sci.Level = 6; /* 686, aka Pentium II+ */
604 sci.FeatureSet = 0x1fff;
609 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
610 else memcpy( SystemInformation, &sci, len);
612 else ret = STATUS_INFO_LENGTH_MISMATCH;
615 case SystemPerformanceInformation:
617 SYSTEM_PERFORMANCE_INFORMATION spi;
619 memset(&spi, 0 , sizeof(spi));
624 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
625 else memcpy( SystemInformation, &spi, len);
627 else ret = STATUS_INFO_LENGTH_MISMATCH;
630 case SystemTimeOfDayInformation:
632 SYSTEM_TIMEOFDAY_INFORMATION sti;
634 memset(&sti, 0 , sizeof(sti));
636 /* liKeSystemTime, liExpTimeZoneBias, uCurrentTimeZoneId */
637 RtlSecondsSince1970ToTime( server_start_time, &sti.liKeBootTime );
639 if (Length <= sizeof(sti))
642 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
643 else memcpy( SystemInformation, &sti, Length);
645 else ret = STATUS_INFO_LENGTH_MISMATCH;
648 case SystemProcessInformation:
650 SYSTEM_PROCESS_INFORMATION* spi = (SYSTEM_PROCESS_INFORMATION*)SystemInformation;
651 SYSTEM_PROCESS_INFORMATION* last = NULL;
653 WCHAR procname[1024];
656 DWORD procstructlen = 0;
658 SERVER_START_REQ( create_snapshot )
660 req->flags = SNAP_PROCESS | SNAP_THREAD;
663 if (!(ret = wine_server_call( req ))) hSnap = reply->handle;
667 while (ret == STATUS_SUCCESS)
669 SERVER_START_REQ( next_process )
672 req->reset = (len == 0);
673 wine_server_set_reply( req, procname, sizeof(procname)-sizeof(WCHAR) );
674 if (!(ret = wine_server_call( req )))
676 /* Make sure procname is 0 terminated */
677 procname[wine_server_reply_size(reply) / sizeof(WCHAR)] = 0;
679 /* Get only the executable name, not the path */
680 if ((exename = strrchrW(procname, '\\')) != NULL) exename++;
681 else exename = procname;
683 wlen = (strlenW(exename) + 1) * sizeof(WCHAR);
685 procstructlen = sizeof(*spi) + wlen + ((reply->threads - 1) * sizeof(SYSTEM_THREAD_INFORMATION));
687 if (Length >= len + procstructlen)
689 /* ftCreationTime, ftUserTime, ftKernelTime;
690 * vmCounters, ioCounters
693 memset(spi, 0, sizeof(*spi));
695 spi->dwOffset = procstructlen - wlen;
696 spi->dwThreadCount = reply->threads;
698 /* spi->pszProcessName will be set later on */
700 spi->dwBasePriority = reply->priority;
701 spi->dwProcessID = (DWORD)reply->pid;
702 spi->dwParentProcessID = (DWORD)reply->ppid;
703 spi->dwHandleCount = reply->handles;
705 /* spi->ti will be set later on */
707 len += procstructlen;
709 else ret = STATUS_INFO_LENGTH_MISMATCH;
714 if (ret != STATUS_SUCCESS)
716 if (ret == STATUS_NO_MORE_FILES) ret = STATUS_SUCCESS;
719 else /* Length is already checked for */
723 /* set thread info */
725 while (ret == STATUS_SUCCESS)
727 SERVER_START_REQ( next_thread )
730 req->reset = (j == 0);
731 if (!(ret = wine_server_call( req )))
734 if (reply->pid == spi->dwProcessID)
736 /* ftKernelTime, ftUserTime, ftCreateTime;
737 * dwTickCount, dwStartAddress
740 memset(&spi->ti[i], 0, sizeof(spi->ti));
742 spi->ti[i].dwOwningPID = reply->pid;
743 spi->ti[i].dwThreadID = reply->tid;
744 spi->ti[i].dwCurrentPriority = reply->base_pri + reply->delta_pri;
745 spi->ti[i].dwBasePriority = reply->base_pri;
752 if (ret == STATUS_NO_MORE_FILES) ret = STATUS_SUCCESS;
754 /* now append process name */
755 spi->ProcessName.Buffer = (WCHAR*)((char*)spi + spi->dwOffset);
756 spi->ProcessName.Length = wlen - sizeof(WCHAR);
757 spi->ProcessName.MaximumLength = wlen;
758 memcpy( spi->ProcessName.Buffer, exename, wlen );
759 spi->dwOffset += wlen;
762 spi = (SYSTEM_PROCESS_INFORMATION*)((char*)spi + spi->dwOffset);
765 if (ret == STATUS_SUCCESS && last) last->dwOffset = 0;
766 if (hSnap) NtClose(hSnap);
769 case SystemProcessorPerformanceInformation:
771 SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION sppi;
773 memset(&sppi, 0 , sizeof(sppi)); /* FIXME */
778 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
779 else memcpy( SystemInformation, &sppi, len);
781 else ret = STATUS_INFO_LENGTH_MISMATCH;
784 case SystemModuleInformation:
786 SYSTEM_MODULE_INFORMATION smi;
788 memset(&smi, 0, sizeof(smi));
793 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
794 else memcpy( SystemInformation, &smi, len);
796 else ret = STATUS_INFO_LENGTH_MISMATCH;
799 case SystemHandleInformation:
801 SYSTEM_HANDLE_INFORMATION shi;
803 memset(&shi, 0, sizeof(shi));
808 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
809 else memcpy( SystemInformation, &shi, len);
811 else ret = STATUS_INFO_LENGTH_MISMATCH;
814 case SystemCacheInformation:
816 SYSTEM_CACHE_INFORMATION sci;
818 memset(&sci, 0, sizeof(sci)); /* FIXME */
823 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
824 else memcpy( SystemInformation, &sci, len);
826 else ret = STATUS_INFO_LENGTH_MISMATCH;
829 case SystemInterruptInformation:
831 SYSTEM_INTERRUPT_INFORMATION sii;
833 memset(&sii, 0, sizeof(sii));
838 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
839 else memcpy( SystemInformation, &sii, len);
841 else ret = STATUS_INFO_LENGTH_MISMATCH;
844 case SystemKernelDebuggerInformation:
846 SYSTEM_KERNEL_DEBUGGER_INFORMATION skdi;
848 skdi.DebuggerEnabled = FALSE;
849 skdi.DebuggerNotPresent = TRUE;
854 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
855 else memcpy( SystemInformation, &skdi, len);
857 else ret = STATUS_INFO_LENGTH_MISMATCH;
860 case SystemRegistryQuotaInformation:
862 /* Something to do with the size of the registry *
863 * Since we don't have a size limitation, fake it *
864 * This is almost certainly wrong. *
865 * This sets each of the three words in the struct to 32 MB, *
866 * which is enough to make the IE 5 installer happy. */
867 SYSTEM_REGISTRY_QUOTA_INFORMATION srqi;
869 srqi.RegistryQuotaAllowed = 0x2000000;
870 srqi.RegistryQuotaUsed = 0x200000;
871 srqi.Reserved1 = (void*)0x200000;
876 if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
879 FIXME("SystemRegistryQuotaInformation: faking max registry size of 32 MB\n");
880 memcpy( SystemInformation, &srqi, len);
883 else ret = STATUS_INFO_LENGTH_MISMATCH;
887 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
888 SystemInformationClass,SystemInformation,Length,ResultLength);
890 /* Several Information Classes are not implemented on Windows and return 2 different values
891 * STATUS_NOT_IMPLEMENTED or STATUS_INVALID_INFO_CLASS
892 * in 95% of the cases it's STATUS_INVALID_INFO_CLASS, so use this as the default
894 ret = STATUS_INVALID_INFO_CLASS;
897 if (ResultLength) *ResultLength = len;
903 /******************************************************************************
904 * NtCreatePagingFile [NTDLL.@]
905 * ZwCreatePagingFile [NTDLL.@]
907 NTSTATUS WINAPI NtCreatePagingFile(
908 PUNICODE_STRING PageFileName,
909 PLARGE_INTEGER MinimumSize,
910 PLARGE_INTEGER MaximumSize,
911 PLARGE_INTEGER ActualSize)
913 FIXME("(%p %p %p %p) stub\n", PageFileName, MinimumSize, MaximumSize, ActualSize);
914 return STATUS_SUCCESS;
917 /******************************************************************************
918 * NtDisplayString [NTDLL.@]
920 * writes a string to the nt-textmode screen eg. during startup
922 NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
927 if (!(ret = RtlUnicodeStringToAnsiString( &stringA, string, TRUE )))
929 MESSAGE( "%.*s", stringA.Length, stringA.Buffer );
930 RtlFreeAnsiString( &stringA );
935 /******************************************************************************
936 * NtInitiatePowerAction [NTDLL.@]
939 NTSTATUS WINAPI NtInitiatePowerAction(
940 IN POWER_ACTION SystemAction,
941 IN SYSTEM_POWER_STATE MinSystemState,
943 IN BOOLEAN Asynchronous)
945 FIXME("(%d,%d,0x%08lx,%d),stub\n",
946 SystemAction,MinSystemState,Flags,Asynchronous);
947 return STATUS_NOT_IMPLEMENTED;
951 /******************************************************************************
952 * NtPowerInformation [NTDLL.@]
955 NTSTATUS WINAPI NtPowerInformation(
956 IN POWER_INFORMATION_LEVEL InformationLevel,
957 IN PVOID lpInputBuffer,
958 IN ULONG nInputBufferSize,
959 IN PVOID lpOutputBuffer,
960 IN ULONG nOutputBufferSize)
962 TRACE("(%d,%p,%ld,%p,%ld)\n",
963 InformationLevel,lpInputBuffer,nInputBufferSize,lpOutputBuffer,nOutputBufferSize);
964 switch(InformationLevel) {
965 case SystemPowerCapabilities: {
966 PSYSTEM_POWER_CAPABILITIES PowerCaps = (PSYSTEM_POWER_CAPABILITIES)lpOutputBuffer;
967 FIXME("semi-stub: SystemPowerCapabilities\n");
968 if (nOutputBufferSize < sizeof(SYSTEM_POWER_CAPABILITIES))
969 return STATUS_BUFFER_TOO_SMALL;
970 /* FIXME: These values are based off a native XP desktop, should probably use APM/ACPI to get the 'real' values */
971 PowerCaps->PowerButtonPresent = TRUE;
972 PowerCaps->SleepButtonPresent = FALSE;
973 PowerCaps->LidPresent = FALSE;
974 PowerCaps->SystemS1 = TRUE;
975 PowerCaps->SystemS2 = FALSE;
976 PowerCaps->SystemS3 = FALSE;
977 PowerCaps->SystemS4 = TRUE;
978 PowerCaps->SystemS5 = TRUE;
979 PowerCaps->HiberFilePresent = TRUE;
980 PowerCaps->FullWake = TRUE;
981 PowerCaps->VideoDimPresent = FALSE;
982 PowerCaps->ApmPresent = FALSE;
983 PowerCaps->UpsPresent = FALSE;
984 PowerCaps->ThermalControl = FALSE;
985 PowerCaps->ProcessorThrottle = FALSE;
986 PowerCaps->ProcessorMinThrottle = 100;
987 PowerCaps->ProcessorMaxThrottle = 100;
988 PowerCaps->DiskSpinDown = TRUE;
989 PowerCaps->SystemBatteriesPresent = FALSE;
990 PowerCaps->BatteriesAreShortTerm = FALSE;
991 PowerCaps->BatteryScale[0].Granularity = 0;
992 PowerCaps->BatteryScale[0].Capacity = 0;
993 PowerCaps->BatteryScale[1].Granularity = 0;
994 PowerCaps->BatteryScale[1].Capacity = 0;
995 PowerCaps->BatteryScale[2].Granularity = 0;
996 PowerCaps->BatteryScale[2].Capacity = 0;
997 PowerCaps->AcOnLineWake = PowerSystemUnspecified;
998 PowerCaps->SoftLidWake = PowerSystemUnspecified;
999 PowerCaps->RtcWake = PowerSystemSleeping1;
1000 PowerCaps->MinDeviceWakeState = PowerSystemUnspecified;
1001 PowerCaps->DefaultLowLatencyWake = PowerSystemUnspecified;
1002 return STATUS_SUCCESS;
1005 FIXME("Unimplemented NtPowerInformation action: %d\n", InformationLevel);
1006 return STATUS_NOT_IMPLEMENTED;
1010 /******************************************************************************
1011 * NtShutdownSystem [NTDLL.@]
1014 NTSTATUS WINAPI NtShutdownSystem(SHUTDOWN_ACTION Action)
1016 FIXME("%d\n",Action);
1017 return STATUS_SUCCESS;
1020 /******************************************************************************
1021 * NtAllocateLocallyUniqueId (NTDLL.@)
1023 * FIXME: the server should do that
1025 NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
1027 static LUID luid = { SE_MAX_WELL_KNOWN_PRIVILEGE, 0 };
1029 FIXME("%p\n", Luid);
1032 return STATUS_ACCESS_VIOLATION;
1035 if (luid.LowPart==0)
1037 Luid->HighPart = luid.HighPart;
1038 Luid->LowPart = luid.LowPart;
1040 return STATUS_SUCCESS;
1043 /******************************************************************************
1044 * VerSetConditionMask (NTDLL.@)
1046 ULONGLONG WINAPI VerSetConditionMask( ULONGLONG dwlConditionMask, DWORD dwTypeBitMask,
1047 BYTE dwConditionMask)
1049 if(dwTypeBitMask == 0)
1050 return dwlConditionMask;
1051 dwConditionMask &= 0x07;
1052 if(dwConditionMask == 0)
1053 return dwlConditionMask;
1055 if(dwTypeBitMask & VER_PRODUCT_TYPE)
1056 dwlConditionMask |= dwConditionMask << 7*3;
1057 else if (dwTypeBitMask & VER_SUITENAME)
1058 dwlConditionMask |= dwConditionMask << 6*3;
1059 else if (dwTypeBitMask & VER_SERVICEPACKMAJOR)
1060 dwlConditionMask |= dwConditionMask << 5*3;
1061 else if (dwTypeBitMask & VER_SERVICEPACKMINOR)
1062 dwlConditionMask |= dwConditionMask << 4*3;
1063 else if (dwTypeBitMask & VER_PLATFORMID)
1064 dwlConditionMask |= dwConditionMask << 3*3;
1065 else if (dwTypeBitMask & VER_BUILDNUMBER)
1066 dwlConditionMask |= dwConditionMask << 2*3;
1067 else if (dwTypeBitMask & VER_MAJORVERSION)
1068 dwlConditionMask |= dwConditionMask << 1*3;
1069 else if (dwTypeBitMask & VER_MINORVERSION)
1070 dwlConditionMask |= dwConditionMask << 0*3;
1071 return dwlConditionMask;
1074 /******************************************************************************
1075 * NtAccessCheckAndAuditAlarm (NTDLL.@)
1076 * ZwAccessCheckAndAuditAlarm (NTDLL.@)
1078 NTSTATUS WINAPI NtAccessCheckAndAuditAlarm(PUNICODE_STRING SubsystemName, HANDLE HandleId, PUNICODE_STRING ObjectTypeName,
1079 PUNICODE_STRING ObjectName, PSECURITY_DESCRIPTOR SecurityDescriptor,
1080 ACCESS_MASK DesiredAccess, PGENERIC_MAPPING GenericMapping, BOOLEAN ObjectCreation,
1081 PACCESS_MASK GrantedAccess, PBOOLEAN AccessStatus, PBOOLEAN GenerateOnClose)
1083 FIXME("(%s, %p, %s, %p, 0x%08lx, %p, %d, %p, %p, %p), stub\n", debugstr_us(SubsystemName), HandleId,
1084 debugstr_us(ObjectTypeName), SecurityDescriptor, DesiredAccess, GenericMapping, ObjectCreation,
1085 GrantedAccess, AccessStatus, GenerateOnClose);
1087 return STATUS_NOT_IMPLEMENTED;