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
29 #include "wine/debug.h"
35 #include "ntdll_misc.h"
36 #include "wine/server.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
40 /* FIXME: fixed at 2005/2/22 */
41 static LONGLONG boottime = (LONGLONG)1275356510 * 100000000;
43 /* Structures used by NtConnectPort */
45 typedef struct LpcSectionInfo
51 DWORD ClientBaseAddress;
52 DWORD ServerBaseAddress;
53 } LPCSECTIONINFO, *PLPCSECTIONINFO;
55 typedef struct LpcSectionMapInfo
59 DWORD ServerBaseAddress;
60 } LPCSECTIONMAPINFO, *PLPCSECTIONMAPINFO;
62 /* Structure used by NtAcceptConnectPort, NtReplyWaitReceivePort */
64 #define MAX_MESSAGE_DATA 328
66 typedef struct LpcMessage
68 WORD ActualMessageLength;
69 WORD TotalMessageLength;
71 DWORD ClientProcessId;
74 DWORD SharedSectionSize;
75 BYTE MessageData[MAX_MESSAGE_DATA];
76 } LPCMESSAGE, *PLPCMESSAGE;
82 /******************************************************************************
83 * NtDuplicateToken [NTDLL.@]
84 * ZwDuplicateToken [NTDLL.@]
86 NTSTATUS WINAPI NtDuplicateToken(
87 IN HANDLE ExistingToken,
88 IN ACCESS_MASK DesiredAccess,
89 IN POBJECT_ATTRIBUTES ObjectAttributes,
90 IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
91 IN TOKEN_TYPE TokenType,
96 TRACE("(%p,0x%08lx,%p,0x%08x,0x%08x,%p)\n",
97 ExistingToken, DesiredAccess, ObjectAttributes,
98 ImpersonationLevel, TokenType, NewToken);
99 dump_ObjectAttributes(ObjectAttributes);
101 SERVER_START_REQ( duplicate_token )
103 req->handle = ExistingToken;
104 req->access = DesiredAccess;
105 req->inherit = ObjectAttributes && (ObjectAttributes->Attributes & OBJ_INHERIT);
106 req->primary = (TokenType == TokenPrimary);
107 req->impersonation_level = ImpersonationLevel;
108 status = wine_server_call( req );
109 if (!status) *NewToken = reply->new_handle;
116 /******************************************************************************
117 * NtOpenProcessToken [NTDLL.@]
118 * ZwOpenProcessToken [NTDLL.@]
120 NTSTATUS WINAPI NtOpenProcessToken(
121 HANDLE ProcessHandle,
127 TRACE("(%p,0x%08lx,%p)\n", ProcessHandle,DesiredAccess, TokenHandle);
129 SERVER_START_REQ( open_token )
131 req->handle = ProcessHandle;
133 ret = wine_server_call( req );
134 if (!ret) *TokenHandle = reply->token;
141 /******************************************************************************
142 * NtOpenThreadToken [NTDLL.@]
143 * ZwOpenThreadToken [NTDLL.@]
145 NTSTATUS WINAPI NtOpenThreadToken(
153 TRACE("(%p,0x%08lx,0x%08x,%p)\n",
154 ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);
156 SERVER_START_REQ( open_token )
158 req->handle = ThreadHandle;
159 req->flags = OPEN_TOKEN_THREAD;
160 if (OpenAsSelf) req->flags |= OPEN_TOKEN_AS_SELF;
161 ret = wine_server_call( req );
162 if (!ret) *TokenHandle = reply->token;
169 /******************************************************************************
170 * NtAdjustPrivilegesToken [NTDLL.@]
171 * ZwAdjustPrivilegesToken [NTDLL.@]
173 * FIXME: parameters unsafe
175 NTSTATUS WINAPI NtAdjustPrivilegesToken(
176 IN HANDLE TokenHandle,
177 IN BOOLEAN DisableAllPrivileges,
178 IN PTOKEN_PRIVILEGES NewState,
179 IN DWORD BufferLength,
180 OUT PTOKEN_PRIVILEGES PreviousState,
181 OUT PDWORD ReturnLength)
185 TRACE("(%p,0x%08x,%p,0x%08lx,%p,%p)\n",
186 TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength);
188 SERVER_START_REQ( adjust_token_privileges )
190 req->handle = TokenHandle;
191 req->disable_all = DisableAllPrivileges;
192 req->get_modified_state = (PreviousState != NULL);
193 if (!DisableAllPrivileges)
195 wine_server_add_data( req, &NewState->Privileges,
196 NewState->PrivilegeCount * sizeof(NewState->Privileges[0]) );
198 if (PreviousState && BufferLength >= FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ))
199 wine_server_set_reply( req, &PreviousState->Privileges,
200 BufferLength - FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) );
201 ret = wine_server_call( req );
204 *ReturnLength = reply->len + FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges );
205 PreviousState->PrivilegeCount = reply->len / sizeof(LUID_AND_ATTRIBUTES);
213 /******************************************************************************
214 * NtQueryInformationToken [NTDLL.@]
215 * ZwQueryInformationToken [NTDLL.@]
218 * Buffer for TokenUser:
219 * 0x00 TOKEN_USER the PSID field points to the SID
223 NTSTATUS WINAPI NtQueryInformationToken(
225 DWORD tokeninfoclass,
227 DWORD tokeninfolength,
230 unsigned int len = 0;
231 NTSTATUS status = STATUS_SUCCESS;
233 TRACE("(%p,%ld,%p,%ld,%p)\n",
234 token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);
236 switch (tokeninfoclass)
239 len = sizeof(TOKEN_USER) + sizeof(SID);
242 len = sizeof(TOKEN_GROUPS);
245 len = sizeof(TOKEN_OWNER) + sizeof(SID);
247 case TokenPrimaryGroup:
248 len = sizeof(TOKEN_PRIMARY_GROUP);
250 case TokenDefaultDacl:
251 len = sizeof(TOKEN_DEFAULT_DACL);
254 len = sizeof(TOKEN_SOURCE);
257 len = sizeof (TOKEN_TYPE);
260 case TokenImpersonationLevel:
261 case TokenStatistics:
265 /* FIXME: what if retlen == NULL ? */
268 if (tokeninfolength < len)
269 return STATUS_BUFFER_TOO_SMALL;
271 switch (tokeninfoclass)
276 TOKEN_USER * tuser = tokeninfo;
277 PSID sid = (PSID) (tuser + 1);
278 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
279 RtlInitializeSid(sid, &localSidAuthority, 1);
280 *(RtlSubAuthoritySid(sid, 0)) = SECURITY_INTERACTIVE_RID;
281 tuser->User.Sid = sid;
287 TOKEN_GROUPS *tgroups = tokeninfo;
288 SID_IDENTIFIER_AUTHORITY sid = {SECURITY_NT_AUTHORITY};
290 /* we need to show admin privileges ! */
291 tgroups->GroupCount = 1;
292 tgroups->Groups->Attributes = SE_GROUP_ENABLED;
293 RtlAllocateAndInitializeSid( &sid,
295 SECURITY_BUILTIN_DOMAIN_RID,
296 DOMAIN_ALIAS_RID_ADMINS,
298 &(tgroups->Groups->Sid));
301 case TokenPrimaryGroup:
304 TOKEN_PRIMARY_GROUP *tgroup = tokeninfo;
305 SID_IDENTIFIER_AUTHORITY sid = {SECURITY_NT_AUTHORITY};
306 RtlAllocateAndInitializeSid( &sid,
308 SECURITY_BUILTIN_DOMAIN_RID,
309 DOMAIN_ALIAS_RID_ADMINS,
311 &(tgroup->PrimaryGroup));
314 case TokenPrivileges:
315 SERVER_START_REQ( get_token_privileges )
317 TOKEN_PRIVILEGES *tpriv = tokeninfo;
319 if (tpriv && tokeninfolength > FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ))
320 wine_server_set_reply( req, &tpriv->Privileges, tokeninfolength - FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) );
321 status = wine_server_call( req );
322 *retlen = FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) + reply->len;
323 if (tpriv) tpriv->PrivilegeCount = reply->len / sizeof(LUID_AND_ATTRIBUTES);
330 TOKEN_OWNER *owner = tokeninfo;
331 PSID sid = (PSID) (owner + 1);
332 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
333 RtlInitializeSid(sid, &localSidAuthority, 1);
334 *(RtlSubAuthoritySid(sid, 0)) = SECURITY_INTERACTIVE_RID;
340 ERR("Unhandled Token Information class %ld!\n", tokeninfoclass);
341 return STATUS_NOT_IMPLEMENTED;
347 /******************************************************************************
348 * NtSetInformationToken [NTDLL.@]
349 * ZwSetInformationToken [NTDLL.@]
351 NTSTATUS WINAPI NtSetInformationToken(
353 TOKEN_INFORMATION_CLASS TokenInformationClass,
354 PVOID TokenInformation,
355 ULONG TokenInformationLength)
357 FIXME("%p %d %p %lu\n", TokenHandle, TokenInformationClass,
358 TokenInformation, TokenInformationLength);
359 return STATUS_NOT_IMPLEMENTED;
362 /******************************************************************************
363 * NtAdjustGroupsToken [NTDLL.@]
364 * ZwAdjustGroupsToken [NTDLL.@]
366 NTSTATUS WINAPI NtAdjustGroupsToken(
368 BOOLEAN ResetToDefault,
369 PTOKEN_GROUPS NewState,
371 PTOKEN_GROUPS PreviousState,
374 FIXME("%p %d %p %lu %p %p\n", TokenHandle, ResetToDefault,
375 NewState, BufferLength, PreviousState, ReturnLength);
376 return STATUS_NOT_IMPLEMENTED;
383 /******************************************************************************
384 * NtQuerySection [NTDLL.@]
386 NTSTATUS WINAPI NtQuerySection(
387 IN HANDLE SectionHandle,
388 IN PVOID SectionInformationClass,
389 OUT PVOID SectionInformation,
391 OUT PULONG ResultLength)
393 FIXME("(%p,%p,%p,0x%08lx,%p) stub!\n",
394 SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
402 /******************************************************************************
403 * NtCreatePort [NTDLL.@]
404 * ZwCreatePort [NTDLL.@]
406 NTSTATUS WINAPI NtCreatePort(PHANDLE PortHandle,POBJECT_ATTRIBUTES ObjectAttributes,
407 DWORD MaxConnectInfoLength,DWORD MaxDataLength,DWORD unknown)
409 FIXME("(%p,%p,0x%08lx,0x%08lx,0x%08lx),stub!\n",PortHandle,ObjectAttributes,
410 MaxConnectInfoLength,MaxDataLength,unknown);
414 /******************************************************************************
415 * NtConnectPort [NTDLL.@]
416 * ZwConnectPort [NTDLL.@]
418 NTSTATUS WINAPI NtConnectPort(PHANDLE PortHandle,PUNICODE_STRING PortName,PVOID Unknown1,
419 PLPCSECTIONINFO sectionInfo,PLPCSECTIONMAPINFO mapInfo,PVOID Unknown2,
420 PVOID ConnectInfo,PDWORD pConnectInfoLength)
422 FIXME("(%p,%s,%p,%p,%p,%p,%p,%p (%ld)),stub!\n",PortHandle,debugstr_w(PortName->Buffer),Unknown1,
423 sectionInfo,mapInfo,Unknown2,ConnectInfo,pConnectInfoLength,pConnectInfoLength?*pConnectInfoLength:-1);
424 if(ConnectInfo && pConnectInfoLength)
425 TRACE("\tMessage = %s\n",debugstr_an(ConnectInfo,*pConnectInfoLength));
429 /******************************************************************************
430 * NtListenPort [NTDLL.@]
431 * ZwListenPort [NTDLL.@]
433 NTSTATUS WINAPI NtListenPort(HANDLE PortHandle,PLPCMESSAGE pLpcMessage)
435 FIXME("(%p,%p),stub!\n",PortHandle,pLpcMessage);
439 /******************************************************************************
440 * NtAcceptConnectPort [NTDLL.@]
441 * ZwAcceptConnectPort [NTDLL.@]
443 NTSTATUS WINAPI NtAcceptConnectPort(PHANDLE PortHandle,DWORD Unknown,PLPCMESSAGE pLpcMessage,
444 DWORD acceptIt,DWORD Unknown2,PLPCSECTIONMAPINFO mapInfo)
446 FIXME("(%p,0x%08lx,%p,0x%08lx,0x%08lx,%p),stub!\n",PortHandle,Unknown,pLpcMessage,acceptIt,Unknown2,mapInfo);
450 /******************************************************************************
451 * NtCompleteConnectPort [NTDLL.@]
452 * ZwCompleteConnectPort [NTDLL.@]
454 NTSTATUS WINAPI NtCompleteConnectPort(HANDLE PortHandle)
456 FIXME("(%p),stub!\n",PortHandle);
460 /******************************************************************************
461 * NtRegisterThreadTerminatePort [NTDLL.@]
462 * ZwRegisterThreadTerminatePort [NTDLL.@]
464 NTSTATUS WINAPI NtRegisterThreadTerminatePort(HANDLE PortHandle)
466 FIXME("(%p),stub!\n",PortHandle);
470 /******************************************************************************
471 * NtRequestWaitReplyPort [NTDLL.@]
472 * ZwRequestWaitReplyPort [NTDLL.@]
474 NTSTATUS WINAPI NtRequestWaitReplyPort(HANDLE PortHandle,PLPCMESSAGE pLpcMessageIn,PLPCMESSAGE pLpcMessageOut)
476 FIXME("(%p,%p,%p),stub!\n",PortHandle,pLpcMessageIn,pLpcMessageOut);
479 TRACE("Message to send:\n");
480 TRACE("\tActualMessageLength = %d\n",pLpcMessageIn->ActualMessageLength);
481 TRACE("\tTotalMessageLength = %d\n",pLpcMessageIn->TotalMessageLength);
482 TRACE("\tMessageType = %ld\n",pLpcMessageIn->MessageType);
483 TRACE("\tClientProcessId = %ld\n",pLpcMessageIn->ClientProcessId);
484 TRACE("\tClientThreadId = %ld\n",pLpcMessageIn->ClientThreadId);
485 TRACE("\tMessageId = %ld\n",pLpcMessageIn->MessageId);
486 TRACE("\tSharedSectionSize = %ld\n",pLpcMessageIn->SharedSectionSize);
487 TRACE("\tMessageData = %s\n",debugstr_an(pLpcMessageIn->MessageData,pLpcMessageIn->ActualMessageLength));
492 /******************************************************************************
493 * NtReplyWaitReceivePort [NTDLL.@]
494 * ZwReplyWaitReceivePort [NTDLL.@]
496 NTSTATUS WINAPI NtReplyWaitReceivePort(HANDLE PortHandle,PDWORD Unknown,PLPCMESSAGE pLpcMessageOut,PLPCMESSAGE pLpcMessageIn)
498 FIXME("(%p,%p,%p,%p),stub!\n",PortHandle,Unknown,pLpcMessageOut,pLpcMessageIn);
506 /******************************************************************************
507 * NtSetIntervalProfile [NTDLL.@]
508 * ZwSetIntervalProfile [NTDLL.@]
510 NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,DWORD x2) {
511 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
515 /******************************************************************************
516 * NtQueryPerformanceCounter [NTDLL.@]
518 * Note: Windows uses a timer clocked at a multiple of 1193182 Hz. There is a
519 * good number of applications that crash when the returned frequency is either
520 * lower or higher then what Windows gives. Also too high counter values are
521 * reported to give problems.
523 NTSTATUS WINAPI NtQueryPerformanceCounter(
524 OUT PLARGE_INTEGER Counter,
525 OUT PLARGE_INTEGER Frequency)
529 if (!Counter) return STATUS_ACCESS_VIOLATION;
530 NtQuerySystemTime( &time );
531 time.QuadPart -= boottime;
532 /* convert a counter that increments at a rate of 10 MHz
533 * to one of 1193182 Hz, with some care for arithmetic
534 * overflow ( will not overflow until 3396 or so ) and
535 * good accuracy ( 21/176 = 0.119318182) */
536 Counter->QuadPart = (time.QuadPart * 21) / 176;
538 Frequency->QuadPart = 1193182;
542 /******************************************************************************
543 * NtCreateMailslotFile [NTDLL.@]
544 * ZwCreateMailslotFile [NTDLL.@]
546 NTSTATUS WINAPI NtCreateMailslotFile(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
548 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4,x5,x6,x7,x8);
552 /******************************************************************************
553 * NtQuerySystemInformation [NTDLL.@]
554 * ZwQuerySystemInformation [NTDLL.@]
557 * SystemInformationClass Index to a certain information structure
558 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
559 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
560 * SystemConfigurationInformation CONFIGURATION_INFORMATION
561 * observed (class/len):
567 * SystemInformation caller supplies storage for the information structure
568 * Length size of the structure
569 * ResultLength Data written
571 NTSTATUS WINAPI NtQuerySystemInformation(
572 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
573 OUT PVOID SystemInformation,
575 OUT PULONG ResultLength)
577 NTSTATUS ret = STATUS_SUCCESS;
580 TRACE("(0x%08x,%p,0x%08lx,%p)\n",
581 SystemInformationClass,SystemInformation,Length,ResultLength);
583 switch (SystemInformationClass)
585 case SystemBasicInformation:
587 SYSTEM_BASIC_INFORMATION* sbi = (SYSTEM_BASIC_INFORMATION*)SystemInformation;
588 if (Length >= sizeof(*sbi))
591 sbi->uKeMaximumIncrement = 0;
592 sbi->uPageSize = 1024; /* FIXME */
593 sbi->uMmNumberOfPhysicalPages = 12345; /* FIXME */
594 sbi->uMmLowestPhysicalPage = 0; /* FIXME */
595 sbi->uMmHighestPhysicalPage = 12345; /* FIXME */
596 sbi->uAllocationGranularity = 65536; /* FIXME */
597 sbi->pLowestUserAddress = 0; /* FIXME */
598 sbi->pMmHighestUserAddress = (void*)~0; /* FIXME */
599 sbi->uKeActiveProcessors = 1; /* FIXME */
600 sbi->bKeNumberProcessors = 1; /* FIXME */
603 else ret = STATUS_INFO_LENGTH_MISMATCH;
606 case SystemCpuInformation:
608 SYSTEM_CPU_INFORMATION* sci;
609 sci = (SYSTEM_CPU_INFORMATION *) SystemInformation;
610 if (Length >= sizeof(*sci))
612 /* FIXME: move some code from kernel/cpu.c to process this */
613 sci->Architecture = PROCESSOR_ARCHITECTURE_INTEL;
614 sci->Level = 6; /* 686, aka Pentium II+ */
617 sci->FeatureSet = 0x1fff;
619 else ret = STATUS_INFO_LENGTH_MISMATCH;
622 case SystemPerformanceInformation:
624 SYSTEM_PERFORMANCE_INFORMATION* spi = (SYSTEM_PERFORMANCE_INFORMATION*)SystemInformation;
625 if (Length >= sizeof(*spi))
627 memset(spi, 0, sizeof(*spi)); /* FIXME */
630 else ret = STATUS_INFO_LENGTH_MISMATCH;
633 case SystemTimeOfDayInformation:
635 SYSTEM_TIMEOFDAY_INFORMATION* sti = (SYSTEM_TIMEOFDAY_INFORMATION*)SystemInformation;
636 if (Length >= sizeof(*sti))
638 sti->liKeBootTime.QuadPart = boottime;
639 sti->liKeSystemTime.QuadPart = 0; /* FIXME */
640 sti->liExpTimeZoneBias.QuadPart = 0; /* FIXME */
641 sti->uCurrentTimeZoneId = 0; /* FIXME */
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 SERVER_START_REQ( create_snapshot )
658 req->flags = SNAP_PROCESS | SNAP_THREAD;
659 req->inherit = FALSE;
661 if (!(ret = wine_server_call( req ))) hSnap = reply->handle;
665 while (ret == STATUS_SUCCESS)
667 SERVER_START_REQ( next_process )
670 req->reset = (len == 0);
671 wine_server_set_reply( req, procname, sizeof(procname) );
672 if (!(ret = wine_server_call( req )))
674 wlen = wine_server_reply_size(reply) + sizeof(WCHAR);
675 if (Length >= len + sizeof(*spi))
677 memset(spi, 0, sizeof(*spi));
678 spi->dwOffset = sizeof(*spi);
679 spi->dwThreadCount = reply->threads;
680 memset(&spi->ftCreationTime, 0, sizeof(spi->ftCreationTime));
681 /* spi->pszProcessName will be set later on */
682 spi->dwBasePriority = reply->priority;
683 spi->dwProcessID = (DWORD)reply->pid;
684 spi->dwParentProcessID = (DWORD)reply->ppid;
685 spi->dwHandleCount = reply->handles;
686 spi->dwVirtualBytesPeak = 0; /* FIXME */
687 spi->dwVirtualBytes = 0; /* FIXME */
688 spi->dwPageFaults = 0; /* FIXME */
689 spi->dwWorkingSetPeak = 0; /* FIXME */
690 spi->dwWorkingSet = 0; /* FIXME */
691 spi->dwUnknown5 = 0; /* FIXME */
692 spi->dwPagedPool = 0; /* FIXME */
693 spi->dwUnknown6 = 0; /* FIXME */
694 spi->dwNonPagedPool = 0; /* FIXME */
695 spi->dwPageFileBytesPeak = 0; /* FIXME */
696 spi->dwPrivateBytes = 0; /* FIXME */
697 spi->dwPageFileBytes = 0; /* FIXME */
698 /* spi->ti will be set later on */
699 len += sizeof(*spi) - sizeof(spi->ti);
701 else ret = STATUS_INFO_LENGTH_MISMATCH;
705 if (ret != STATUS_SUCCESS)
707 if (ret == STATUS_NO_MORE_FILES) ret = STATUS_SUCCESS;
710 if (Length >= len + wlen + spi->dwThreadCount * sizeof(THREAD_INFO))
714 /* set thread info */
715 spi->dwOffset += spi->dwThreadCount * sizeof(THREAD_INFO);
716 len += spi->dwThreadCount * sizeof(THREAD_INFO);
718 while (ret == STATUS_SUCCESS)
720 SERVER_START_REQ( next_thread )
723 req->reset = (j == 0);
724 if (!(ret = wine_server_call( req )))
727 if (reply->pid == spi->dwProcessID)
729 /* ftKernelTime, ftUserTime, ftCreateTime;
730 * dwTickCount, dwStartAddress
732 spi->ti[i].dwOwningPID = reply->pid;
733 spi->ti[i].dwThreadID = reply->tid;
734 spi->ti[i].dwCurrentPriority = reply->base_pri + reply->delta_pri;
735 spi->ti[i].dwBasePriority = reply->base_pri;
742 if (ret == STATUS_NO_MORE_FILES) ret = STATUS_SUCCESS;
744 /* now append process name */
745 spi->pszProcessName = (WCHAR*)((char*)spi + spi->dwOffset);
746 memcpy( spi->pszProcessName, procname, wlen - sizeof(WCHAR) );
747 spi->pszProcessName[wlen / sizeof(WCHAR)] = 0;
749 spi->dwOffset += wlen;
752 spi = (SYSTEM_PROCESS_INFORMATION*)((char*)spi + spi->dwOffset);
754 else ret = STATUS_INFO_LENGTH_MISMATCH;
756 if (ret == STATUS_SUCCESS && last) last->dwOffset = 0;
757 if (hSnap) NtClose(hSnap);
760 case SystemProcessorPerformanceInformation:
762 SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* sppi = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*)SystemInformation;
763 if (Length >= sizeof(*sppi))
765 memset(sppi, 0, sizeof(*sppi)); /* FIXME */
768 else ret = STATUS_INFO_LENGTH_MISMATCH;
772 case SystemCacheInformation:
774 SYSTEM_CACHE_INFORMATION* sci = (SYSTEM_CACHE_INFORMATION*)SystemInformation;
775 if (Length >= sizeof(*sci))
777 memset(sci, 0, sizeof(*sci)); /* FIXME */
780 else ret = STATUS_INFO_LENGTH_MISMATCH;
783 case SystemRegistryQuotaInformation:
784 /* Something to do with the size of the registry *
785 * Since we don't have a size limitation, fake it *
786 * This is almost certainly wrong. *
787 * This sets each of the three words in the struct to 32 MB, *
788 * which is enough to make the IE 5 installer happy. */
790 SYSTEM_REGISTRY_QUOTA_INFORMATION* srqi = (SYSTEM_REGISTRY_QUOTA_INFORMATION*)SystemInformation;
791 if (Length >= sizeof(*srqi))
793 FIXME("(0x%08x,%p,0x%08lx,%p) faking max registry size of 32 MB\n",
794 SystemInformationClass,SystemInformation,Length,ResultLength);
795 srqi->RegistryQuotaAllowed = 0x2000000;
796 srqi->RegistryQuotaUsed = 0x200000;
797 srqi->Reserved1 = (void*)0x200000;
800 else ret = STATUS_INFO_LENGTH_MISMATCH;
804 case SystemKernelDebuggerInformation:
806 PSYSTEM_KERNEL_DEBUGGER_INFORMATION pkdi;
807 if( Length >= sizeof(*pkdi))
809 pkdi = SystemInformation;
810 pkdi->DebuggerEnabled = FALSE;
811 pkdi->DebuggerNotPresent = TRUE;
814 else ret = STATUS_INFO_LENGTH_MISMATCH;
819 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
820 SystemInformationClass,SystemInformation,Length,ResultLength);
821 ret = STATUS_NOT_IMPLEMENTED;
823 if (ResultLength) *ResultLength = len;
829 /******************************************************************************
830 * NtCreatePagingFile [NTDLL.@]
831 * ZwCreatePagingFile [NTDLL.@]
833 NTSTATUS WINAPI NtCreatePagingFile(
834 IN PUNICODE_STRING PageFileName,
837 OUT PULONG ActualSize)
839 FIXME("(%p(%s),0x%08lx,0x%08lx,%p),stub!\n",
840 PageFileName->Buffer, debugstr_w(PageFileName->Buffer),MiniumSize,MaxiumSize,ActualSize);
844 /******************************************************************************
845 * NtDisplayString [NTDLL.@]
847 * writes a string to the nt-textmode screen eg. during startup
849 NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
854 if (!(ret = RtlUnicodeStringToAnsiString( &stringA, string, TRUE )))
856 MESSAGE( "%.*s", stringA.Length, stringA.Buffer );
857 RtlFreeAnsiString( &stringA );
862 /******************************************************************************
863 * NtPowerInformation [NTDLL.@]
866 NTSTATUS WINAPI NtPowerInformation(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5)
868 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub\n",x1,x2,x3,x4,x5);
872 /******************************************************************************
873 * NtShutdownSystem [NTDLL.@]
876 NTSTATUS WINAPI NtShutdownSystem(DWORD x1)
878 FIXME("(0x%08lx),stub\n",x1);
882 /******************************************************************************
883 * NtAllocateLocallyUniqueId (NTDLL.@)
885 * FIXME: the server should do that
887 NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
889 static LUID luid = { SE_MAX_WELL_KNOWN_PRIVILEGE, 0 };
894 return STATUS_ACCESS_VIOLATION;
899 Luid->HighPart = luid.HighPart;
900 Luid->LowPart = luid.LowPart;
902 return STATUS_SUCCESS;
905 /******************************************************************************
906 * VerSetConditionMask (NTDLL.@)
908 ULONGLONG WINAPI VerSetConditionMask( ULONGLONG dwlConditionMask, DWORD dwTypeBitMask,
909 BYTE dwConditionMask)
911 if(dwTypeBitMask == 0)
912 return dwlConditionMask;
913 dwConditionMask &= 0x07;
914 if(dwConditionMask == 0)
915 return dwlConditionMask;
917 if(dwTypeBitMask & VER_PRODUCT_TYPE)
918 dwlConditionMask |= dwConditionMask << 7*3;
919 else if (dwTypeBitMask & VER_SUITENAME)
920 dwlConditionMask |= dwConditionMask << 6*3;
921 else if (dwTypeBitMask & VER_SERVICEPACKMAJOR)
922 dwlConditionMask |= dwConditionMask << 5*3;
923 else if (dwTypeBitMask & VER_SERVICEPACKMINOR)
924 dwlConditionMask |= dwConditionMask << 4*3;
925 else if (dwTypeBitMask & VER_PLATFORMID)
926 dwlConditionMask |= dwConditionMask << 3*3;
927 else if (dwTypeBitMask & VER_BUILDNUMBER)
928 dwlConditionMask |= dwConditionMask << 2*3;
929 else if (dwTypeBitMask & VER_MAJORVERSION)
930 dwlConditionMask |= dwConditionMask << 1*3;
931 else if (dwTypeBitMask & VER_MINORVERSION)
932 dwlConditionMask |= dwConditionMask << 0*3;
933 return dwlConditionMask;
936 /******************************************************************************
937 * NtAlertThread (NTDLL.@)
939 NTSTATUS WINAPI NtAlertThread(HANDLE ThreadHandle)
941 FIXME("%p\n", ThreadHandle);
942 return STATUS_NOT_IMPLEMENTED;