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"
30 #include "wine/unicode.h"
34 #include "ntdll_misc.h"
35 #include "wine/server.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(ntdll
);
43 /******************************************************************************
44 * NtDuplicateToken [NTDLL.@]
45 * ZwDuplicateToken [NTDLL.@]
47 NTSTATUS WINAPI
NtDuplicateToken(
48 IN HANDLE ExistingToken
,
49 IN ACCESS_MASK DesiredAccess
,
50 IN POBJECT_ATTRIBUTES ObjectAttributes
,
51 IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
,
52 IN TOKEN_TYPE TokenType
,
57 TRACE("(%p,0x%08lx,%p,0x%08x,0x%08x,%p)\n",
58 ExistingToken
, DesiredAccess
, ObjectAttributes
,
59 ImpersonationLevel
, TokenType
, NewToken
);
60 dump_ObjectAttributes(ObjectAttributes
);
62 SERVER_START_REQ( duplicate_token
)
64 req
->handle
= ExistingToken
;
65 req
->access
= DesiredAccess
;
66 req
->inherit
= ObjectAttributes
&& (ObjectAttributes
->Attributes
& OBJ_INHERIT
);
67 req
->primary
= (TokenType
== TokenPrimary
);
68 req
->impersonation_level
= ImpersonationLevel
;
69 status
= wine_server_call( req
);
70 if (!status
) *NewToken
= reply
->new_handle
;
77 /******************************************************************************
78 * NtOpenProcessToken [NTDLL.@]
79 * ZwOpenProcessToken [NTDLL.@]
81 NTSTATUS WINAPI
NtOpenProcessToken(
88 TRACE("(%p,0x%08lx,%p)\n", ProcessHandle
,DesiredAccess
, TokenHandle
);
90 SERVER_START_REQ( open_token
)
92 req
->handle
= ProcessHandle
;
94 ret
= wine_server_call( req
);
95 if (!ret
) *TokenHandle
= reply
->token
;
102 /******************************************************************************
103 * NtOpenThreadToken [NTDLL.@]
104 * ZwOpenThreadToken [NTDLL.@]
106 NTSTATUS WINAPI
NtOpenThreadToken(
114 TRACE("(%p,0x%08lx,0x%08x,%p)\n",
115 ThreadHandle
,DesiredAccess
, OpenAsSelf
, TokenHandle
);
117 SERVER_START_REQ( open_token
)
119 req
->handle
= ThreadHandle
;
120 req
->flags
= OPEN_TOKEN_THREAD
;
121 if (OpenAsSelf
) req
->flags
|= OPEN_TOKEN_AS_SELF
;
122 ret
= wine_server_call( req
);
123 if (!ret
) *TokenHandle
= reply
->token
;
130 /******************************************************************************
131 * NtAdjustPrivilegesToken [NTDLL.@]
132 * ZwAdjustPrivilegesToken [NTDLL.@]
134 * FIXME: parameters unsafe
136 NTSTATUS WINAPI
NtAdjustPrivilegesToken(
137 IN HANDLE TokenHandle
,
138 IN BOOLEAN DisableAllPrivileges
,
139 IN PTOKEN_PRIVILEGES NewState
,
140 IN DWORD BufferLength
,
141 OUT PTOKEN_PRIVILEGES PreviousState
,
142 OUT PDWORD ReturnLength
)
146 TRACE("(%p,0x%08x,%p,0x%08lx,%p,%p)\n",
147 TokenHandle
, DisableAllPrivileges
, NewState
, BufferLength
, PreviousState
, ReturnLength
);
149 SERVER_START_REQ( adjust_token_privileges
)
151 req
->handle
= TokenHandle
;
152 req
->disable_all
= DisableAllPrivileges
;
153 req
->get_modified_state
= (PreviousState
!= NULL
);
154 if (!DisableAllPrivileges
)
156 wine_server_add_data( req
, &NewState
->Privileges
,
157 NewState
->PrivilegeCount
* sizeof(NewState
->Privileges
[0]) );
159 if (PreviousState
&& BufferLength
>= FIELD_OFFSET( TOKEN_PRIVILEGES
, Privileges
))
160 wine_server_set_reply( req
, &PreviousState
->Privileges
,
161 BufferLength
- FIELD_OFFSET( TOKEN_PRIVILEGES
, Privileges
) );
162 ret
= wine_server_call( req
);
165 *ReturnLength
= reply
->len
+ FIELD_OFFSET( TOKEN_PRIVILEGES
, Privileges
);
166 PreviousState
->PrivilegeCount
= reply
->len
/ sizeof(LUID_AND_ATTRIBUTES
);
174 /******************************************************************************
175 * NtQueryInformationToken [NTDLL.@]
176 * ZwQueryInformationToken [NTDLL.@]
179 * Buffer for TokenUser:
180 * 0x00 TOKEN_USER the PSID field points to the SID
184 NTSTATUS WINAPI
NtQueryInformationToken(
186 DWORD tokeninfoclass
,
188 DWORD tokeninfolength
,
191 unsigned int len
= 0;
192 NTSTATUS status
= STATUS_SUCCESS
;
194 TRACE("(%p,%ld,%p,%ld,%p)\n",
195 token
,tokeninfoclass
,tokeninfo
,tokeninfolength
,retlen
);
197 switch (tokeninfoclass
)
200 len
= sizeof(TOKEN_GROUPS
);
203 len
= sizeof(TOKEN_OWNER
) + sizeof(SID
);
205 case TokenPrimaryGroup
:
206 len
= sizeof(TOKEN_PRIMARY_GROUP
);
208 case TokenDefaultDacl
:
209 len
= sizeof(TOKEN_DEFAULT_DACL
);
212 len
= sizeof(TOKEN_SOURCE
);
215 len
= sizeof (TOKEN_TYPE
);
218 case TokenImpersonationLevel
:
219 case TokenStatistics
:
223 /* FIXME: what if retlen == NULL ? */
226 if (tokeninfolength
< len
)
227 return STATUS_BUFFER_TOO_SMALL
;
229 switch (tokeninfoclass
)
232 SERVER_START_REQ( get_token_user
)
234 TOKEN_USER
* tuser
= tokeninfo
;
235 PSID sid
= (PSID
) (tuser
+ 1);
236 DWORD sid_len
= tokeninfolength
< sizeof(TOKEN_USER
) ? 0 : tokeninfolength
- sizeof(TOKEN_USER
);
239 wine_server_set_reply( req
, sid
, sid_len
);
240 status
= wine_server_call( req
);
241 *retlen
= reply
->user_len
+ sizeof(TOKEN_USER
);
242 if (status
== STATUS_SUCCESS
)
244 tuser
->User
.Sid
= sid
;
245 tuser
->User
.Attributes
= 0;
253 TOKEN_GROUPS
*tgroups
= tokeninfo
;
254 SID_IDENTIFIER_AUTHORITY sid
= {SECURITY_NT_AUTHORITY
};
256 /* we need to show admin privileges ! */
257 tgroups
->GroupCount
= 1;
258 tgroups
->Groups
->Attributes
= SE_GROUP_ENABLED
;
259 RtlAllocateAndInitializeSid( &sid
,
261 SECURITY_BUILTIN_DOMAIN_RID
,
262 DOMAIN_ALIAS_RID_ADMINS
,
264 &(tgroups
->Groups
->Sid
));
267 case TokenPrimaryGroup
:
270 TOKEN_PRIMARY_GROUP
*tgroup
= tokeninfo
;
271 SID_IDENTIFIER_AUTHORITY sid
= {SECURITY_NT_AUTHORITY
};
272 RtlAllocateAndInitializeSid( &sid
,
274 SECURITY_BUILTIN_DOMAIN_RID
,
275 DOMAIN_ALIAS_RID_ADMINS
,
277 &(tgroup
->PrimaryGroup
));
280 case TokenPrivileges
:
281 SERVER_START_REQ( get_token_privileges
)
283 TOKEN_PRIVILEGES
*tpriv
= tokeninfo
;
285 if (tpriv
&& tokeninfolength
> FIELD_OFFSET( TOKEN_PRIVILEGES
, Privileges
))
286 wine_server_set_reply( req
, &tpriv
->Privileges
, tokeninfolength
- FIELD_OFFSET( TOKEN_PRIVILEGES
, Privileges
) );
287 status
= wine_server_call( req
);
288 *retlen
= FIELD_OFFSET( TOKEN_PRIVILEGES
, Privileges
) + reply
->len
;
289 if (tpriv
) tpriv
->PrivilegeCount
= reply
->len
/ sizeof(LUID_AND_ATTRIBUTES
);
296 TOKEN_OWNER
*owner
= tokeninfo
;
297 PSID sid
= (PSID
) (owner
+ 1);
298 SID_IDENTIFIER_AUTHORITY localSidAuthority
= {SECURITY_NT_AUTHORITY
};
299 RtlInitializeSid(sid
, &localSidAuthority
, 1);
300 *(RtlSubAuthoritySid(sid
, 0)) = SECURITY_INTERACTIVE_RID
;
306 ERR("Unhandled Token Information class %ld!\n", tokeninfoclass
);
307 return STATUS_NOT_IMPLEMENTED
;
313 /******************************************************************************
314 * NtSetInformationToken [NTDLL.@]
315 * ZwSetInformationToken [NTDLL.@]
317 NTSTATUS WINAPI
NtSetInformationToken(
319 TOKEN_INFORMATION_CLASS TokenInformationClass
,
320 PVOID TokenInformation
,
321 ULONG TokenInformationLength
)
323 FIXME("%p %d %p %lu\n", TokenHandle
, TokenInformationClass
,
324 TokenInformation
, TokenInformationLength
);
325 return STATUS_NOT_IMPLEMENTED
;
328 /******************************************************************************
329 * NtAdjustGroupsToken [NTDLL.@]
330 * ZwAdjustGroupsToken [NTDLL.@]
332 NTSTATUS WINAPI
NtAdjustGroupsToken(
334 BOOLEAN ResetToDefault
,
335 PTOKEN_GROUPS NewState
,
337 PTOKEN_GROUPS PreviousState
,
340 FIXME("%p %d %p %lu %p %p\n", TokenHandle
, ResetToDefault
,
341 NewState
, BufferLength
, PreviousState
, ReturnLength
);
342 return STATUS_NOT_IMPLEMENTED
;
345 /******************************************************************************
346 * NtPrivilegeCheck [NTDLL.@]
347 * ZwPrivilegeCheck [NTDLL.@]
349 NTSTATUS WINAPI
NtPrivilegeCheck(
351 PPRIVILEGE_SET RequiredPrivileges
,
355 SERVER_START_REQ( check_token_privileges
)
357 req
->handle
= ClientToken
;
358 req
->all_required
= ((RequiredPrivileges
->Control
& PRIVILEGE_SET_ALL_NECESSARY
) ? TRUE
: FALSE
);
359 wine_server_add_data( req
, &RequiredPrivileges
->Privilege
,
360 RequiredPrivileges
->PrivilegeCount
* sizeof(RequiredPrivileges
->Privilege
[0]) );
361 wine_server_set_reply( req
, &RequiredPrivileges
->Privilege
,
362 RequiredPrivileges
->PrivilegeCount
* sizeof(RequiredPrivileges
->Privilege
[0]) );
364 status
= wine_server_call( req
);
366 if (status
== STATUS_SUCCESS
)
367 *Result
= (reply
->has_privileges
? TRUE
: FALSE
);
377 /******************************************************************************
378 * NtQuerySection [NTDLL.@]
380 NTSTATUS WINAPI
NtQuerySection(
381 IN HANDLE SectionHandle
,
382 IN SECTION_INFORMATION_CLASS SectionInformationClass
,
383 OUT PVOID SectionInformation
,
385 OUT PULONG ResultLength
)
387 FIXME("(%p,%d,%p,0x%08lx,%p) stub!\n",
388 SectionHandle
,SectionInformationClass
,SectionInformation
,Length
,ResultLength
);
396 /******************************************************************************
397 * NtCreatePort [NTDLL.@]
398 * ZwCreatePort [NTDLL.@]
400 NTSTATUS WINAPI
NtCreatePort(PHANDLE PortHandle
,POBJECT_ATTRIBUTES ObjectAttributes
,
401 ULONG MaxConnectInfoLength
,ULONG MaxDataLength
,PULONG reserved
)
403 FIXME("(%p,%p,%lu,%lu,%p),stub!\n",PortHandle
,ObjectAttributes
,
404 MaxConnectInfoLength
,MaxDataLength
,reserved
);
408 /******************************************************************************
409 * NtConnectPort [NTDLL.@]
410 * ZwConnectPort [NTDLL.@]
412 NTSTATUS WINAPI
NtConnectPort(
414 PUNICODE_STRING PortName
,
415 PSECURITY_QUALITY_OF_SERVICE SecurityQos
,
416 PLPC_SECTION_WRITE WriteSection
,
417 PLPC_SECTION_READ ReadSection
,
418 PULONG MaximumMessageLength
,
420 PULONG pConnectInfoLength
)
422 FIXME("(%p,%s,%p,%p,%p,%p,%p,%p),stub!\n",
423 PortHandle
,debugstr_w(PortName
->Buffer
),SecurityQos
,
424 WriteSection
,ReadSection
,MaximumMessageLength
,ConnectInfo
,
426 if (ConnectInfo
&& pConnectInfoLength
)
427 TRACE("\tMessage = %s\n",debugstr_an(ConnectInfo
,*pConnectInfoLength
));
431 /******************************************************************************
432 * NtListenPort [NTDLL.@]
433 * ZwListenPort [NTDLL.@]
435 NTSTATUS WINAPI
NtListenPort(HANDLE PortHandle
,PLPC_MESSAGE pLpcMessage
)
437 FIXME("(%p,%p),stub!\n",PortHandle
,pLpcMessage
);
441 /******************************************************************************
442 * NtAcceptConnectPort [NTDLL.@]
443 * ZwAcceptConnectPort [NTDLL.@]
445 NTSTATUS WINAPI
NtAcceptConnectPort(
447 ULONG PortIdentifier
,
448 PLPC_MESSAGE pLpcMessage
,
450 PLPC_SECTION_WRITE WriteSection
,
451 PLPC_SECTION_READ ReadSection
)
453 FIXME("(%p,%lu,%p,%d,%p,%p),stub!\n",
454 PortHandle
,PortIdentifier
,pLpcMessage
,Accept
,WriteSection
,ReadSection
);
458 /******************************************************************************
459 * NtCompleteConnectPort [NTDLL.@]
460 * ZwCompleteConnectPort [NTDLL.@]
462 NTSTATUS WINAPI
NtCompleteConnectPort(HANDLE PortHandle
)
464 FIXME("(%p),stub!\n",PortHandle
);
468 /******************************************************************************
469 * NtRegisterThreadTerminatePort [NTDLL.@]
470 * ZwRegisterThreadTerminatePort [NTDLL.@]
472 NTSTATUS WINAPI
NtRegisterThreadTerminatePort(HANDLE PortHandle
)
474 FIXME("(%p),stub!\n",PortHandle
);
478 /******************************************************************************
479 * NtRequestWaitReplyPort [NTDLL.@]
480 * ZwRequestWaitReplyPort [NTDLL.@]
482 NTSTATUS WINAPI
NtRequestWaitReplyPort(
484 PLPC_MESSAGE pLpcMessageIn
,
485 PLPC_MESSAGE pLpcMessageOut
)
487 FIXME("(%p,%p,%p),stub!\n",PortHandle
,pLpcMessageIn
,pLpcMessageOut
);
490 TRACE("Message to send:\n");
491 TRACE("\tDataSize = %u\n",pLpcMessageIn
->DataSize
);
492 TRACE("\tMessageSize = %u\n",pLpcMessageIn
->MessageSize
);
493 TRACE("\tMessageType = %u\n",pLpcMessageIn
->MessageType
);
494 TRACE("\tVirtualRangesOffset = %u\n",pLpcMessageIn
->VirtualRangesOffset
);
495 TRACE("\tClientId.UniqueProcess = %p\n",pLpcMessageIn
->ClientId
.UniqueProcess
);
496 TRACE("\tClientId.UniqueThread = %p\n",pLpcMessageIn
->ClientId
.UniqueThread
);
497 TRACE("\tMessageId = %lu\n",pLpcMessageIn
->MessageId
);
498 TRACE("\tSectionSize = %lu\n",pLpcMessageIn
->SectionSize
);
499 TRACE("\tData = %s\n",
500 debugstr_an((const char*)pLpcMessageIn
->Data
,pLpcMessageIn
->DataSize
));
505 /******************************************************************************
506 * NtReplyWaitReceivePort [NTDLL.@]
507 * ZwReplyWaitReceivePort [NTDLL.@]
509 NTSTATUS WINAPI
NtReplyWaitReceivePort(
511 PULONG PortIdentifier
,
512 PLPC_MESSAGE ReplyMessage
,
513 PLPC_MESSAGE Message
)
515 FIXME("(%p,%p,%p,%p),stub!\n",PortHandle
,PortIdentifier
,ReplyMessage
,Message
);
523 /******************************************************************************
524 * NtSetIntervalProfile [NTDLL.@]
525 * ZwSetIntervalProfile [NTDLL.@]
527 NTSTATUS WINAPI
NtSetIntervalProfile(
529 KPROFILE_SOURCE Source
)
531 FIXME("%lu,%d\n", Interval
, Source
);
532 return STATUS_SUCCESS
;
535 /******************************************************************************
536 * NtQuerySystemInformation [NTDLL.@]
537 * ZwQuerySystemInformation [NTDLL.@]
540 * SystemInformationClass Index to a certain information structure
541 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
542 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
543 * SystemConfigurationInformation CONFIGURATION_INFORMATION
544 * observed (class/len):
550 * SystemInformation caller supplies storage for the information structure
551 * Length size of the structure
552 * ResultLength Data written
554 NTSTATUS WINAPI
NtQuerySystemInformation(
555 IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
556 OUT PVOID SystemInformation
,
558 OUT PULONG ResultLength
)
560 NTSTATUS ret
= STATUS_SUCCESS
;
563 TRACE("(0x%08x,%p,0x%08lx,%p)\n",
564 SystemInformationClass
,SystemInformation
,Length
,ResultLength
);
566 switch (SystemInformationClass
)
568 case SystemBasicInformation
:
570 SYSTEM_BASIC_INFORMATION sbi
;
573 sbi
.uKeMaximumIncrement
= 0;
574 sbi
.uPageSize
= 1024; /* FIXME */
575 sbi
.uMmNumberOfPhysicalPages
= 12345; /* FIXME */
576 sbi
.uMmLowestPhysicalPage
= 0; /* FIXME */
577 sbi
.uMmHighestPhysicalPage
= 12345; /* FIXME */
578 sbi
.uAllocationGranularity
= 65536; /* FIXME */
579 sbi
.pLowestUserAddress
= 0; /* FIXME */
580 sbi
.pMmHighestUserAddress
= (void*)~0; /* FIXME */
581 sbi
.uKeActiveProcessors
= 1; /* FIXME */
582 sbi
.bKeNumberProcessors
= 1; /* FIXME */
587 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
588 else memcpy( SystemInformation
, &sbi
, len
);
590 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
593 case SystemCpuInformation
:
595 SYSTEM_CPU_INFORMATION sci
;
597 /* FIXME: move some code from kernel/cpu.c to process this */
598 sci
.Architecture
= PROCESSOR_ARCHITECTURE_INTEL
;
599 sci
.Level
= 6; /* 686, aka Pentium II+ */
602 sci
.FeatureSet
= 0x1fff;
607 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
608 else memcpy( SystemInformation
, &sci
, len
);
610 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
613 case SystemPerformanceInformation
:
615 SYSTEM_PERFORMANCE_INFORMATION spi
;
617 memset(&spi
, 0 , sizeof(spi
));
622 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
623 else memcpy( SystemInformation
, &spi
, len
);
625 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
628 case SystemTimeOfDayInformation
:
630 SYSTEM_TIMEOFDAY_INFORMATION sti
;
632 memset(&sti
, 0 , sizeof(sti
));
634 /* liKeSystemTime, liExpTimeZoneBias, uCurrentTimeZoneId */
635 RtlSecondsSince1970ToTime( server_start_time
, &sti
.liKeBootTime
);
637 if (Length
<= sizeof(sti
))
640 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
641 else memcpy( SystemInformation
, &sti
, Length
);
643 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
646 case SystemProcessInformation
:
648 SYSTEM_PROCESS_INFORMATION
* spi
= (SYSTEM_PROCESS_INFORMATION
*)SystemInformation
;
649 SYSTEM_PROCESS_INFORMATION
* last
= NULL
;
651 WCHAR procname
[1024];
654 DWORD procstructlen
= 0;
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
)-sizeof(WCHAR
) );
672 if (!(ret
= wine_server_call( req
)))
674 /* Make sure procname is 0 terminated */
675 procname
[wine_server_reply_size(reply
) / sizeof(WCHAR
)] = 0;
677 /* Get only the executable name, not the path */
678 if ((exename
= strrchrW(procname
, '\\')) != NULL
) exename
++;
679 else exename
= procname
;
681 wlen
= (strlenW(exename
) + 1) * sizeof(WCHAR
);
683 procstructlen
= sizeof(*spi
) + wlen
+ ((reply
->threads
- 1) * sizeof(SYSTEM_THREAD_INFORMATION
));
685 if (Length
>= len
+ procstructlen
)
687 /* ftCreationTime, ftUserTime, ftKernelTime;
688 * vmCounters, ioCounters
691 memset(spi
, 0, sizeof(*spi
));
693 spi
->dwOffset
= procstructlen
- wlen
;
694 spi
->dwThreadCount
= reply
->threads
;
696 /* spi->pszProcessName will be set later on */
698 spi
->dwBasePriority
= reply
->priority
;
699 spi
->dwProcessID
= (DWORD
)reply
->pid
;
700 spi
->dwParentProcessID
= (DWORD
)reply
->ppid
;
701 spi
->dwHandleCount
= reply
->handles
;
703 /* spi->ti will be set later on */
705 len
+= procstructlen
;
707 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
712 if (ret
!= STATUS_SUCCESS
)
714 if (ret
== STATUS_NO_MORE_FILES
) ret
= STATUS_SUCCESS
;
717 else /* Length is already checked for */
721 /* set thread info */
723 while (ret
== STATUS_SUCCESS
)
725 SERVER_START_REQ( next_thread
)
728 req
->reset
= (j
== 0);
729 if (!(ret
= wine_server_call( req
)))
732 if (reply
->pid
== spi
->dwProcessID
)
734 /* ftKernelTime, ftUserTime, ftCreateTime;
735 * dwTickCount, dwStartAddress
738 memset(&spi
->ti
[i
], 0, sizeof(spi
->ti
));
740 spi
->ti
[i
].dwOwningPID
= reply
->pid
;
741 spi
->ti
[i
].dwThreadID
= reply
->tid
;
742 spi
->ti
[i
].dwCurrentPriority
= reply
->base_pri
+ reply
->delta_pri
;
743 spi
->ti
[i
].dwBasePriority
= reply
->base_pri
;
750 if (ret
== STATUS_NO_MORE_FILES
) ret
= STATUS_SUCCESS
;
752 /* now append process name */
753 spi
->ProcessName
.Buffer
= (WCHAR
*)((char*)spi
+ spi
->dwOffset
);
754 spi
->ProcessName
.Length
= wlen
- sizeof(WCHAR
);
755 spi
->ProcessName
.MaximumLength
= wlen
;
756 memcpy( spi
->ProcessName
.Buffer
, exename
, wlen
);
757 spi
->dwOffset
+= wlen
;
760 spi
= (SYSTEM_PROCESS_INFORMATION
*)((char*)spi
+ spi
->dwOffset
);
763 if (ret
== STATUS_SUCCESS
&& last
) last
->dwOffset
= 0;
764 if (hSnap
) NtClose(hSnap
);
767 case SystemProcessorPerformanceInformation
:
769 SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION sppi
;
771 memset(&sppi
, 0 , sizeof(sppi
)); /* FIXME */
776 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
777 else memcpy( SystemInformation
, &sppi
, len
);
779 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
782 case SystemModuleInformation
:
784 SYSTEM_MODULE_INFORMATION smi
;
786 memset(&smi
, 0, sizeof(smi
));
791 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
792 else memcpy( SystemInformation
, &smi
, len
);
794 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
797 case SystemHandleInformation
:
799 SYSTEM_HANDLE_INFORMATION shi
;
801 memset(&shi
, 0, sizeof(shi
));
806 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
807 else memcpy( SystemInformation
, &shi
, len
);
809 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
812 case SystemCacheInformation
:
814 SYSTEM_CACHE_INFORMATION sci
;
816 memset(&sci
, 0, sizeof(sci
)); /* FIXME */
821 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
822 else memcpy( SystemInformation
, &sci
, len
);
824 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
827 case SystemInterruptInformation
:
829 SYSTEM_INTERRUPT_INFORMATION sii
;
831 memset(&sii
, 0, sizeof(sii
));
836 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
837 else memcpy( SystemInformation
, &sii
, len
);
839 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
842 case SystemKernelDebuggerInformation
:
844 SYSTEM_KERNEL_DEBUGGER_INFORMATION skdi
;
846 skdi
.DebuggerEnabled
= FALSE
;
847 skdi
.DebuggerNotPresent
= TRUE
;
852 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
853 else memcpy( SystemInformation
, &skdi
, len
);
855 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
858 case SystemRegistryQuotaInformation
:
860 /* Something to do with the size of the registry *
861 * Since we don't have a size limitation, fake it *
862 * This is almost certainly wrong. *
863 * This sets each of the three words in the struct to 32 MB, *
864 * which is enough to make the IE 5 installer happy. */
865 SYSTEM_REGISTRY_QUOTA_INFORMATION srqi
;
867 srqi
.RegistryQuotaAllowed
= 0x2000000;
868 srqi
.RegistryQuotaUsed
= 0x200000;
869 srqi
.Reserved1
= (void*)0x200000;
874 if (!SystemInformation
) ret
= STATUS_ACCESS_VIOLATION
;
877 FIXME("SystemRegistryQuotaInformation: faking max registry size of 32 MB\n");
878 memcpy( SystemInformation
, &srqi
, len
);
881 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
885 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
886 SystemInformationClass
,SystemInformation
,Length
,ResultLength
);
888 /* Several Information Classes are not implemented on Windows and return 2 different values
889 * STATUS_NOT_IMPLEMENTED or STATUS_INVALID_INFO_CLASS
890 * in 95% of the cases it's STATUS_INVALID_INFO_CLASS, so use this as the default
892 ret
= STATUS_INVALID_INFO_CLASS
;
895 if (ResultLength
) *ResultLength
= len
;
901 /******************************************************************************
902 * NtCreatePagingFile [NTDLL.@]
903 * ZwCreatePagingFile [NTDLL.@]
905 NTSTATUS WINAPI
NtCreatePagingFile(
906 PUNICODE_STRING PageFileName
,
907 PLARGE_INTEGER MiniumSize
,
908 PLARGE_INTEGER MaxiumSize
,
909 PLARGE_INTEGER ActualSize
)
911 FIXME("%p %p %p %p\n", PageFileName
, MiniumSize
, MaxiumSize
, ActualSize
);
912 return STATUS_SUCCESS
;
915 /******************************************************************************
916 * NtDisplayString [NTDLL.@]
918 * writes a string to the nt-textmode screen eg. during startup
920 NTSTATUS WINAPI
NtDisplayString ( PUNICODE_STRING string
)
925 if (!(ret
= RtlUnicodeStringToAnsiString( &stringA
, string
, TRUE
)))
927 MESSAGE( "%.*s", stringA
.Length
, stringA
.Buffer
);
928 RtlFreeAnsiString( &stringA
);
933 /******************************************************************************
934 * NtInitiatePowerAction [NTDLL.@]
937 NTSTATUS WINAPI
NtInitiatePowerAction(
938 IN POWER_ACTION SystemAction
,
939 IN SYSTEM_POWER_STATE MinSystemState
,
941 IN BOOLEAN Asynchronous
)
943 FIXME("(%d,%d,0x%08lx,%d),stub\n",
944 SystemAction
,MinSystemState
,Flags
,Asynchronous
);
945 return STATUS_NOT_IMPLEMENTED
;
949 /******************************************************************************
950 * NtPowerInformation [NTDLL.@]
953 NTSTATUS WINAPI
NtPowerInformation(
954 IN POWER_INFORMATION_LEVEL InformationLevel
,
955 IN PVOID lpInputBuffer
,
956 IN ULONG nInputBufferSize
,
957 IN PVOID lpOutputBuffer
,
958 IN ULONG nOutputBufferSize
)
960 TRACE("(%d,%p,%ld,%p,%ld)\n",
961 InformationLevel
,lpInputBuffer
,nInputBufferSize
,lpOutputBuffer
,nOutputBufferSize
);
962 switch(InformationLevel
) {
963 case SystemPowerCapabilities
: {
964 PSYSTEM_POWER_CAPABILITIES PowerCaps
= (PSYSTEM_POWER_CAPABILITIES
)lpOutputBuffer
;
965 FIXME("semi-stub: SystemPowerCapabilities\n");
966 if (nOutputBufferSize
< sizeof(SYSTEM_POWER_CAPABILITIES
))
967 return STATUS_BUFFER_TOO_SMALL
;
968 /* FIXME: These values are based off a native XP desktop, should probably use APM/ACPI to get the 'real' values */
969 PowerCaps
->PowerButtonPresent
= TRUE
;
970 PowerCaps
->SleepButtonPresent
= FALSE
;
971 PowerCaps
->LidPresent
= FALSE
;
972 PowerCaps
->SystemS1
= TRUE
;
973 PowerCaps
->SystemS2
= FALSE
;
974 PowerCaps
->SystemS3
= FALSE
;
975 PowerCaps
->SystemS4
= TRUE
;
976 PowerCaps
->SystemS5
= TRUE
;
977 PowerCaps
->HiberFilePresent
= TRUE
;
978 PowerCaps
->FullWake
= TRUE
;
979 PowerCaps
->VideoDimPresent
= FALSE
;
980 PowerCaps
->ApmPresent
= FALSE
;
981 PowerCaps
->UpsPresent
= FALSE
;
982 PowerCaps
->ThermalControl
= FALSE
;
983 PowerCaps
->ProcessorThrottle
= FALSE
;
984 PowerCaps
->ProcessorMinThrottle
= 100;
985 PowerCaps
->ProcessorMaxThrottle
= 100;
986 PowerCaps
->DiskSpinDown
= TRUE
;
987 PowerCaps
->SystemBatteriesPresent
= FALSE
;
988 PowerCaps
->BatteriesAreShortTerm
= FALSE
;
989 PowerCaps
->BatteryScale
[0].Granularity
= 0;
990 PowerCaps
->BatteryScale
[0].Capacity
= 0;
991 PowerCaps
->BatteryScale
[1].Granularity
= 0;
992 PowerCaps
->BatteryScale
[1].Capacity
= 0;
993 PowerCaps
->BatteryScale
[2].Granularity
= 0;
994 PowerCaps
->BatteryScale
[2].Capacity
= 0;
995 PowerCaps
->AcOnLineWake
= PowerSystemUnspecified
;
996 PowerCaps
->SoftLidWake
= PowerSystemUnspecified
;
997 PowerCaps
->RtcWake
= PowerSystemSleeping1
;
998 PowerCaps
->MinDeviceWakeState
= PowerSystemUnspecified
;
999 PowerCaps
->DefaultLowLatencyWake
= PowerSystemUnspecified
;
1000 return STATUS_SUCCESS
;
1003 FIXME("Unimplemented NtPowerInformation action: %d\n", InformationLevel
);
1004 return STATUS_NOT_IMPLEMENTED
;
1008 /******************************************************************************
1009 * NtShutdownSystem [NTDLL.@]
1012 NTSTATUS WINAPI
NtShutdownSystem(SHUTDOWN_ACTION Action
)
1014 FIXME("%d\n",Action
);
1015 return STATUS_SUCCESS
;
1018 /******************************************************************************
1019 * NtAllocateLocallyUniqueId (NTDLL.@)
1021 * FIXME: the server should do that
1023 NTSTATUS WINAPI
NtAllocateLocallyUniqueId(PLUID Luid
)
1025 static LUID luid
= { SE_MAX_WELL_KNOWN_PRIVILEGE
, 0 };
1027 FIXME("%p\n", Luid
);
1030 return STATUS_ACCESS_VIOLATION
;
1033 if (luid
.LowPart
==0)
1035 Luid
->HighPart
= luid
.HighPart
;
1036 Luid
->LowPart
= luid
.LowPart
;
1038 return STATUS_SUCCESS
;
1041 /******************************************************************************
1042 * VerSetConditionMask (NTDLL.@)
1044 ULONGLONG WINAPI
VerSetConditionMask( ULONGLONG dwlConditionMask
, DWORD dwTypeBitMask
,
1045 BYTE dwConditionMask
)
1047 if(dwTypeBitMask
== 0)
1048 return dwlConditionMask
;
1049 dwConditionMask
&= 0x07;
1050 if(dwConditionMask
== 0)
1051 return dwlConditionMask
;
1053 if(dwTypeBitMask
& VER_PRODUCT_TYPE
)
1054 dwlConditionMask
|= dwConditionMask
<< 7*3;
1055 else if (dwTypeBitMask
& VER_SUITENAME
)
1056 dwlConditionMask
|= dwConditionMask
<< 6*3;
1057 else if (dwTypeBitMask
& VER_SERVICEPACKMAJOR
)
1058 dwlConditionMask
|= dwConditionMask
<< 5*3;
1059 else if (dwTypeBitMask
& VER_SERVICEPACKMINOR
)
1060 dwlConditionMask
|= dwConditionMask
<< 4*3;
1061 else if (dwTypeBitMask
& VER_PLATFORMID
)
1062 dwlConditionMask
|= dwConditionMask
<< 3*3;
1063 else if (dwTypeBitMask
& VER_BUILDNUMBER
)
1064 dwlConditionMask
|= dwConditionMask
<< 2*3;
1065 else if (dwTypeBitMask
& VER_MAJORVERSION
)
1066 dwlConditionMask
|= dwConditionMask
<< 1*3;
1067 else if (dwTypeBitMask
& VER_MINORVERSION
)
1068 dwlConditionMask
|= dwConditionMask
<< 0*3;
1069 return dwlConditionMask
;