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
28 #include "wine/debug.h"
31 #include "ntdll_misc.h"
32 #include "wine/server.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
40 /**************************************************************************
41 * NtCreateTimer [NTDLL.@]
42 * ZwCreateTimer [NTDLL.@]
44 NTSTATUS WINAPI NtCreateTimer(
45 OUT PHANDLE TimerHandle,
46 IN ACCESS_MASK DesiredAccess,
47 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
48 IN TIMER_TYPE TimerType)
50 FIXME("(%p,0x%08lx,%p,0x%08x) stub\n",
51 TimerHandle,DesiredAccess,ObjectAttributes, TimerType);
52 dump_ObjectAttributes(ObjectAttributes);
55 /**************************************************************************
56 * NtSetTimer [NTDLL.@]
57 * ZwSetTimer [NTDLL.@]
59 NTSTATUS WINAPI NtSetTimer(
60 IN HANDLE TimerHandle,
61 IN PLARGE_INTEGER DueTime,
62 IN PTIMERAPCROUTINE TimerApcRoutine,
63 IN PVOID TimerContext,
65 IN ULONG Period OPTIONAL,
66 OUT PBOOLEAN PreviousState OPTIONAL)
68 FIXME("(0x%08x,%p,%p,%p,%08x,0x%08lx,%p) stub\n",
69 TimerHandle,DueTime,TimerApcRoutine,TimerContext,WakeTimer,Period,PreviousState);
73 /******************************************************************************
74 * NtQueryTimerResolution [NTDLL.@]
76 NTSTATUS WINAPI NtQueryTimerResolution(DWORD x1,DWORD x2,DWORD x3)
78 FIXME("(0x%08lx,0x%08lx,0x%08lx), stub!\n",x1,x2,x3);
86 /******************************************************************************
87 * NtTerminateProcess [NTDLL.@]
89 * Native applications must kill themselves when done
91 NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
95 SERVER_START_REQ( terminate_process )
98 req->exit_code = exit_code;
99 ret = wine_server_call( req );
100 self = !ret && reply->self;
103 if (self) exit( exit_code );
107 /******************************************************************************
108 * NtQueryInformationProcess [NTDLL.@]
109 * ZwQueryInformationProcess [NTDLL.@]
112 NTSTATUS WINAPI NtQueryInformationProcess(
113 IN HANDLE ProcessHandle,
114 IN PROCESSINFOCLASS ProcessInformationClass,
115 OUT PVOID ProcessInformation,
116 IN ULONG ProcessInformationLength,
117 OUT PULONG ReturnLength)
119 NTSTATUS ret = STATUS_SUCCESS;
122 switch (ProcessInformationClass) {
123 case ProcessDebugPort:
124 /* "These are not the debuggers you are looking for." */
125 /* set it to 0 aka "no debugger" to satisfy copy protections */
126 if (ProcessInformationLength == 4)
128 memset(ProcessInformation,0,ProcessInformationLength);
132 ret = STATUS_INFO_LENGTH_MISMATCH;
135 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p),stub!\n",
136 ProcessHandle,ProcessInformationClass,
137 ProcessInformation,ProcessInformationLength,
149 /******************************************************************************
150 * NtSetInformationProcess [NTDLL.@]
151 * ZwSetInformationProcess [NTDLL.@]
153 NTSTATUS WINAPI NtSetInformationProcess(
154 IN HANDLE ProcessHandle,
155 IN PROCESSINFOCLASS ProcessInformationClass,
156 IN PVOID ProcessInformation,
157 IN ULONG ProcessInformationLength)
159 FIXME("(0x%08x,0x%08x,%p,0x%08lx) stub\n",
160 ProcessHandle,ProcessInformationClass,ProcessInformation,ProcessInformationLength);
168 /******************************************************************************
169 * NtResumeThread [NTDLL.@]
170 * ZwResumeThread [NTDLL.@]
172 NTSTATUS WINAPI NtResumeThread(
173 IN HANDLE ThreadHandle,
174 IN PULONG SuspendCount)
176 FIXME("(0x%08x,%p),stub!\n",
177 ThreadHandle,SuspendCount);
182 /******************************************************************************
183 * NtTerminateThread [NTDLL.@]
184 * ZwTerminateThread [NTDLL.@]
186 NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
191 SERVER_START_REQ( terminate_thread )
193 req->handle = handle;
194 req->exit_code = exit_code;
195 ret = wine_server_call( req );
196 self = !ret && reply->self;
203 if (last) exit( exit_code );
204 else SYSDEPS_ExitThread( exit_code );
210 /******************************************************************************
211 * NtQueryInformationThread [NTDLL.@]
212 * ZwQueryInformationThread [NTDLL.@]
215 NTSTATUS WINAPI NtQueryInformationThread(
216 IN HANDLE ThreadHandle,
217 IN THREADINFOCLASS ThreadInformationClass,
218 OUT PVOID ThreadInformation,
219 IN ULONG ThreadInformationLength,
220 OUT PULONG ReturnLength)
222 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p),stub!\n",
223 ThreadHandle, ThreadInformationClass, ThreadInformation,
224 ThreadInformationLength, ReturnLength);
228 /******************************************************************************
229 * NtSetInformationThread [NTDLL.@]
230 * ZwSetInformationThread [NTDLL.@]
232 NTSTATUS WINAPI NtSetInformationThread(
234 THREADINFOCLASS ThreadInformationClass,
235 PVOID ThreadInformation,
236 ULONG ThreadInformationLength)
238 FIXME("(0x%08x,0x%08x,%p,0x%08lx),stub!\n",
239 ThreadHandle, ThreadInformationClass, ThreadInformation, ThreadInformationLength);
247 /******************************************************************************
248 * NtDuplicateToken [NTDLL.@]
249 * ZwDuplicateToken [NTDLL.@]
251 NTSTATUS WINAPI NtDuplicateToken(
252 IN HANDLE ExistingToken,
253 IN ACCESS_MASK DesiredAccess,
254 IN POBJECT_ATTRIBUTES ObjectAttributes,
255 IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
256 IN TOKEN_TYPE TokenType,
257 OUT PHANDLE NewToken)
259 FIXME("(0x%08x,0x%08lx,%p,0x%08x,0x%08x,%p),stub!\n",
260 ExistingToken, DesiredAccess, ObjectAttributes,
261 ImpersonationLevel, TokenType, NewToken);
262 dump_ObjectAttributes(ObjectAttributes);
266 /******************************************************************************
267 * NtOpenProcessToken [NTDLL.@]
268 * ZwOpenProcessToken [NTDLL.@]
270 NTSTATUS WINAPI NtOpenProcessToken(
271 HANDLE ProcessHandle,
275 FIXME("(0x%08x,0x%08lx,%p): stub\n",
276 ProcessHandle,DesiredAccess, TokenHandle);
277 *TokenHandle = 0xcafe;
281 /******************************************************************************
282 * NtOpenThreadToken [NTDLL.@]
283 * ZwOpenThreadToken [NTDLL.@]
285 NTSTATUS WINAPI NtOpenThreadToken(
291 FIXME("(0x%08x,0x%08lx,0x%08x,%p): stub\n",
292 ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);
293 *TokenHandle = 0xcafe;
297 /******************************************************************************
298 * NtAdjustPrivilegesToken [NTDLL.@]
299 * ZwAdjustGroupsToken [NTDLL.@]
301 * FIXME: parameters unsafe
303 NTSTATUS WINAPI NtAdjustPrivilegesToken(
304 IN HANDLE TokenHandle,
305 IN BOOLEAN DisableAllPrivileges,
306 IN PTOKEN_PRIVILEGES NewState,
307 IN DWORD BufferLength,
308 OUT PTOKEN_PRIVILEGES PreviousState,
309 OUT PDWORD ReturnLength)
311 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p,%p),stub!\n",
312 TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength);
316 /******************************************************************************
317 * NtQueryInformationToken [NTDLL.@]
318 * ZwQueryInformationToken [NTDLL.@]
321 * Buffer for TokenUser:
322 * 0x00 TOKEN_USER the PSID field points to the SID
326 NTSTATUS WINAPI NtQueryInformationToken(
328 DWORD tokeninfoclass,
330 DWORD tokeninfolength,
333 unsigned int len = 0;
335 FIXME("(%08x,%ld,%p,%ld,%p): stub\n",
336 token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);
338 switch (tokeninfoclass)
341 len = sizeof(TOKEN_USER) + sizeof(SID);
344 len = sizeof(TOKEN_GROUPS);
346 case TokenPrivileges:
347 len = sizeof(TOKEN_PRIVILEGES);
350 len = sizeof(TOKEN_OWNER);
352 case TokenPrimaryGroup:
353 len = sizeof(TOKEN_PRIMARY_GROUP);
355 case TokenDefaultDacl:
356 len = sizeof(TOKEN_DEFAULT_DACL);
359 len = sizeof(TOKEN_SOURCE);
362 len = sizeof (TOKEN_TYPE);
365 case TokenImpersonationLevel:
366 case TokenStatistics:
370 /* FIXME: what if retlen == NULL ? */
373 if (tokeninfolength < len)
374 return STATUS_BUFFER_TOO_SMALL;
376 switch (tokeninfoclass)
381 TOKEN_USER * tuser = tokeninfo;
382 PSID sid = (PSID) (tuser + 1);
383 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
384 RtlInitializeSid(sid, &localSidAuthority, 1);
385 *(RtlSubAuthoritySid(sid, 0)) = SECURITY_INTERACTIVE_RID;
386 tuser->User.Sid = sid;
392 TOKEN_GROUPS *tgroups = tokeninfo;
393 SID_IDENTIFIER_AUTHORITY sid = {SECURITY_NT_AUTHORITY};
395 /* we need to show admin privileges ! */
396 tgroups->GroupCount = 1;
397 RtlAllocateAndInitializeSid( &sid,
399 SECURITY_BUILTIN_DOMAIN_RID,
400 DOMAIN_ALIAS_RID_ADMINS,
402 &(tgroups->Groups->Sid));
405 case TokenPrivileges:
408 TOKEN_PRIVILEGES *tpriv = tokeninfo;
409 tpriv->PrivilegeCount = 1;
420 /******************************************************************************
421 * NtCreateSection [NTDLL.@]
422 * ZwCreateSection [NTDLL.@]
424 NTSTATUS WINAPI NtCreateSection(
425 OUT PHANDLE SectionHandle,
426 IN ACCESS_MASK DesiredAccess,
427 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
428 IN PLARGE_INTEGER MaximumSize OPTIONAL,
429 IN ULONG SectionPageProtection OPTIONAL,
430 IN ULONG AllocationAttributes,
431 IN HANDLE FileHandle OPTIONAL)
433 FIXME("(%p,0x%08lx,%p,%p,0x%08lx,0x%08lx,0x%08x) stub\n",
434 SectionHandle,DesiredAccess, ObjectAttributes,
435 MaximumSize,SectionPageProtection,AllocationAttributes,FileHandle);
436 dump_ObjectAttributes(ObjectAttributes);
440 /******************************************************************************
441 * NtOpenSection [NTDLL.@]
442 * ZwOpenSection [NTDLL.@]
444 NTSTATUS WINAPI NtOpenSection(
445 PHANDLE SectionHandle,
446 ACCESS_MASK DesiredAccess,
447 POBJECT_ATTRIBUTES ObjectAttributes)
449 FIXME("(%p,0x%08lx,%p),stub!\n",
450 SectionHandle,DesiredAccess,ObjectAttributes);
451 dump_ObjectAttributes(ObjectAttributes);
455 /******************************************************************************
456 * NtQuerySection [NTDLL.@]
458 NTSTATUS WINAPI NtQuerySection(
459 IN HANDLE SectionHandle,
460 IN PVOID SectionInformationClass,
461 OUT PVOID SectionInformation,
463 OUT PULONG ResultLength)
465 FIXME("(0x%08x,%p,%p,0x%08lx,%p) stub!\n",
466 SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
470 /******************************************************************************
471 * NtMapViewOfSection [NTDLL.@]
472 * ZwMapViewOfSection [NTDLL.@]
473 * FUNCTION: Maps a view of a section into the virtual address space of a process
476 * SectionHandle Handle of the section
477 * ProcessHandle Handle of the process
478 * BaseAddress Desired base address (or NULL) on entry
479 * Actual base address of the view on exit
480 * ZeroBits Number of high order address bits that must be zero
481 * CommitSize Size in bytes of the initially committed section of the view
482 * SectionOffset Offset in bytes from the beginning of the section to the beginning of the view
483 * ViewSize Desired length of map (or zero to map all) on entry
484 Actual length mapped on exit
485 * InheritDisposition Specified how the view is to be shared with
487 * AllocateType Type of allocation for the pages
488 * Protect Protection for the committed region of the view
490 NTSTATUS WINAPI NtMapViewOfSection(
491 HANDLE SectionHandle,
492 HANDLE ProcessHandle,
496 PLARGE_INTEGER SectionOffset,
498 SECTION_INHERIT InheritDisposition,
499 ULONG AllocationType,
502 FIXME("(0x%08x,0x%08x,%p,0x%08lx,0x%08lx,%p,%p,0x%08x,0x%08lx,0x%08lx) stub\n",
503 SectionHandle,ProcessHandle,BaseAddress,ZeroBits,CommitSize,SectionOffset,
504 ViewSize,InheritDisposition,AllocationType,Protect);
512 /******************************************************************************
513 * NtCreatePort [NTDLL.@]
514 * ZwCreatePort [NTDLL.@]
516 NTSTATUS WINAPI NtCreatePort(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5)
518 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4,x5);
522 /******************************************************************************
523 * NtConnectPort [NTDLL.@]
524 * ZwConnectPort [NTDLL.@]
526 NTSTATUS WINAPI NtConnectPort(DWORD x1,PUNICODE_STRING uni,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
528 FIXME("(0x%08lx,%s,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",
529 x1,debugstr_w(uni->Buffer),x3,x4,x5,x6,x7,x8);
533 /******************************************************************************
534 * NtListenPort [NTDLL.@]
535 * ZwListenPort [NTDLL.@]
537 NTSTATUS WINAPI NtListenPort(DWORD x1,DWORD x2)
539 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
543 /******************************************************************************
544 * NtAcceptConnectPort [NTDLL.@]
545 * ZwAcceptConnectPort [NTDLL.@]
547 NTSTATUS WINAPI NtAcceptConnectPort(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6)
549 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4,x5,x6);
553 /******************************************************************************
554 * NtCompleteConnectPort [NTDLL.@]
555 * ZwCompleteConnectPort [NTDLL.@]
557 NTSTATUS WINAPI NtCompleteConnectPort(DWORD x1)
559 FIXME("(0x%08lx),stub!\n",x1);
563 /******************************************************************************
564 * NtRegisterThreadTerminatePort [NTDLL.@]
565 * ZwRegisterThreadTerminatePort [NTDLL.@]
567 NTSTATUS WINAPI NtRegisterThreadTerminatePort(DWORD x1)
569 FIXME("(0x%08lx),stub!\n",x1);
573 /******************************************************************************
574 * NtRequestWaitReplyPort [NTDLL.@]
575 * ZwRequestWaitReplyPort [NTDLL.@]
577 NTSTATUS WINAPI NtRequestWaitReplyPort(DWORD x1,DWORD x2,DWORD x3)
579 FIXME("(0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3);
583 /******************************************************************************
584 * NtReplyWaitReceivePort [NTDLL.@]
585 * ZwReplyWaitReceivePort [NTDLL.@]
587 NTSTATUS WINAPI NtReplyWaitReceivePort(DWORD x1,DWORD x2,DWORD x3,DWORD x4)
589 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4);
597 /******************************************************************************
598 * NtSetIntervalProfile [NTDLL.@]
599 * ZwSetIntervalProfile [NTDLL.@]
601 NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,DWORD x2) {
602 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
606 /******************************************************************************
607 * NtQueryPerformanceCounter [NTDLL.@]
609 NTSTATUS WINAPI NtQueryPerformanceCounter(
610 IN PLARGE_INTEGER Counter,
611 IN PLARGE_INTEGER Frequency)
613 FIXME("(%p, 0%p) stub\n",
618 /******************************************************************************
619 * NtCreateMailslotFile [NTDLL.@]
620 * ZwCreateMailslotFile [NTDLL.@]
622 NTSTATUS WINAPI NtCreateMailslotFile(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
624 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);
628 /******************************************************************************
629 * NtQuerySystemInformation [NTDLL.@]
630 * ZwQuerySystemInformation [NTDLL.@]
633 * SystemInformationClass Index to a certain information structure
634 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
635 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
636 * SystemConfigurationInformation CONFIGURATION_INFORMATION
637 * observed (class/len):
643 * SystemInformation caller supplies storage for the information structure
644 * Length size of the structure
645 * ResultLength Data written
647 NTSTATUS WINAPI NtQuerySystemInformation(
648 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
649 OUT PVOID SystemInformation,
651 OUT PULONG ResultLength)
653 switch(SystemInformationClass)
656 /* Something to do with the size of the registry *
657 * Since we don't have a size limitation, fake it *
658 * This is almost certainly wrong. *
659 * This sets each of the three words in the struct to 32 MB, *
660 * which is enough to make the IE 5 installer happy. */
661 FIXME("(0x%08x,%p,0x%08lx,%p) faking max registry size of 32 MB\n",
662 SystemInformationClass,SystemInformation,Length,ResultLength);
663 *(DWORD *)SystemInformation = 0x2000000;
664 *(((DWORD *)SystemInformation)+1) = 0x200000;
665 *(((DWORD *)SystemInformation)+2) = 0x200000;
669 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
670 SystemInformationClass,SystemInformation,Length,ResultLength);
671 ZeroMemory (SystemInformation, Length);
674 return STATUS_SUCCESS;
678 /******************************************************************************
679 * NtCreatePagingFile [NTDLL.@]
680 * ZwCreatePagingFile [NTDLL.@]
682 NTSTATUS WINAPI NtCreatePagingFile(
683 IN PUNICODE_STRING PageFileName,
686 OUT PULONG ActualSize)
688 FIXME("(%p(%s),0x%08lx,0x%08lx,%p),stub!\n",
689 PageFileName->Buffer, debugstr_w(PageFileName->Buffer),MiniumSize,MaxiumSize,ActualSize);
693 /******************************************************************************
694 * NtDisplayString [NTDLL.@]
696 * writes a string to the nt-textmode screen eg. during startup
698 NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
703 if (!(ret = RtlUnicodeStringToAnsiString( &stringA, string, TRUE )))
705 MESSAGE( "%.*s", stringA.Length, stringA.Buffer );
706 RtlFreeAnsiString( &stringA );
711 /******************************************************************************
712 * NtPowerInformation [NTDLL.@]
715 NTSTATUS WINAPI NtPowerInformation(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5)
717 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub\n",x1,x2,x3,x4,x5);
721 /******************************************************************************
722 * NtAllocateLocallyUniqueId (NTDLL.@)
724 * FIXME: the server should do that
726 NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
730 FIXME("%p (0x%08lx%08lx)\n", Luid, luid.HighPart, luid.LowPart);
735 Luid->HighPart = luid.HighPart;
736 Luid->LowPart = luid.LowPart;
738 return STATUS_SUCCESS;
741 /******************************************************************************
742 * VerSetConditionMask (NTDLL.@)
744 ULONGLONG WINAPI VerSetConditionMask( ULONGLONG dwlConditionMask, DWORD dwTypeBitMask,
745 BYTE dwConditionMask)
747 if(dwTypeBitMask == 0)
748 return dwlConditionMask;
749 dwConditionMask &= 0x07;
750 if(dwConditionMask == 0)
751 return dwlConditionMask;
753 if(dwTypeBitMask & VER_PRODUCT_TYPE)
754 dwlConditionMask |= dwConditionMask << 7*3;
755 else if (dwTypeBitMask & VER_SUITENAME)
756 dwlConditionMask |= dwConditionMask << 6*3;
757 else if (dwTypeBitMask & VER_SERVICEPACKMAJOR)
758 dwlConditionMask |= dwConditionMask << 5*3;
759 else if (dwTypeBitMask & VER_SERVICEPACKMINOR)
760 dwlConditionMask |= dwConditionMask << 4*3;
761 else if (dwTypeBitMask & VER_PLATFORMID)
762 dwlConditionMask |= dwConditionMask << 3*3;
763 else if (dwTypeBitMask & VER_BUILDNUMBER)
764 dwlConditionMask |= dwConditionMask << 2*3;
765 else if (dwTypeBitMask & VER_MAJORVERSION)
766 dwlConditionMask |= dwConditionMask << 1*3;
767 else if (dwTypeBitMask & VER_MINORVERSION)
768 dwlConditionMask |= dwConditionMask << 0*3;
769 return dwlConditionMask;