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
->attributes
= ObjectAttributes
? ObjectAttributes
->Attributes
: 0;
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
;
95 req
->access
= DesiredAccess
;
98 ret
= wine_server_call( req
);
99 if (!ret
) *TokenHandle
= reply
->token
;
106 /******************************************************************************
107 * NtOpenThreadToken [NTDLL.@]
108 * ZwOpenThreadToken [NTDLL.@]
110 NTSTATUS WINAPI
NtOpenThreadToken(
118 TRACE("(%p,0x%08lx,0x%08x,%p)\n",
119 ThreadHandle
,DesiredAccess
, OpenAsSelf
, TokenHandle
);
121 SERVER_START_REQ( open_token
)
123 req
->handle
= ThreadHandle
;
124 req
->access
= DesiredAccess
;
126 req
->flags
= OPEN_TOKEN_THREAD
;
127 if (OpenAsSelf
) req
->flags
|= OPEN_TOKEN_AS_SELF
;
128 ret
= wine_server_call( req
);
129 if (!ret
) *TokenHandle
= reply
->token
;
136 /******************************************************************************
137 * NtAdjustPrivilegesToken [NTDLL.@]
138 * ZwAdjustPrivilegesToken [NTDLL.@]
140 * FIXME: parameters unsafe
142 NTSTATUS WINAPI
NtAdjustPrivilegesToken(
143 IN HANDLE TokenHandle
,
144 IN BOOLEAN DisableAllPrivileges
,
145 IN PTOKEN_PRIVILEGES NewState
,
146 IN DWORD BufferLength
,
147 OUT PTOKEN_PRIVILEGES PreviousState
,
148 OUT PDWORD ReturnLength
)
152 TRACE("(%p,0x%08x,%p,0x%08lx,%p,%p)\n",
153 TokenHandle
, DisableAllPrivileges
, NewState
, BufferLength
, PreviousState
, ReturnLength
);
155 SERVER_START_REQ( adjust_token_privileges
)
157 req
->handle
= TokenHandle
;
158 req
->disable_all
= DisableAllPrivileges
;
159 req
->get_modified_state
= (PreviousState
!= NULL
);
160 if (!DisableAllPrivileges
)
162 wine_server_add_data( req
, &NewState
->Privileges
,
163 NewState
->PrivilegeCount
* sizeof(NewState
->Privileges
[0]) );
165 if (PreviousState
&& BufferLength
>= FIELD_OFFSET( TOKEN_PRIVILEGES
, Privileges
))
166 wine_server_set_reply( req
, &PreviousState
->Privileges
,
167 BufferLength
- FIELD_OFFSET( TOKEN_PRIVILEGES
, Privileges
) );
168 ret
= wine_server_call( req
);
171 *ReturnLength
= reply
->len
+ FIELD_OFFSET( TOKEN_PRIVILEGES
, Privileges
);
172 PreviousState
->PrivilegeCount
= reply
->len
/ sizeof(LUID_AND_ATTRIBUTES
);
180 /******************************************************************************
181 * NtQueryInformationToken [NTDLL.@]
182 * ZwQueryInformationToken [NTDLL.@]
185 * Buffer for TokenUser:
186 * 0x00 TOKEN_USER the PSID field points to the SID
190 NTSTATUS WINAPI
NtQueryInformationToken(
192 DWORD tokeninfoclass
,
194 DWORD tokeninfolength
,
197 unsigned int len
= 0;
198 NTSTATUS status
= STATUS_SUCCESS
;
200 TRACE("(%p,%ld,%p,%ld,%p)\n",
201 token
,tokeninfoclass
,tokeninfo
,tokeninfolength
,retlen
);
203 switch (tokeninfoclass
)
206 len
= sizeof(TOKEN_GROUPS
);
209 len
= sizeof(TOKEN_OWNER
) + sizeof(SID
);
211 case TokenPrimaryGroup
:
212 len
= sizeof(TOKEN_PRIMARY_GROUP
);
214 case TokenDefaultDacl
:
215 len
= sizeof(TOKEN_DEFAULT_DACL
);
218 len
= sizeof(TOKEN_SOURCE
);
221 len
= sizeof (TOKEN_TYPE
);
224 case TokenImpersonationLevel
:
225 case TokenStatistics
:
229 /* FIXME: what if retlen == NULL ? */
232 if (tokeninfolength
< len
)
233 return STATUS_BUFFER_TOO_SMALL
;
235 switch (tokeninfoclass
)
238 SERVER_START_REQ( get_token_user
)
240 TOKEN_USER
* tuser
= tokeninfo
;
241 PSID sid
= (PSID
) (tuser
+ 1);
242 DWORD sid_len
= tokeninfolength
< sizeof(TOKEN_USER
) ? 0 : tokeninfolength
- sizeof(TOKEN_USER
);
245 wine_server_set_reply( req
, sid
, sid_len
);
246 status
= wine_server_call( req
);
247 *retlen
= reply
->user_len
+ sizeof(TOKEN_USER
);
248 if (status
== STATUS_SUCCESS
)
250 tuser
->User
.Sid
= sid
;
251 tuser
->User
.Attributes
= 0;
259 TOKEN_GROUPS
*tgroups
= tokeninfo
;
260 SID_IDENTIFIER_AUTHORITY sid
= {SECURITY_NT_AUTHORITY
};
262 /* we need to show admin privileges ! */
263 tgroups
->GroupCount
= 1;
264 tgroups
->Groups
->Attributes
= SE_GROUP_ENABLED
;
265 RtlAllocateAndInitializeSid( &sid
,
267 SECURITY_BUILTIN_DOMAIN_RID
,
268 DOMAIN_ALIAS_RID_ADMINS
,
270 &(tgroups
->Groups
->Sid
));
273 case TokenPrimaryGroup
:
276 TOKEN_PRIMARY_GROUP
*tgroup
= tokeninfo
;
277 SID_IDENTIFIER_AUTHORITY sid
= {SECURITY_NT_AUTHORITY
};
278 RtlAllocateAndInitializeSid( &sid
,
280 SECURITY_BUILTIN_DOMAIN_RID
,
281 DOMAIN_ALIAS_RID_ADMINS
,
283 &(tgroup
->PrimaryGroup
));
286 case TokenPrivileges
:
287 SERVER_START_REQ( get_token_privileges
)
289 TOKEN_PRIVILEGES
*tpriv
= tokeninfo
;
291 if (tpriv
&& tokeninfolength
> FIELD_OFFSET( TOKEN_PRIVILEGES
, Privileges
))
292 wine_server_set_reply( req
, &tpriv
->Privileges
, tokeninfolength
- FIELD_OFFSET( TOKEN_PRIVILEGES
, Privileges
) );
293 status
= wine_server_call( req
);
294 *retlen
= FIELD_OFFSET( TOKEN_PRIVILEGES
, Privileges
) + reply
->len
;
295 if (tpriv
) tpriv
->PrivilegeCount
= reply
->len
/ sizeof(LUID_AND_ATTRIBUTES
);
302 TOKEN_OWNER
*owner
= tokeninfo
;
303 PSID sid
= (PSID
) (owner
+ 1);
304 SID_IDENTIFIER_AUTHORITY localSidAuthority
= {SECURITY_NT_AUTHORITY
};
305 RtlInitializeSid(sid
, &localSidAuthority
, 1);
306 *(RtlSubAuthoritySid(sid
, 0)) = SECURITY_INTERACTIVE_RID
;
312 ERR("Unhandled Token Information class %ld!\n", tokeninfoclass
);
313 return STATUS_NOT_IMPLEMENTED
;
319 /******************************************************************************
320 * NtSetInformationToken [NTDLL.@]
321 * ZwSetInformationToken [NTDLL.@]
323 NTSTATUS WINAPI
NtSetInformationToken(
325 TOKEN_INFORMATION_CLASS TokenInformationClass
,
326 PVOID TokenInformation
,
327 ULONG TokenInformationLength
)
329 FIXME("%p %d %p %lu\n", TokenHandle
, TokenInformationClass
,
330 TokenInformation
, TokenInformationLength
);
331 return STATUS_NOT_IMPLEMENTED
;
334 /******************************************************************************
335 * NtAdjustGroupsToken [NTDLL.@]
336 * ZwAdjustGroupsToken [NTDLL.@]
338 NTSTATUS WINAPI
NtAdjustGroupsToken(
340 BOOLEAN ResetToDefault
,
341 PTOKEN_GROUPS NewState
,
343 PTOKEN_GROUPS PreviousState
,
346 FIXME("%p %d %p %lu %p %p\n", TokenHandle
, ResetToDefault
,
347 NewState
, BufferLength
, PreviousState
, ReturnLength
);
348 return STATUS_NOT_IMPLEMENTED
;
351 /******************************************************************************
352 * NtPrivilegeCheck [NTDLL.@]
353 * ZwPrivilegeCheck [NTDLL.@]
355 NTSTATUS WINAPI
NtPrivilegeCheck(
357 PPRIVILEGE_SET RequiredPrivileges
,
361 SERVER_START_REQ( check_token_privileges
)
363 req
->handle
= ClientToken
;
364 req
->all_required
= ((RequiredPrivileges
->Control
& PRIVILEGE_SET_ALL_NECESSARY
) ? TRUE
: FALSE
);
365 wine_server_add_data( req
, &RequiredPrivileges
->Privilege
,
366 RequiredPrivileges
->PrivilegeCount
* sizeof(RequiredPrivileges
->Privilege
[0]) );
367 wine_server_set_reply( req
, &RequiredPrivileges
->Privilege
,
368 RequiredPrivileges
->PrivilegeCount
* sizeof(RequiredPrivileges
->Privilege
[0]) );
370 status
= wine_server_call( req
);
372 if (status
== STATUS_SUCCESS
)
373 *Result
= (reply
->has_privileges
? TRUE
: FALSE
);
383 /******************************************************************************
384 * NtQuerySection [NTDLL.@]
386 NTSTATUS WINAPI
NtQuerySection(
387 IN HANDLE SectionHandle
,
388 IN SECTION_INFORMATION_CLASS SectionInformationClass
,
389 OUT PVOID SectionInformation
,
391 OUT PULONG ResultLength
)
393 FIXME("(%p,%d,%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 ULONG MaxConnectInfoLength
,ULONG MaxDataLength
,PULONG reserved
)
409 FIXME("(%p,%p,%lu,%lu,%p),stub!\n",PortHandle
,ObjectAttributes
,
410 MaxConnectInfoLength
,MaxDataLength
,reserved
);
414 /******************************************************************************
415 * NtConnectPort [NTDLL.@]
416 * ZwConnectPort [NTDLL.@]
418 NTSTATUS WINAPI
NtConnectPort(
420 PUNICODE_STRING PortName
,
421 PSECURITY_QUALITY_OF_SERVICE SecurityQos
,
422 PLPC_SECTION_WRITE WriteSection
,
423 PLPC_SECTION_READ ReadSection
,
424 PULONG MaximumMessageLength
,
426 PULONG pConnectInfoLength
)
428 FIXME("(%p,%s,%p,%p,%p,%p,%p,%p),stub!\n",
429 PortHandle
,debugstr_w(PortName
->Buffer
),SecurityQos
,
430 WriteSection
,ReadSection
,MaximumMessageLength
,ConnectInfo
,
432 if (ConnectInfo
&& pConnectInfoLength
)
433 TRACE("\tMessage = %s\n",debugstr_an(ConnectInfo
,*pConnectInfoLength
));
437 /******************************************************************************
438 * NtListenPort [NTDLL.@]
439 * ZwListenPort [NTDLL.@]
441 NTSTATUS WINAPI
NtListenPort(HANDLE PortHandle
,PLPC_MESSAGE pLpcMessage
)
443 FIXME("(%p,%p),stub!\n",PortHandle
,pLpcMessage
);
447 /******************************************************************************
448 * NtAcceptConnectPort [NTDLL.@]
449 * ZwAcceptConnectPort [NTDLL.@]
451 NTSTATUS WINAPI
NtAcceptConnectPort(
453 ULONG PortIdentifier
,
454 PLPC_MESSAGE pLpcMessage
,
456 PLPC_SECTION_WRITE WriteSection
,
457 PLPC_SECTION_READ ReadSection
)
459 FIXME("(%p,%lu,%p,%d,%p,%p),stub!\n",
460 PortHandle
,PortIdentifier
,pLpcMessage
,Accept
,WriteSection
,ReadSection
);
464 /******************************************************************************
465 * NtCompleteConnectPort [NTDLL.@]
466 * ZwCompleteConnectPort [NTDLL.@]
468 NTSTATUS WINAPI
NtCompleteConnectPort(HANDLE PortHandle
)
470 FIXME("(%p),stub!\n",PortHandle
);
474 /******************************************************************************
475 * NtRegisterThreadTerminatePort [NTDLL.@]
476 * ZwRegisterThreadTerminatePort [NTDLL.@]
478 NTSTATUS WINAPI
NtRegisterThreadTerminatePort(HANDLE PortHandle
)
480 FIXME("(%p),stub!\n",PortHandle
);
484 /******************************************************************************
485 * NtRequestWaitReplyPort [NTDLL.@]
486 * ZwRequestWaitReplyPort [NTDLL.@]
488 NTSTATUS WINAPI
NtRequestWaitReplyPort(
490 PLPC_MESSAGE pLpcMessageIn
,
491 PLPC_MESSAGE pLpcMessageOut
)
493 FIXME("(%p,%p,%p),stub!\n",PortHandle
,pLpcMessageIn
,pLpcMessageOut
);
496 TRACE("Message to send:\n");
497 TRACE("\tDataSize = %u\n",pLpcMessageIn
->DataSize
);
498 TRACE("\tMessageSize = %u\n",pLpcMessageIn
->MessageSize
);
499 TRACE("\tMessageType = %u\n",pLpcMessageIn
->MessageType
);
500 TRACE("\tVirtualRangesOffset = %u\n",pLpcMessageIn
->VirtualRangesOffset
);
501 TRACE("\tClientId.UniqueProcess = %p\n",pLpcMessageIn
->ClientId
.UniqueProcess
);
502 TRACE("\tClientId.UniqueThread = %p\n",pLpcMessageIn
->ClientId
.UniqueThread
);
503 TRACE("\tMessageId = %lu\n",pLpcMessageIn
->MessageId
);
504 TRACE("\tSectionSize = %lu\n",pLpcMessageIn
->SectionSize
);
505 TRACE("\tData = %s\n",
506 debugstr_an((const char*)pLpcMessageIn
->Data
,pLpcMessageIn
->DataSize
));
511 /******************************************************************************
512 * NtReplyWaitReceivePort [NTDLL.@]
513 * ZwReplyWaitReceivePort [NTDLL.@]
515 NTSTATUS WINAPI
NtReplyWaitReceivePort(
517 PULONG PortIdentifier
,
518 PLPC_MESSAGE ReplyMessage
,
519 PLPC_MESSAGE Message
)
521 FIXME("(%p,%p,%p,%p),stub!\n",PortHandle
,PortIdentifier
,ReplyMessage
,Message
);
529 /******************************************************************************
530 * NtSetIntervalProfile [NTDLL.@]
531 * ZwSetIntervalProfile [NTDLL.@]
533 NTSTATUS WINAPI
NtSetIntervalProfile(
535 KPROFILE_SOURCE Source
)
537 FIXME("%lu,%d\n", Interval
, Source
);
538 return STATUS_SUCCESS
;
541 /******************************************************************************
542 * NtQuerySystemInformation [NTDLL.@]
543 * ZwQuerySystemInformation [NTDLL.@]
546 * SystemInformationClass Index to a certain information structure
547 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
548 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
549 * SystemConfigurationInformation CONFIGURATION_INFORMATION
550 * observed (class/len):
556 * SystemInformation caller supplies storage for the information structure
557 * Length size of the structure
558 * ResultLength Data written
560 NTSTATUS WINAPI
NtQuerySystemInformation(
561 IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
562 OUT PVOID SystemInformation
,
564 OUT PULONG ResultLength
)
566 NTSTATUS ret
= STATUS_SUCCESS
;
569 TRACE("(0x%08x,%p,0x%08lx,%p)\n",
570 SystemInformationClass
,SystemInformation
,Length
,ResultLength
);
572 switch (SystemInformationClass
)
574 case SystemBasicInformation
:
576 SYSTEM_BASIC_INFORMATION sbi
;
579 sbi
.uKeMaximumIncrement
= 0;
580 sbi
.uPageSize
= 1024; /* FIXME */
581 sbi
.uMmNumberOfPhysicalPages
= 12345; /* FIXME */
582 sbi
.uMmLowestPhysicalPage
= 0; /* FIXME */
583 sbi
.uMmHighestPhysicalPage
= 12345; /* FIXME */
584 sbi
.uAllocationGranularity
= 65536; /* FIXME */
585 sbi
.pLowestUserAddress
= 0; /* FIXME */
586 sbi
.pMmHighestUserAddress
= (void*)~0; /* FIXME */
587 sbi
.uKeActiveProcessors
= 1; /* FIXME */
588 sbi
.bKeNumberProcessors
= 1; /* FIXME */
593 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
594 else memcpy( SystemInformation
, &sbi
, len
);
596 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
599 case SystemCpuInformation
:
601 SYSTEM_CPU_INFORMATION sci
;
603 /* FIXME: move some code from kernel/cpu.c to process this */
604 sci
.Architecture
= PROCESSOR_ARCHITECTURE_INTEL
;
605 sci
.Level
= 6; /* 686, aka Pentium II+ */
608 sci
.FeatureSet
= 0x1fff;
613 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
614 else memcpy( SystemInformation
, &sci
, len
);
616 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
619 case SystemPerformanceInformation
:
621 SYSTEM_PERFORMANCE_INFORMATION spi
;
623 memset(&spi
, 0 , sizeof(spi
));
628 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
629 else memcpy( SystemInformation
, &spi
, len
);
631 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
634 case SystemTimeOfDayInformation
:
636 SYSTEM_TIMEOFDAY_INFORMATION sti
;
638 memset(&sti
, 0 , sizeof(sti
));
640 /* liKeSystemTime, liExpTimeZoneBias, uCurrentTimeZoneId */
641 RtlSecondsSince1970ToTime( server_start_time
, &sti
.liKeBootTime
);
643 if (Length
<= sizeof(sti
))
646 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
647 else memcpy( SystemInformation
, &sti
, Length
);
649 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
652 case SystemProcessInformation
:
654 SYSTEM_PROCESS_INFORMATION
* spi
= (SYSTEM_PROCESS_INFORMATION
*)SystemInformation
;
655 SYSTEM_PROCESS_INFORMATION
* last
= NULL
;
657 WCHAR procname
[1024];
660 DWORD procstructlen
= 0;
662 SERVER_START_REQ( create_snapshot
)
664 req
->flags
= SNAP_PROCESS
| SNAP_THREAD
;
667 if (!(ret
= wine_server_call( req
))) hSnap
= reply
->handle
;
671 while (ret
== STATUS_SUCCESS
)
673 SERVER_START_REQ( next_process
)
676 req
->reset
= (len
== 0);
677 wine_server_set_reply( req
, procname
, sizeof(procname
)-sizeof(WCHAR
) );
678 if (!(ret
= wine_server_call( req
)))
680 /* Make sure procname is 0 terminated */
681 procname
[wine_server_reply_size(reply
) / sizeof(WCHAR
)] = 0;
683 /* Get only the executable name, not the path */
684 if ((exename
= strrchrW(procname
, '\\')) != NULL
) exename
++;
685 else exename
= procname
;
687 wlen
= (strlenW(exename
) + 1) * sizeof(WCHAR
);
689 procstructlen
= sizeof(*spi
) + wlen
+ ((reply
->threads
- 1) * sizeof(SYSTEM_THREAD_INFORMATION
));
691 if (Length
>= len
+ procstructlen
)
693 /* ftCreationTime, ftUserTime, ftKernelTime;
694 * vmCounters, ioCounters
697 memset(spi
, 0, sizeof(*spi
));
699 spi
->dwOffset
= procstructlen
- wlen
;
700 spi
->dwThreadCount
= reply
->threads
;
702 /* spi->pszProcessName will be set later on */
704 spi
->dwBasePriority
= reply
->priority
;
705 spi
->dwProcessID
= (DWORD
)reply
->pid
;
706 spi
->dwParentProcessID
= (DWORD
)reply
->ppid
;
707 spi
->dwHandleCount
= reply
->handles
;
709 /* spi->ti will be set later on */
711 len
+= procstructlen
;
713 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
718 if (ret
!= STATUS_SUCCESS
)
720 if (ret
== STATUS_NO_MORE_FILES
) ret
= STATUS_SUCCESS
;
723 else /* Length is already checked for */
727 /* set thread info */
729 while (ret
== STATUS_SUCCESS
)
731 SERVER_START_REQ( next_thread
)
734 req
->reset
= (j
== 0);
735 if (!(ret
= wine_server_call( req
)))
738 if (reply
->pid
== spi
->dwProcessID
)
740 /* ftKernelTime, ftUserTime, ftCreateTime;
741 * dwTickCount, dwStartAddress
744 memset(&spi
->ti
[i
], 0, sizeof(spi
->ti
));
746 spi
->ti
[i
].dwOwningPID
= reply
->pid
;
747 spi
->ti
[i
].dwThreadID
= reply
->tid
;
748 spi
->ti
[i
].dwCurrentPriority
= reply
->base_pri
+ reply
->delta_pri
;
749 spi
->ti
[i
].dwBasePriority
= reply
->base_pri
;
756 if (ret
== STATUS_NO_MORE_FILES
) ret
= STATUS_SUCCESS
;
758 /* now append process name */
759 spi
->ProcessName
.Buffer
= (WCHAR
*)((char*)spi
+ spi
->dwOffset
);
760 spi
->ProcessName
.Length
= wlen
- sizeof(WCHAR
);
761 spi
->ProcessName
.MaximumLength
= wlen
;
762 memcpy( spi
->ProcessName
.Buffer
, exename
, wlen
);
763 spi
->dwOffset
+= wlen
;
766 spi
= (SYSTEM_PROCESS_INFORMATION
*)((char*)spi
+ spi
->dwOffset
);
769 if (ret
== STATUS_SUCCESS
&& last
) last
->dwOffset
= 0;
770 if (hSnap
) NtClose(hSnap
);
773 case SystemProcessorPerformanceInformation
:
775 SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION sppi
;
777 memset(&sppi
, 0 , sizeof(sppi
)); /* FIXME */
782 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
783 else memcpy( SystemInformation
, &sppi
, len
);
785 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
788 case SystemModuleInformation
:
790 SYSTEM_MODULE_INFORMATION smi
;
792 memset(&smi
, 0, sizeof(smi
));
797 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
798 else memcpy( SystemInformation
, &smi
, len
);
800 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
803 case SystemHandleInformation
:
805 SYSTEM_HANDLE_INFORMATION shi
;
807 memset(&shi
, 0, sizeof(shi
));
812 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
813 else memcpy( SystemInformation
, &shi
, len
);
815 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
818 case SystemCacheInformation
:
820 SYSTEM_CACHE_INFORMATION sci
;
822 memset(&sci
, 0, sizeof(sci
)); /* FIXME */
827 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
828 else memcpy( SystemInformation
, &sci
, len
);
830 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
833 case SystemInterruptInformation
:
835 SYSTEM_INTERRUPT_INFORMATION sii
;
837 memset(&sii
, 0, sizeof(sii
));
842 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
843 else memcpy( SystemInformation
, &sii
, len
);
845 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
848 case SystemKernelDebuggerInformation
:
850 SYSTEM_KERNEL_DEBUGGER_INFORMATION skdi
;
852 skdi
.DebuggerEnabled
= FALSE
;
853 skdi
.DebuggerNotPresent
= TRUE
;
858 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
859 else memcpy( SystemInformation
, &skdi
, len
);
861 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
864 case SystemRegistryQuotaInformation
:
866 /* Something to do with the size of the registry *
867 * Since we don't have a size limitation, fake it *
868 * This is almost certainly wrong. *
869 * This sets each of the three words in the struct to 32 MB, *
870 * which is enough to make the IE 5 installer happy. */
871 SYSTEM_REGISTRY_QUOTA_INFORMATION srqi
;
873 srqi
.RegistryQuotaAllowed
= 0x2000000;
874 srqi
.RegistryQuotaUsed
= 0x200000;
875 srqi
.Reserved1
= (void*)0x200000;
880 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
883 FIXME("SystemRegistryQuotaInformation: faking max registry size of 32 MB\n");
884 memcpy( SystemInformation
, &srqi
, len
);
887 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
891 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
892 SystemInformationClass
,SystemInformation
,Length
,ResultLength
);
894 /* Several Information Classes are not implemented on Windows and return 2 different values
895 * STATUS_NOT_IMPLEMENTED or STATUS_INVALID_INFO_CLASS
896 * in 95% of the cases it's STATUS_INVALID_INFO_CLASS, so use this as the default
898 ret
= STATUS_INVALID_INFO_CLASS
;
901 if (ResultLength
) *ResultLength
= len
;
907 /******************************************************************************
908 * NtCreatePagingFile [NTDLL.@]
909 * ZwCreatePagingFile [NTDLL.@]
911 NTSTATUS WINAPI
NtCreatePagingFile(
912 PUNICODE_STRING PageFileName
,
913 PLARGE_INTEGER MinimumSize
,
914 PLARGE_INTEGER MaximumSize
,
915 PLARGE_INTEGER ActualSize
)
917 FIXME("(%p %p %p %p) stub\n", PageFileName
, MinimumSize
, MaximumSize
, ActualSize
);
918 return STATUS_SUCCESS
;
921 /******************************************************************************
922 * NtDisplayString [NTDLL.@]
924 * writes a string to the nt-textmode screen eg. during startup
926 NTSTATUS WINAPI
NtDisplayString ( PUNICODE_STRING string
)
931 if (!(ret
= RtlUnicodeStringToAnsiString( &stringA
, string
, TRUE
)))
933 MESSAGE( "%.*s", stringA
.Length
, stringA
.Buffer
);
934 RtlFreeAnsiString( &stringA
);
939 /******************************************************************************
940 * NtInitiatePowerAction [NTDLL.@]
943 NTSTATUS WINAPI
NtInitiatePowerAction(
944 IN POWER_ACTION SystemAction
,
945 IN SYSTEM_POWER_STATE MinSystemState
,
947 IN BOOLEAN Asynchronous
)
949 FIXME("(%d,%d,0x%08lx,%d),stub\n",
950 SystemAction
,MinSystemState
,Flags
,Asynchronous
);
951 return STATUS_NOT_IMPLEMENTED
;
955 /******************************************************************************
956 * NtPowerInformation [NTDLL.@]
959 NTSTATUS WINAPI
NtPowerInformation(
960 IN POWER_INFORMATION_LEVEL InformationLevel
,
961 IN PVOID lpInputBuffer
,
962 IN ULONG nInputBufferSize
,
963 IN PVOID lpOutputBuffer
,
964 IN ULONG nOutputBufferSize
)
966 TRACE("(%d,%p,%ld,%p,%ld)\n",
967 InformationLevel
,lpInputBuffer
,nInputBufferSize
,lpOutputBuffer
,nOutputBufferSize
);
968 switch(InformationLevel
) {
969 case SystemPowerCapabilities
: {
970 PSYSTEM_POWER_CAPABILITIES PowerCaps
= (PSYSTEM_POWER_CAPABILITIES
)lpOutputBuffer
;
971 FIXME("semi-stub: SystemPowerCapabilities\n");
972 if (nOutputBufferSize
< sizeof(SYSTEM_POWER_CAPABILITIES
))
973 return STATUS_BUFFER_TOO_SMALL
;
974 /* FIXME: These values are based off a native XP desktop, should probably use APM/ACPI to get the 'real' values */
975 PowerCaps
->PowerButtonPresent
= TRUE
;
976 PowerCaps
->SleepButtonPresent
= FALSE
;
977 PowerCaps
->LidPresent
= FALSE
;
978 PowerCaps
->SystemS1
= TRUE
;
979 PowerCaps
->SystemS2
= FALSE
;
980 PowerCaps
->SystemS3
= FALSE
;
981 PowerCaps
->SystemS4
= TRUE
;
982 PowerCaps
->SystemS5
= TRUE
;
983 PowerCaps
->HiberFilePresent
= TRUE
;
984 PowerCaps
->FullWake
= TRUE
;
985 PowerCaps
->VideoDimPresent
= FALSE
;
986 PowerCaps
->ApmPresent
= FALSE
;
987 PowerCaps
->UpsPresent
= FALSE
;
988 PowerCaps
->ThermalControl
= FALSE
;
989 PowerCaps
->ProcessorThrottle
= FALSE
;
990 PowerCaps
->ProcessorMinThrottle
= 100;
991 PowerCaps
->ProcessorMaxThrottle
= 100;
992 PowerCaps
->DiskSpinDown
= TRUE
;
993 PowerCaps
->SystemBatteriesPresent
= FALSE
;
994 PowerCaps
->BatteriesAreShortTerm
= FALSE
;
995 PowerCaps
->BatteryScale
[0].Granularity
= 0;
996 PowerCaps
->BatteryScale
[0].Capacity
= 0;
997 PowerCaps
->BatteryScale
[1].Granularity
= 0;
998 PowerCaps
->BatteryScale
[1].Capacity
= 0;
999 PowerCaps
->BatteryScale
[2].Granularity
= 0;
1000 PowerCaps
->BatteryScale
[2].Capacity
= 0;
1001 PowerCaps
->AcOnLineWake
= PowerSystemUnspecified
;
1002 PowerCaps
->SoftLidWake
= PowerSystemUnspecified
;
1003 PowerCaps
->RtcWake
= PowerSystemSleeping1
;
1004 PowerCaps
->MinDeviceWakeState
= PowerSystemUnspecified
;
1005 PowerCaps
->DefaultLowLatencyWake
= PowerSystemUnspecified
;
1006 return STATUS_SUCCESS
;
1009 FIXME("Unimplemented NtPowerInformation action: %d\n", InformationLevel
);
1010 return STATUS_NOT_IMPLEMENTED
;
1014 /******************************************************************************
1015 * NtShutdownSystem [NTDLL.@]
1018 NTSTATUS WINAPI
NtShutdownSystem(SHUTDOWN_ACTION Action
)
1020 FIXME("%d\n",Action
);
1021 return STATUS_SUCCESS
;
1024 /******************************************************************************
1025 * NtAllocateLocallyUniqueId (NTDLL.@)
1027 * FIXME: the server should do that
1029 NTSTATUS WINAPI
NtAllocateLocallyUniqueId(PLUID Luid
)
1031 static LUID luid
= { SE_MAX_WELL_KNOWN_PRIVILEGE
, 0 };
1033 FIXME("%p\n", Luid
);
1036 return STATUS_ACCESS_VIOLATION
;
1039 if (luid
.LowPart
==0)
1041 Luid
->HighPart
= luid
.HighPart
;
1042 Luid
->LowPart
= luid
.LowPart
;
1044 return STATUS_SUCCESS
;
1047 /******************************************************************************
1048 * VerSetConditionMask (NTDLL.@)
1050 ULONGLONG WINAPI
VerSetConditionMask( ULONGLONG dwlConditionMask
, DWORD dwTypeBitMask
,
1051 BYTE dwConditionMask
)
1053 if(dwTypeBitMask
== 0)
1054 return dwlConditionMask
;
1055 dwConditionMask
&= 0x07;
1056 if(dwConditionMask
== 0)
1057 return dwlConditionMask
;
1059 if(dwTypeBitMask
& VER_PRODUCT_TYPE
)
1060 dwlConditionMask
|= dwConditionMask
<< 7*3;
1061 else if (dwTypeBitMask
& VER_SUITENAME
)
1062 dwlConditionMask
|= dwConditionMask
<< 6*3;
1063 else if (dwTypeBitMask
& VER_SERVICEPACKMAJOR
)
1064 dwlConditionMask
|= dwConditionMask
<< 5*3;
1065 else if (dwTypeBitMask
& VER_SERVICEPACKMINOR
)
1066 dwlConditionMask
|= dwConditionMask
<< 4*3;
1067 else if (dwTypeBitMask
& VER_PLATFORMID
)
1068 dwlConditionMask
|= dwConditionMask
<< 3*3;
1069 else if (dwTypeBitMask
& VER_BUILDNUMBER
)
1070 dwlConditionMask
|= dwConditionMask
<< 2*3;
1071 else if (dwTypeBitMask
& VER_MAJORVERSION
)
1072 dwlConditionMask
|= dwConditionMask
<< 1*3;
1073 else if (dwTypeBitMask
& VER_MINORVERSION
)
1074 dwlConditionMask
|= dwConditionMask
<< 0*3;
1075 return dwlConditionMask
;
1078 /******************************************************************************
1079 * NtAccessCheckAndAuditAlarm (NTDLL.@)
1080 * ZwAccessCheckAndAuditAlarm (NTDLL.@)
1082 NTSTATUS WINAPI
NtAccessCheckAndAuditAlarm(PUNICODE_STRING SubsystemName
, HANDLE HandleId
, PUNICODE_STRING ObjectTypeName
,
1083 PUNICODE_STRING ObjectName
, PSECURITY_DESCRIPTOR SecurityDescriptor
,
1084 ACCESS_MASK DesiredAccess
, PGENERIC_MAPPING GenericMapping
, BOOLEAN ObjectCreation
,
1085 PACCESS_MASK GrantedAccess
, PBOOLEAN AccessStatus
, PBOOLEAN GenerateOnClose
)
1087 FIXME("(%s, %p, %s, %p, 0x%08lx, %p, %d, %p, %p, %p), stub\n", debugstr_us(SubsystemName
), HandleId
,
1088 debugstr_us(ObjectTypeName
), SecurityDescriptor
, DesiredAccess
, GenericMapping
, ObjectCreation
,
1089 GrantedAccess
, AccessStatus
, GenerateOnClose
);
1091 return STATUS_NOT_IMPLEMENTED
;