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 * NtQuerySystemInformation [NTDLL.@]
544 * ZwQuerySystemInformation [NTDLL.@]
547 * SystemInformationClass Index to a certain information structure
548 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
549 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
550 * SystemConfigurationInformation CONFIGURATION_INFORMATION
551 * observed (class/len):
557 * SystemInformation caller supplies storage for the information structure
558 * Length size of the structure
559 * ResultLength Data written
561 NTSTATUS WINAPI
NtQuerySystemInformation(
562 IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
563 OUT PVOID SystemInformation
,
565 OUT PULONG ResultLength
)
567 NTSTATUS ret
= STATUS_SUCCESS
;
570 TRACE("(0x%08x,%p,0x%08lx,%p)\n",
571 SystemInformationClass
,SystemInformation
,Length
,ResultLength
);
573 switch (SystemInformationClass
)
575 case SystemBasicInformation
:
577 SYSTEM_BASIC_INFORMATION sbi
;
580 sbi
.uKeMaximumIncrement
= 0;
581 sbi
.uPageSize
= 1024; /* FIXME */
582 sbi
.uMmNumberOfPhysicalPages
= 12345; /* FIXME */
583 sbi
.uMmLowestPhysicalPage
= 0; /* FIXME */
584 sbi
.uMmHighestPhysicalPage
= 12345; /* FIXME */
585 sbi
.uAllocationGranularity
= 65536; /* FIXME */
586 sbi
.pLowestUserAddress
= 0; /* FIXME */
587 sbi
.pMmHighestUserAddress
= (void*)~0; /* FIXME */
588 sbi
.uKeActiveProcessors
= 1; /* FIXME */
589 sbi
.bKeNumberProcessors
= 1; /* FIXME */
594 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
595 else memcpy( SystemInformation
, &sbi
, len
);
597 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
600 case SystemCpuInformation
:
602 SYSTEM_CPU_INFORMATION
* sci
;
603 sci
= (SYSTEM_CPU_INFORMATION
*) SystemInformation
;
604 if (Length
>= sizeof(*sci
))
606 /* FIXME: move some code from kernel/cpu.c to process this */
607 sci
->Architecture
= PROCESSOR_ARCHITECTURE_INTEL
;
608 sci
->Level
= 6; /* 686, aka Pentium II+ */
611 sci
->FeatureSet
= 0x1fff;
613 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
616 case SystemPerformanceInformation
:
618 SYSTEM_PERFORMANCE_INFORMATION
* spi
= (SYSTEM_PERFORMANCE_INFORMATION
*)SystemInformation
;
619 if (Length
>= sizeof(*spi
))
621 memset(spi
, 0, sizeof(*spi
)); /* FIXME */
624 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
627 case SystemTimeOfDayInformation
:
629 SYSTEM_TIMEOFDAY_INFORMATION
* sti
= (SYSTEM_TIMEOFDAY_INFORMATION
*)SystemInformation
;
630 if (Length
>= sizeof(*sti
))
632 sti
->liKeBootTime
.QuadPart
= boottime
;
633 sti
->liKeSystemTime
.QuadPart
= 0; /* FIXME */
634 sti
->liExpTimeZoneBias
.QuadPart
= 0; /* FIXME */
635 sti
->uCurrentTimeZoneId
= 0; /* FIXME */
639 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
642 case SystemProcessInformation
:
644 SYSTEM_PROCESS_INFORMATION
* spi
= (SYSTEM_PROCESS_INFORMATION
*)SystemInformation
;
645 SYSTEM_PROCESS_INFORMATION
* last
= NULL
;
647 WCHAR procname
[1024];
650 SERVER_START_REQ( create_snapshot
)
652 req
->flags
= SNAP_PROCESS
| SNAP_THREAD
;
653 req
->inherit
= FALSE
;
655 if (!(ret
= wine_server_call( req
))) hSnap
= reply
->handle
;
659 while (ret
== STATUS_SUCCESS
)
661 SERVER_START_REQ( next_process
)
664 req
->reset
= (len
== 0);
665 wine_server_set_reply( req
, procname
, sizeof(procname
) );
666 if (!(ret
= wine_server_call( req
)))
668 wlen
= wine_server_reply_size(reply
) + sizeof(WCHAR
);
669 if (Length
>= len
+ sizeof(*spi
))
671 memset(spi
, 0, sizeof(*spi
));
672 spi
->dwOffset
= sizeof(*spi
);
673 spi
->dwThreadCount
= reply
->threads
;
674 memset(&spi
->ftCreationTime
, 0, sizeof(spi
->ftCreationTime
));
675 /* spi->pszProcessName will be set later on */
676 spi
->dwBasePriority
= reply
->priority
;
677 spi
->dwProcessID
= (DWORD
)reply
->pid
;
678 spi
->dwParentProcessID
= (DWORD
)reply
->ppid
;
679 spi
->dwHandleCount
= reply
->handles
;
680 spi
->dwVirtualBytesPeak
= 0; /* FIXME */
681 spi
->dwVirtualBytes
= 0; /* FIXME */
682 spi
->dwPageFaults
= 0; /* FIXME */
683 spi
->dwWorkingSetPeak
= 0; /* FIXME */
684 spi
->dwWorkingSet
= 0; /* FIXME */
685 spi
->dwUnknown5
= 0; /* FIXME */
686 spi
->dwPagedPool
= 0; /* FIXME */
687 spi
->dwUnknown6
= 0; /* FIXME */
688 spi
->dwNonPagedPool
= 0; /* FIXME */
689 spi
->dwPageFileBytesPeak
= 0; /* FIXME */
690 spi
->dwPrivateBytes
= 0; /* FIXME */
691 spi
->dwPageFileBytes
= 0; /* FIXME */
692 /* spi->ti will be set later on */
693 len
+= sizeof(*spi
) - sizeof(spi
->ti
);
695 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
699 if (ret
!= STATUS_SUCCESS
)
701 if (ret
== STATUS_NO_MORE_FILES
) ret
= STATUS_SUCCESS
;
704 if (Length
>= len
+ wlen
+ spi
->dwThreadCount
* sizeof(THREAD_INFO
))
708 /* set thread info */
709 spi
->dwOffset
+= spi
->dwThreadCount
* sizeof(THREAD_INFO
);
710 len
+= spi
->dwThreadCount
* sizeof(THREAD_INFO
);
712 while (ret
== STATUS_SUCCESS
)
714 SERVER_START_REQ( next_thread
)
717 req
->reset
= (j
== 0);
718 if (!(ret
= wine_server_call( req
)))
721 if (reply
->pid
== spi
->dwProcessID
)
723 /* ftKernelTime, ftUserTime, ftCreateTime;
724 * dwTickCount, dwStartAddress
726 spi
->ti
[i
].dwOwningPID
= reply
->pid
;
727 spi
->ti
[i
].dwThreadID
= reply
->tid
;
728 spi
->ti
[i
].dwCurrentPriority
= reply
->base_pri
+ reply
->delta_pri
;
729 spi
->ti
[i
].dwBasePriority
= reply
->base_pri
;
736 if (ret
== STATUS_NO_MORE_FILES
) ret
= STATUS_SUCCESS
;
738 /* now append process name */
739 spi
->pszProcessName
= (WCHAR
*)((char*)spi
+ spi
->dwOffset
);
740 memcpy( spi
->pszProcessName
, procname
, wlen
- sizeof(WCHAR
) );
741 spi
->pszProcessName
[wlen
/ sizeof(WCHAR
)] = 0;
743 spi
->dwOffset
+= wlen
;
746 spi
= (SYSTEM_PROCESS_INFORMATION
*)((char*)spi
+ spi
->dwOffset
);
748 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
750 if (ret
== STATUS_SUCCESS
&& last
) last
->dwOffset
= 0;
751 if (hSnap
) NtClose(hSnap
);
754 case SystemProcessorPerformanceInformation
:
756 SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
* sppi
= (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
*)SystemInformation
;
757 if (Length
>= sizeof(*sppi
))
759 memset(sppi
, 0, sizeof(*sppi
)); /* FIXME */
762 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
766 case SystemCacheInformation
:
768 SYSTEM_CACHE_INFORMATION
* sci
= (SYSTEM_CACHE_INFORMATION
*)SystemInformation
;
769 if (Length
>= sizeof(*sci
))
771 memset(sci
, 0, sizeof(*sci
)); /* FIXME */
774 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
777 case SystemRegistryQuotaInformation
:
778 /* Something to do with the size of the registry *
779 * Since we don't have a size limitation, fake it *
780 * This is almost certainly wrong. *
781 * This sets each of the three words in the struct to 32 MB, *
782 * which is enough to make the IE 5 installer happy. */
784 SYSTEM_REGISTRY_QUOTA_INFORMATION
* srqi
= (SYSTEM_REGISTRY_QUOTA_INFORMATION
*)SystemInformation
;
785 if (Length
>= sizeof(*srqi
))
787 FIXME("(0x%08x,%p,0x%08lx,%p) faking max registry size of 32 MB\n",
788 SystemInformationClass
,SystemInformation
,Length
,ResultLength
);
789 srqi
->RegistryQuotaAllowed
= 0x2000000;
790 srqi
->RegistryQuotaUsed
= 0x200000;
791 srqi
->Reserved1
= (void*)0x200000;
794 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
798 case SystemKernelDebuggerInformation
:
800 PSYSTEM_KERNEL_DEBUGGER_INFORMATION pkdi
;
801 if( Length
>= sizeof(*pkdi
))
803 pkdi
= SystemInformation
;
804 pkdi
->DebuggerEnabled
= FALSE
;
805 pkdi
->DebuggerNotPresent
= TRUE
;
808 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
813 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
814 SystemInformationClass
,SystemInformation
,Length
,ResultLength
);
816 /* Several Information Classes are not implemented on Windows and return 2 different values
817 * STATUS_NOT_IMPLEMENTED or STATUS_INVALID_INFO_CLASS
818 * in 95% of the cases it's STATUS_INVALID_INFO_CLASS, so use this as the default
820 ret
= STATUS_INVALID_INFO_CLASS
;
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 * NtInitiatePowerAction [NTDLL.@]
866 NTSTATUS WINAPI
NtInitiatePowerAction(
867 IN POWER_ACTION SystemAction
,
868 IN SYSTEM_POWER_STATE MinSystemState
,
870 IN BOOLEAN Asynchronous
)
872 FIXME("(%d,%d,0x%08lx,%d),stub\n",
873 SystemAction
,MinSystemState
,Flags
,Asynchronous
);
874 return STATUS_NOT_IMPLEMENTED
;
878 /******************************************************************************
879 * NtPowerInformation [NTDLL.@]
882 NTSTATUS WINAPI
NtPowerInformation(
883 IN POWER_INFORMATION_LEVEL InformationLevel
,
884 IN PVOID lpInputBuffer
,
885 IN ULONG nInputBufferSize
,
886 IN PVOID lpOutputBuffer
,
887 IN ULONG nOutputBufferSize
)
889 TRACE("(%d,%p,%ld,%p,%ld)\n",
890 InformationLevel
,lpInputBuffer
,nInputBufferSize
,lpOutputBuffer
,nOutputBufferSize
);
891 switch(InformationLevel
) {
892 case SystemPowerCapabilities
: {
893 PSYSTEM_POWER_CAPABILITIES PowerCaps
= (PSYSTEM_POWER_CAPABILITIES
)lpOutputBuffer
;
894 FIXME("semi-stub: SystemPowerCapabilities\n");
895 if (nOutputBufferSize
< sizeof(SYSTEM_POWER_CAPABILITIES
))
896 return STATUS_BUFFER_TOO_SMALL
;
897 /* FIXME: These values are based off a native XP desktop, should probably use APM/ACPI to get the 'real' values */
898 PowerCaps
->PowerButtonPresent
= TRUE
;
899 PowerCaps
->SleepButtonPresent
= FALSE
;
900 PowerCaps
->LidPresent
= FALSE
;
901 PowerCaps
->SystemS1
= TRUE
;
902 PowerCaps
->SystemS2
= FALSE
;
903 PowerCaps
->SystemS3
= FALSE
;
904 PowerCaps
->SystemS4
= TRUE
;
905 PowerCaps
->SystemS5
= TRUE
;
906 PowerCaps
->HiberFilePresent
= TRUE
;
907 PowerCaps
->FullWake
= TRUE
;
908 PowerCaps
->VideoDimPresent
= FALSE
;
909 PowerCaps
->ApmPresent
= FALSE
;
910 PowerCaps
->UpsPresent
= FALSE
;
911 PowerCaps
->ThermalControl
= FALSE
;
912 PowerCaps
->ProcessorThrottle
= FALSE
;
913 PowerCaps
->ProcessorMinThrottle
= 100;
914 PowerCaps
->ProcessorMaxThrottle
= 100;
915 PowerCaps
->DiskSpinDown
= TRUE
;
916 PowerCaps
->SystemBatteriesPresent
= FALSE
;
917 PowerCaps
->BatteriesAreShortTerm
= FALSE
;
918 PowerCaps
->BatteryScale
[0].Granularity
= 0;
919 PowerCaps
->BatteryScale
[0].Capacity
= 0;
920 PowerCaps
->BatteryScale
[1].Granularity
= 0;
921 PowerCaps
->BatteryScale
[1].Capacity
= 0;
922 PowerCaps
->BatteryScale
[2].Granularity
= 0;
923 PowerCaps
->BatteryScale
[2].Capacity
= 0;
924 PowerCaps
->AcOnLineWake
= PowerSystemUnspecified
;
925 PowerCaps
->SoftLidWake
= PowerSystemUnspecified
;
926 PowerCaps
->RtcWake
= PowerSystemSleeping1
;
927 PowerCaps
->MinDeviceWakeState
= PowerSystemUnspecified
;
928 PowerCaps
->DefaultLowLatencyWake
= PowerSystemUnspecified
;
929 return STATUS_SUCCESS
;
932 FIXME("Unimplemented NtPowerInformation action: %d\n", InformationLevel
);
933 return STATUS_NOT_IMPLEMENTED
;
937 /******************************************************************************
938 * NtShutdownSystem [NTDLL.@]
941 NTSTATUS WINAPI
NtShutdownSystem(DWORD x1
)
943 FIXME("(0x%08lx),stub\n",x1
);
947 /******************************************************************************
948 * NtAllocateLocallyUniqueId (NTDLL.@)
950 * FIXME: the server should do that
952 NTSTATUS WINAPI
NtAllocateLocallyUniqueId(PLUID Luid
)
954 static LUID luid
= { SE_MAX_WELL_KNOWN_PRIVILEGE
, 0 };
959 return STATUS_ACCESS_VIOLATION
;
964 Luid
->HighPart
= luid
.HighPart
;
965 Luid
->LowPart
= luid
.LowPart
;
967 return STATUS_SUCCESS
;
970 /******************************************************************************
971 * VerSetConditionMask (NTDLL.@)
973 ULONGLONG WINAPI
VerSetConditionMask( ULONGLONG dwlConditionMask
, DWORD dwTypeBitMask
,
974 BYTE dwConditionMask
)
976 if(dwTypeBitMask
== 0)
977 return dwlConditionMask
;
978 dwConditionMask
&= 0x07;
979 if(dwConditionMask
== 0)
980 return dwlConditionMask
;
982 if(dwTypeBitMask
& VER_PRODUCT_TYPE
)
983 dwlConditionMask
|= dwConditionMask
<< 7*3;
984 else if (dwTypeBitMask
& VER_SUITENAME
)
985 dwlConditionMask
|= dwConditionMask
<< 6*3;
986 else if (dwTypeBitMask
& VER_SERVICEPACKMAJOR
)
987 dwlConditionMask
|= dwConditionMask
<< 5*3;
988 else if (dwTypeBitMask
& VER_SERVICEPACKMINOR
)
989 dwlConditionMask
|= dwConditionMask
<< 4*3;
990 else if (dwTypeBitMask
& VER_PLATFORMID
)
991 dwlConditionMask
|= dwConditionMask
<< 3*3;
992 else if (dwTypeBitMask
& VER_BUILDNUMBER
)
993 dwlConditionMask
|= dwConditionMask
<< 2*3;
994 else if (dwTypeBitMask
& VER_MAJORVERSION
)
995 dwlConditionMask
|= dwConditionMask
<< 1*3;
996 else if (dwTypeBitMask
& VER_MINORVERSION
)
997 dwlConditionMask
|= dwConditionMask
<< 0*3;
998 return dwlConditionMask
;
1001 /******************************************************************************
1002 * NtAlertThread (NTDLL.@)
1004 NTSTATUS WINAPI
NtAlertThread(HANDLE ThreadHandle
)
1006 FIXME("%p\n", ThreadHandle
);
1007 return STATUS_NOT_IMPLEMENTED
;