Get rid of the rdtsc cpu instruction method for calculation of the
[wine/multimedia.git] / dlls / ntdll / nt.c
blob0e0b488c6afed575d5e438c3247af9c1a592dd1c
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <time.h>
29 #include "wine/debug.h"
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winreg.h"
34 #include "winternl.h"
35 #include "ntdll_misc.h"
36 #include "wine/server.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
40 /* Structures used by NtConnectPort */
42 typedef struct LpcSectionInfo
44 DWORD Length;
45 HANDLE SectionHandle;
46 DWORD Param1;
47 DWORD SectionSize;
48 DWORD ClientBaseAddress;
49 DWORD ServerBaseAddress;
50 } LPCSECTIONINFO, *PLPCSECTIONINFO;
52 typedef struct LpcSectionMapInfo
54 DWORD Length;
55 DWORD SectionSize;
56 DWORD ServerBaseAddress;
57 } LPCSECTIONMAPINFO, *PLPCSECTIONMAPINFO;
59 /* Structure used by NtAcceptConnectPort, NtReplyWaitReceivePort */
61 #define MAX_MESSAGE_DATA 328
63 typedef struct LpcMessage
65 WORD ActualMessageLength;
66 WORD TotalMessageLength;
67 DWORD MessageType;
68 DWORD ClientProcessId;
69 DWORD ClientThreadId;
70 DWORD MessageId;
71 DWORD SharedSectionSize;
72 BYTE MessageData[MAX_MESSAGE_DATA];
73 } LPCMESSAGE, *PLPCMESSAGE;
76 * Token
79 /******************************************************************************
80 * NtDuplicateToken [NTDLL.@]
81 * ZwDuplicateToken [NTDLL.@]
83 NTSTATUS WINAPI NtDuplicateToken(
84 IN HANDLE ExistingToken,
85 IN ACCESS_MASK DesiredAccess,
86 IN POBJECT_ATTRIBUTES ObjectAttributes,
87 IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
88 IN TOKEN_TYPE TokenType,
89 OUT PHANDLE NewToken)
91 FIXME("(%p,0x%08lx,%p,0x%08x,0x%08x,%p),stub!\n",
92 ExistingToken, DesiredAccess, ObjectAttributes,
93 ImpersonationLevel, TokenType, NewToken);
94 dump_ObjectAttributes(ObjectAttributes);
95 return 0;
98 /******************************************************************************
99 * NtOpenProcessToken [NTDLL.@]
100 * ZwOpenProcessToken [NTDLL.@]
102 NTSTATUS WINAPI NtOpenProcessToken(
103 HANDLE ProcessHandle,
104 DWORD DesiredAccess,
105 HANDLE *TokenHandle)
107 NTSTATUS ret;
109 TRACE("(%p,0x%08lx,%p)\n", ProcessHandle,DesiredAccess, TokenHandle);
111 SERVER_START_REQ( open_token )
113 req->handle = ProcessHandle;
114 req->flags = 0;
115 ret = wine_server_call( req );
116 if (!ret) *TokenHandle = reply->token;
118 SERVER_END_REQ;
120 return ret;
123 /******************************************************************************
124 * NtOpenThreadToken [NTDLL.@]
125 * ZwOpenThreadToken [NTDLL.@]
127 NTSTATUS WINAPI NtOpenThreadToken(
128 HANDLE ThreadHandle,
129 DWORD DesiredAccess,
130 BOOLEAN OpenAsSelf,
131 HANDLE *TokenHandle)
133 NTSTATUS ret;
135 TRACE("(%p,0x%08lx,0x%08x,%p)\n",
136 ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);
138 SERVER_START_REQ( open_token )
140 req->handle = ThreadHandle;
141 req->flags = OPEN_TOKEN_THREAD;
142 if (OpenAsSelf) req->flags |= OPEN_TOKEN_AS_SELF;
143 ret = wine_server_call( req );
144 if (!ret) *TokenHandle = reply->token;
146 SERVER_END_REQ;
148 return ret;
151 /******************************************************************************
152 * NtAdjustPrivilegesToken [NTDLL.@]
153 * ZwAdjustPrivilegesToken [NTDLL.@]
155 * FIXME: parameters unsafe
157 NTSTATUS WINAPI NtAdjustPrivilegesToken(
158 IN HANDLE TokenHandle,
159 IN BOOLEAN DisableAllPrivileges,
160 IN PTOKEN_PRIVILEGES NewState,
161 IN DWORD BufferLength,
162 OUT PTOKEN_PRIVILEGES PreviousState,
163 OUT PDWORD ReturnLength)
165 FIXME("(%p,0x%08x,%p,0x%08lx,%p,%p),stub!\n",
166 TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength);
167 return 0;
170 /******************************************************************************
171 * NtQueryInformationToken [NTDLL.@]
172 * ZwQueryInformationToken [NTDLL.@]
174 * NOTES
175 * Buffer for TokenUser:
176 * 0x00 TOKEN_USER the PSID field points to the SID
177 * 0x08 SID
180 NTSTATUS WINAPI NtQueryInformationToken(
181 HANDLE token,
182 DWORD tokeninfoclass,
183 LPVOID tokeninfo,
184 DWORD tokeninfolength,
185 LPDWORD retlen )
187 unsigned int len = 0;
189 TRACE("(%p,%ld,%p,%ld,%p)\n",
190 token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);
192 switch (tokeninfoclass)
194 case TokenUser:
195 len = sizeof(TOKEN_USER) + sizeof(SID);
196 break;
197 case TokenGroups:
198 len = sizeof(TOKEN_GROUPS);
199 break;
200 case TokenPrivileges:
201 len = sizeof(TOKEN_PRIVILEGES);
202 break;
203 case TokenOwner:
204 len = sizeof(TOKEN_OWNER) + sizeof(SID);
205 break;
206 case TokenPrimaryGroup:
207 len = sizeof(TOKEN_PRIMARY_GROUP);
208 break;
209 case TokenDefaultDacl:
210 len = sizeof(TOKEN_DEFAULT_DACL);
211 break;
212 case TokenSource:
213 len = sizeof(TOKEN_SOURCE);
214 break;
215 case TokenType:
216 len = sizeof (TOKEN_TYPE);
217 break;
218 #if 0
219 case TokenImpersonationLevel:
220 case TokenStatistics:
221 #endif /* 0 */
224 /* FIXME: what if retlen == NULL ? */
225 *retlen = len;
227 if (tokeninfolength < len)
228 return STATUS_BUFFER_TOO_SMALL;
230 switch (tokeninfoclass)
232 case TokenUser:
233 if( tokeninfo )
235 TOKEN_USER * tuser = tokeninfo;
236 PSID sid = (PSID) (tuser + 1);
237 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
238 RtlInitializeSid(sid, &localSidAuthority, 1);
239 *(RtlSubAuthoritySid(sid, 0)) = SECURITY_INTERACTIVE_RID;
240 tuser->User.Sid = sid;
242 break;
243 case TokenGroups:
244 if (tokeninfo)
246 TOKEN_GROUPS *tgroups = tokeninfo;
247 SID_IDENTIFIER_AUTHORITY sid = {SECURITY_NT_AUTHORITY};
249 /* we need to show admin privileges ! */
250 tgroups->GroupCount = 1;
251 tgroups->Groups->Attributes = SE_GROUP_ENABLED;
252 RtlAllocateAndInitializeSid( &sid,
254 SECURITY_BUILTIN_DOMAIN_RID,
255 DOMAIN_ALIAS_RID_ADMINS,
256 0, 0, 0, 0, 0, 0,
257 &(tgroups->Groups->Sid));
259 break;
260 case TokenPrimaryGroup:
261 if (tokeninfo)
263 TOKEN_PRIMARY_GROUP *tgroup = tokeninfo;
264 SID_IDENTIFIER_AUTHORITY sid = {SECURITY_NT_AUTHORITY};
265 RtlAllocateAndInitializeSid( &sid,
267 SECURITY_BUILTIN_DOMAIN_RID,
268 DOMAIN_ALIAS_RID_ADMINS,
269 0, 0, 0, 0, 0, 0,
270 &(tgroup->PrimaryGroup));
272 break;
273 case TokenPrivileges:
274 if (tokeninfo)
276 TOKEN_PRIVILEGES *tpriv = tokeninfo;
277 tpriv->PrivilegeCount = 1;
279 break;
280 case TokenOwner:
281 if (tokeninfo)
283 TOKEN_OWNER *owner = tokeninfo;
284 PSID sid = (PSID) (owner + 1);
285 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
286 RtlInitializeSid(sid, &localSidAuthority, 1);
287 *(RtlSubAuthoritySid(sid, 0)) = SECURITY_INTERACTIVE_RID;
288 owner->Owner = sid;
290 break;
291 default:
293 ERR("Unhandled Token Information class %ld!\n", tokeninfoclass);
294 return STATUS_NOT_IMPLEMENTED;
297 return 0;
300 /******************************************************************************
301 * NtSetInformationToken [NTDLL.@]
302 * ZwSetInformationToken [NTDLL.@]
304 NTSTATUS WINAPI NtSetInformationToken(
305 HANDLE TokenHandle,
306 TOKEN_INFORMATION_CLASS TokenInformationClass,
307 PVOID TokenInformation,
308 ULONG TokenInformationLength)
310 FIXME("%p %d %p %lu\n", TokenHandle, TokenInformationClass,
311 TokenInformation, TokenInformationLength);
312 return STATUS_NOT_IMPLEMENTED;
315 /******************************************************************************
316 * NtAdjustGroupsToken [NTDLL.@]
317 * ZwAdjustGroupsToken [NTDLL.@]
319 NTSTATUS WINAPI NtAdjustGroupsToken(
320 HANDLE TokenHandle,
321 BOOLEAN ResetToDefault,
322 PTOKEN_GROUPS NewState,
323 ULONG BufferLength,
324 PTOKEN_GROUPS PreviousState,
325 PULONG ReturnLength)
327 FIXME("%p %d %p %lu %p %p\n", TokenHandle, ResetToDefault,
328 NewState, BufferLength, PreviousState, ReturnLength);
329 return STATUS_NOT_IMPLEMENTED;
333 * Section
336 /******************************************************************************
337 * NtQuerySection [NTDLL.@]
339 NTSTATUS WINAPI NtQuerySection(
340 IN HANDLE SectionHandle,
341 IN PVOID SectionInformationClass,
342 OUT PVOID SectionInformation,
343 IN ULONG Length,
344 OUT PULONG ResultLength)
346 FIXME("(%p,%p,%p,0x%08lx,%p) stub!\n",
347 SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
348 return 0;
352 * ports
355 /******************************************************************************
356 * NtCreatePort [NTDLL.@]
357 * ZwCreatePort [NTDLL.@]
359 NTSTATUS WINAPI NtCreatePort(PHANDLE PortHandle,POBJECT_ATTRIBUTES ObjectAttributes,
360 DWORD MaxConnectInfoLength,DWORD MaxDataLength,DWORD unknown)
362 FIXME("(%p,%p,0x%08lx,0x%08lx,0x%08lx),stub!\n",PortHandle,ObjectAttributes,
363 MaxConnectInfoLength,MaxDataLength,unknown);
364 return 0;
367 /******************************************************************************
368 * NtConnectPort [NTDLL.@]
369 * ZwConnectPort [NTDLL.@]
371 NTSTATUS WINAPI NtConnectPort(PHANDLE PortHandle,PUNICODE_STRING PortName,PVOID Unknown1,
372 PLPCSECTIONINFO sectionInfo,PLPCSECTIONMAPINFO mapInfo,PVOID Unknown2,
373 PVOID ConnectInfo,PDWORD pConnectInfoLength)
375 FIXME("(%p,%s,%p,%p,%p,%p,%p,%p (%ld)),stub!\n",PortHandle,debugstr_w(PortName->Buffer),Unknown1,
376 sectionInfo,mapInfo,Unknown2,ConnectInfo,pConnectInfoLength,pConnectInfoLength?*pConnectInfoLength:-1);
377 if(ConnectInfo && pConnectInfoLength)
378 TRACE("\tMessage = %s\n",debugstr_an(ConnectInfo,*pConnectInfoLength));
379 return 0;
382 /******************************************************************************
383 * NtListenPort [NTDLL.@]
384 * ZwListenPort [NTDLL.@]
386 NTSTATUS WINAPI NtListenPort(HANDLE PortHandle,PLPCMESSAGE pLpcMessage)
388 FIXME("(%p,%p),stub!\n",PortHandle,pLpcMessage);
389 return 0;
392 /******************************************************************************
393 * NtAcceptConnectPort [NTDLL.@]
394 * ZwAcceptConnectPort [NTDLL.@]
396 NTSTATUS WINAPI NtAcceptConnectPort(PHANDLE PortHandle,DWORD Unknown,PLPCMESSAGE pLpcMessage,
397 DWORD acceptIt,DWORD Unknown2,PLPCSECTIONMAPINFO mapInfo)
399 FIXME("(%p,0x%08lx,%p,0x%08lx,0x%08lx,%p),stub!\n",PortHandle,Unknown,pLpcMessage,acceptIt,Unknown2,mapInfo);
400 return 0;
403 /******************************************************************************
404 * NtCompleteConnectPort [NTDLL.@]
405 * ZwCompleteConnectPort [NTDLL.@]
407 NTSTATUS WINAPI NtCompleteConnectPort(HANDLE PortHandle)
409 FIXME("(%p),stub!\n",PortHandle);
410 return 0;
413 /******************************************************************************
414 * NtRegisterThreadTerminatePort [NTDLL.@]
415 * ZwRegisterThreadTerminatePort [NTDLL.@]
417 NTSTATUS WINAPI NtRegisterThreadTerminatePort(HANDLE PortHandle)
419 FIXME("(%p),stub!\n",PortHandle);
420 return 0;
423 /******************************************************************************
424 * NtRequestWaitReplyPort [NTDLL.@]
425 * ZwRequestWaitReplyPort [NTDLL.@]
427 NTSTATUS WINAPI NtRequestWaitReplyPort(HANDLE PortHandle,PLPCMESSAGE pLpcMessageIn,PLPCMESSAGE pLpcMessageOut)
429 FIXME("(%p,%p,%p),stub!\n",PortHandle,pLpcMessageIn,pLpcMessageOut);
430 if(pLpcMessageIn)
432 TRACE("Message to send:\n");
433 TRACE("\tActualMessageLength = %d\n",pLpcMessageIn->ActualMessageLength);
434 TRACE("\tTotalMessageLength = %d\n",pLpcMessageIn->TotalMessageLength);
435 TRACE("\tMessageType = %ld\n",pLpcMessageIn->MessageType);
436 TRACE("\tClientProcessId = %ld\n",pLpcMessageIn->ClientProcessId);
437 TRACE("\tClientThreadId = %ld\n",pLpcMessageIn->ClientThreadId);
438 TRACE("\tMessageId = %ld\n",pLpcMessageIn->MessageId);
439 TRACE("\tSharedSectionSize = %ld\n",pLpcMessageIn->SharedSectionSize);
440 TRACE("\tMessageData = %s\n",debugstr_an(pLpcMessageIn->MessageData,pLpcMessageIn->ActualMessageLength));
442 return 0;
445 /******************************************************************************
446 * NtReplyWaitReceivePort [NTDLL.@]
447 * ZwReplyWaitReceivePort [NTDLL.@]
449 NTSTATUS WINAPI NtReplyWaitReceivePort(HANDLE PortHandle,PDWORD Unknown,PLPCMESSAGE pLpcMessageOut,PLPCMESSAGE pLpcMessageIn)
451 FIXME("(%p,%p,%p,%p),stub!\n",PortHandle,Unknown,pLpcMessageOut,pLpcMessageIn);
452 return 0;
456 * Misc
459 /******************************************************************************
460 * NtSetIntervalProfile [NTDLL.@]
461 * ZwSetIntervalProfile [NTDLL.@]
463 NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,DWORD x2) {
464 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
465 return 0;
468 /******************************************************************************
469 * NtQueryPerformanceCounter [NTDLL.@]
471 * Note: Windows uses a timer clocked at a multiple of 1193182 Hz.
474 NTSTATUS WINAPI NtQueryPerformanceCounter(
475 OUT PLARGE_INTEGER Counter,
476 OUT PLARGE_INTEGER Frequency)
478 LARGE_INTEGER time;
479 NtQuerySystemTime( &time );
480 Counter->QuadPart = time.QuadPart;
481 Frequency->QuadPart = 10000000;
482 return 0;
485 /******************************************************************************
486 * NtCreateMailslotFile [NTDLL.@]
487 * ZwCreateMailslotFile [NTDLL.@]
489 NTSTATUS WINAPI NtCreateMailslotFile(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
491 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);
492 return 0;
495 /******************************************************************************
496 * NtQuerySystemInformation [NTDLL.@]
497 * ZwQuerySystemInformation [NTDLL.@]
499 * ARGUMENTS:
500 * SystemInformationClass Index to a certain information structure
501 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
502 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
503 * SystemConfigurationInformation CONFIGURATION_INFORMATION
504 * observed (class/len):
505 * 0x0/0x2c
506 * 0x12/0x18
507 * 0x2/0x138
508 * 0x8/0x600
509 * 0x25/0xc
510 * SystemInformation caller supplies storage for the information structure
511 * Length size of the structure
512 * ResultLength Data written
514 NTSTATUS WINAPI NtQuerySystemInformation(
515 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
516 OUT PVOID SystemInformation,
517 IN ULONG Length,
518 OUT PULONG ResultLength)
520 NTSTATUS ret = STATUS_SUCCESS;
521 ULONG len = 0;
523 TRACE("(0x%08x,%p,0x%08lx,%p)\n",
524 SystemInformationClass,SystemInformation,Length,ResultLength);
526 switch (SystemInformationClass)
528 case SystemBasicInformation:
530 SYSTEM_BASIC_INFORMATION* sbi = (SYSTEM_BASIC_INFORMATION*)SystemInformation;
531 if (Length >= sizeof(*sbi))
533 sbi->dwUnknown1 = 0;
534 sbi->uKeMaximumIncrement = 0;
535 sbi->uPageSize = 1024; /* FIXME */
536 sbi->uMmNumberOfPhysicalPages = 12345; /* FIXME */
537 sbi->uMmLowestPhysicalPage = 0; /* FIXME */
538 sbi->uMmHighestPhysicalPage = 12345; /* FIXME */
539 sbi->uAllocationGranularity = 65536; /* FIXME */
540 sbi->pLowestUserAddress = 0; /* FIXME */
541 sbi->pMmHighestUserAddress = (void*)~0; /* FIXME */
542 sbi->uKeActiveProcessors = 1; /* FIXME */
543 sbi->bKeNumberProcessors = 1; /* FIXME */
544 len = sizeof(*sbi);
546 else ret = STATUS_INFO_LENGTH_MISMATCH;
548 break;
549 case SystemPerformanceInformation:
551 SYSTEM_PERFORMANCE_INFORMATION* spi = (SYSTEM_PERFORMANCE_INFORMATION*)SystemInformation;
552 if (Length >= sizeof(*spi))
554 memset(spi, 0, sizeof(*spi)); /* FIXME */
555 len = sizeof(*spi);
557 else ret = STATUS_INFO_LENGTH_MISMATCH;
559 break;
560 case SystemTimeOfDayInformation:
562 SYSTEM_TIMEOFDAY_INFORMATION* sti = (SYSTEM_TIMEOFDAY_INFORMATION*)SystemInformation;
563 if (Length >= sizeof(*sti))
565 sti->liKeBootTime.QuadPart = 0; /* FIXME */
566 sti->liKeSystemTime.QuadPart = 0; /* FIXME */
567 sti->liExpTimeZoneBias.QuadPart = 0; /* FIXME */
568 sti->uCurrentTimeZoneId = 0; /* FIXME */
569 sti->dwReserved = 0;
570 len = sizeof(*sti);
572 else ret = STATUS_INFO_LENGTH_MISMATCH;
574 break;
575 case SystemProcessInformation:
577 SYSTEM_PROCESS_INFORMATION* spi = (SYSTEM_PROCESS_INFORMATION*)SystemInformation;
578 SYSTEM_PROCESS_INFORMATION* last = NULL;
579 HANDLE hSnap = 0;
580 WCHAR procname[1024];
581 DWORD wlen = 0;
583 SERVER_START_REQ( create_snapshot )
585 req->flags = SNAP_PROCESS | SNAP_THREAD;
586 req->inherit = FALSE;
587 req->pid = 0;
588 if (!(ret = wine_server_call( req ))) hSnap = reply->handle;
590 SERVER_END_REQ;
591 len = 0;
592 while (ret == STATUS_SUCCESS)
594 SERVER_START_REQ( next_process )
596 req->handle = hSnap;
597 req->reset = (len == 0);
598 wine_server_set_reply( req, procname, sizeof(procname) );
599 if (!(ret = wine_server_call( req )))
601 wlen = wine_server_reply_size(reply) + sizeof(WCHAR);
602 if (Length >= len + sizeof(*spi))
604 memset(spi, 0, sizeof(*spi));
605 spi->dwOffset = sizeof(*spi);
606 spi->dwThreadCount = reply->threads;
607 memset(&spi->ftCreationTime, 0, sizeof(spi->ftCreationTime));
608 /* spi->pszProcessName will be set later on */
609 spi->dwBasePriority = reply->priority;
610 spi->dwProcessID = (DWORD)reply->pid;
611 spi->dwParentProcessID = (DWORD)reply->ppid;
612 spi->dwHandleCount = reply->handles;
613 spi->dwVirtualBytesPeak = 0; /* FIXME */
614 spi->dwVirtualBytes = 0; /* FIXME */
615 spi->dwPageFaults = 0; /* FIXME */
616 spi->dwWorkingSetPeak = 0; /* FIXME */
617 spi->dwWorkingSet = 0; /* FIXME */
618 spi->dwUnknown5 = 0; /* FIXME */
619 spi->dwPagedPool = 0; /* FIXME */
620 spi->dwUnknown6 = 0; /* FIXME */
621 spi->dwNonPagedPool = 0; /* FIXME */
622 spi->dwPageFileBytesPeak = 0; /* FIXME */
623 spi->dwPrivateBytes = 0; /* FIXME */
624 spi->dwPageFileBytes = 0; /* FIXME */
625 /* spi->ti will be set later on */
626 len += sizeof(*spi) - sizeof(spi->ti);
628 else ret = STATUS_INFO_LENGTH_MISMATCH;
631 SERVER_END_REQ;
632 if (ret != STATUS_SUCCESS)
634 if (ret == STATUS_NO_MORE_FILES) ret = STATUS_SUCCESS;
635 break;
637 if (Length >= len + wlen + spi->dwThreadCount * sizeof(THREAD_INFO))
639 int i, j;
641 /* set thread info */
642 spi->dwOffset += spi->dwThreadCount * sizeof(THREAD_INFO);
643 len += spi->dwThreadCount * sizeof(THREAD_INFO);
644 i = j = 0;
645 while (ret == STATUS_SUCCESS)
647 SERVER_START_REQ( next_thread )
649 req->handle = hSnap;
650 req->reset = (j == 0);
651 if (!(ret = wine_server_call( req )))
653 j++;
654 if (reply->pid == spi->dwProcessID)
656 /* ftKernelTime, ftUserTime, ftCreateTime;
657 * dwTickCount, dwStartAddress
659 spi->ti[i].dwOwningPID = reply->pid;
660 spi->ti[i].dwThreadID = reply->tid;
661 spi->ti[i].dwCurrentPriority = reply->base_pri + reply->delta_pri;
662 spi->ti[i].dwBasePriority = reply->base_pri;
663 i++;
667 SERVER_END_REQ;
669 if (ret == STATUS_NO_MORE_FILES) ret = STATUS_SUCCESS;
671 /* now append process name */
672 spi->pszProcessName = (WCHAR*)((char*)spi + spi->dwOffset);
673 memcpy( spi->pszProcessName, procname, wlen - sizeof(WCHAR) );
674 spi->pszProcessName[wlen / sizeof(WCHAR)] = 0;
675 len += wlen;
676 spi->dwOffset += wlen;
678 last = spi;
679 spi = (SYSTEM_PROCESS_INFORMATION*)((char*)spi + spi->dwOffset);
681 else ret = STATUS_INFO_LENGTH_MISMATCH;
683 if (ret == STATUS_SUCCESS && last) last->dwOffset = 0;
684 if (hSnap) NtClose(hSnap);
686 break;
687 case SystemProcessorPerformanceInformation:
689 SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* sppi = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*)SystemInformation;
690 if (Length >= sizeof(*sppi))
692 memset(sppi, 0, sizeof(*sppi)); /* FIXME */
693 len = sizeof(*sppi);
695 else ret = STATUS_INFO_LENGTH_MISMATCH;
697 break;
699 case SystemCacheInformation:
701 SYSTEM_CACHE_INFORMATION* sci = (SYSTEM_CACHE_INFORMATION*)SystemInformation;
702 if (Length >= sizeof(*sci))
704 memset(sci, 0, sizeof(*sci)); /* FIXME */
705 len = sizeof(*sci);
707 else ret = STATUS_INFO_LENGTH_MISMATCH;
709 break;
710 case SystemRegistryQuotaInformation:
711 /* Something to do with the size of the registry *
712 * Since we don't have a size limitation, fake it *
713 * This is almost certainly wrong. *
714 * This sets each of the three words in the struct to 32 MB, *
715 * which is enough to make the IE 5 installer happy. */
717 SYSTEM_REGISTRY_QUOTA_INFORMATION* srqi = (SYSTEM_REGISTRY_QUOTA_INFORMATION*)SystemInformation;
718 if (Length >= sizeof(*srqi))
720 FIXME("(0x%08x,%p,0x%08lx,%p) faking max registry size of 32 MB\n",
721 SystemInformationClass,SystemInformation,Length,ResultLength);
722 srqi->RegistryQuotaAllowed = 0x2000000;
723 srqi->RegistryQuotaUsed = 0x200000;
724 srqi->Reserved1 = (void*)0x200000;
725 len = sizeof(*srqi);
727 else ret = STATUS_INFO_LENGTH_MISMATCH;
729 break;
731 case SystemKernelDebuggerInformation:
733 PSYSTEM_KERNEL_DEBUGGER_INFORMATION pkdi;
734 if( Length >= sizeof(*pkdi))
736 pkdi = SystemInformation;
737 pkdi->DebuggerEnabled = FALSE;
738 pkdi->DebuggerNotPresent = TRUE;
739 len = sizeof(*pkdi);
741 else ret = STATUS_INFO_LENGTH_MISMATCH;
743 break;
745 default:
746 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
747 SystemInformationClass,SystemInformation,Length,ResultLength);
748 ret = STATUS_NOT_IMPLEMENTED;
750 if (ResultLength) *ResultLength = len;
752 return ret;
756 /******************************************************************************
757 * NtCreatePagingFile [NTDLL.@]
758 * ZwCreatePagingFile [NTDLL.@]
760 NTSTATUS WINAPI NtCreatePagingFile(
761 IN PUNICODE_STRING PageFileName,
762 IN ULONG MiniumSize,
763 IN ULONG MaxiumSize,
764 OUT PULONG ActualSize)
766 FIXME("(%p(%s),0x%08lx,0x%08lx,%p),stub!\n",
767 PageFileName->Buffer, debugstr_w(PageFileName->Buffer),MiniumSize,MaxiumSize,ActualSize);
768 return 0;
771 /******************************************************************************
772 * NtDisplayString [NTDLL.@]
774 * writes a string to the nt-textmode screen eg. during startup
776 NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
778 STRING stringA;
779 NTSTATUS ret;
781 if (!(ret = RtlUnicodeStringToAnsiString( &stringA, string, TRUE )))
783 MESSAGE( "%.*s", stringA.Length, stringA.Buffer );
784 RtlFreeAnsiString( &stringA );
786 return ret;
789 /******************************************************************************
790 * NtPowerInformation [NTDLL.@]
793 NTSTATUS WINAPI NtPowerInformation(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5)
795 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub\n",x1,x2,x3,x4,x5);
796 return 0;
799 /******************************************************************************
800 * NtShutdownSystem [NTDLL.@]
803 NTSTATUS WINAPI NtShutdownSystem(DWORD x1)
805 FIXME("(0x%08lx),stub\n",x1);
806 return 0;
809 /******************************************************************************
810 * NtAllocateLocallyUniqueId (NTDLL.@)
812 * FIXME: the server should do that
814 NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
816 static LUID luid = { SE_MAX_WELL_KNOWN_PRIVILEGE, 0 };
818 FIXME("%p\n", Luid);
820 if (!Luid)
821 return STATUS_ACCESS_VIOLATION;
823 luid.LowPart++;
824 if (luid.LowPart==0)
825 luid.HighPart++;
826 Luid->HighPart = luid.HighPart;
827 Luid->LowPart = luid.LowPart;
829 return STATUS_SUCCESS;
832 /******************************************************************************
833 * VerSetConditionMask (NTDLL.@)
835 ULONGLONG WINAPI VerSetConditionMask( ULONGLONG dwlConditionMask, DWORD dwTypeBitMask,
836 BYTE dwConditionMask)
838 if(dwTypeBitMask == 0)
839 return dwlConditionMask;
840 dwConditionMask &= 0x07;
841 if(dwConditionMask == 0)
842 return dwlConditionMask;
844 if(dwTypeBitMask & VER_PRODUCT_TYPE)
845 dwlConditionMask |= dwConditionMask << 7*3;
846 else if (dwTypeBitMask & VER_SUITENAME)
847 dwlConditionMask |= dwConditionMask << 6*3;
848 else if (dwTypeBitMask & VER_SERVICEPACKMAJOR)
849 dwlConditionMask |= dwConditionMask << 5*3;
850 else if (dwTypeBitMask & VER_SERVICEPACKMINOR)
851 dwlConditionMask |= dwConditionMask << 4*3;
852 else if (dwTypeBitMask & VER_PLATFORMID)
853 dwlConditionMask |= dwConditionMask << 3*3;
854 else if (dwTypeBitMask & VER_BUILDNUMBER)
855 dwlConditionMask |= dwConditionMask << 2*3;
856 else if (dwTypeBitMask & VER_MAJORVERSION)
857 dwlConditionMask |= dwConditionMask << 1*3;
858 else if (dwTypeBitMask & VER_MINORVERSION)
859 dwlConditionMask |= dwConditionMask << 0*3;
860 return dwlConditionMask;
863 /******************************************************************************
864 * NtAlertThread (NTDLL.@)
866 NTSTATUS WINAPI NtAlertThread(HANDLE ThreadHandle)
868 FIXME("%p\n", ThreadHandle);
869 return STATUS_NOT_IMPLEMENTED;