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 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p),stub!\n",
120 ProcessHandle,ProcessInformationClass,ProcessInformation,ProcessInformationLength,ReturnLength
122 /* "These are not the debuggers you are looking for." */
123 if (ProcessInformationClass == ProcessDebugPort)
124 /* set it to 0 aka "no debugger" to satisfy copy protections */
125 memset(ProcessInformation,0,ProcessInformationLength);
130 /******************************************************************************
131 * NtSetInformationProcess [NTDLL.@]
132 * ZwSetInformationProcess [NTDLL.@]
134 NTSTATUS WINAPI NtSetInformationProcess(
135 IN HANDLE ProcessHandle,
136 IN PROCESSINFOCLASS ProcessInformationClass,
137 IN PVOID ProcessInformation,
138 IN ULONG ProcessInformationLength)
140 FIXME("(0x%08x,0x%08x,%p,0x%08lx) stub\n",
141 ProcessHandle,ProcessInformationClass,ProcessInformation,ProcessInformationLength);
149 /******************************************************************************
150 * NtResumeThread [NTDLL.@]
151 * ZwResumeThread [NTDLL.@]
153 NTSTATUS WINAPI NtResumeThread(
154 IN HANDLE ThreadHandle,
155 IN PULONG SuspendCount)
157 FIXME("(0x%08x,%p),stub!\n",
158 ThreadHandle,SuspendCount);
163 /******************************************************************************
164 * NtTerminateThread [NTDLL.@]
165 * ZwTerminateThread [NTDLL.@]
167 NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
172 SERVER_START_REQ( terminate_thread )
174 req->handle = handle;
175 req->exit_code = exit_code;
176 ret = wine_server_call( req );
177 self = !ret && reply->self;
184 if (last) exit( exit_code );
185 else SYSDEPS_ExitThread( exit_code );
191 /******************************************************************************
192 * NtQueryInformationThread [NTDLL.@]
193 * ZwQueryInformationThread [NTDLL.@]
196 NTSTATUS WINAPI NtQueryInformationThread(
197 IN HANDLE ThreadHandle,
198 IN THREADINFOCLASS ThreadInformationClass,
199 OUT PVOID ThreadInformation,
200 IN ULONG ThreadInformationLength,
201 OUT PULONG ReturnLength)
203 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p),stub!\n",
204 ThreadHandle, ThreadInformationClass, ThreadInformation,
205 ThreadInformationLength, ReturnLength);
209 /******************************************************************************
210 * NtSetInformationThread [NTDLL.@]
211 * ZwSetInformationThread [NTDLL.@]
213 NTSTATUS WINAPI NtSetInformationThread(
215 THREADINFOCLASS ThreadInformationClass,
216 PVOID ThreadInformation,
217 ULONG ThreadInformationLength)
219 FIXME("(0x%08x,0x%08x,%p,0x%08lx),stub!\n",
220 ThreadHandle, ThreadInformationClass, ThreadInformation, ThreadInformationLength);
228 /******************************************************************************
229 * NtDuplicateToken [NTDLL.@]
230 * ZwDuplicateToken [NTDLL.@]
232 NTSTATUS WINAPI NtDuplicateToken(
233 IN HANDLE ExistingToken,
234 IN ACCESS_MASK DesiredAccess,
235 IN POBJECT_ATTRIBUTES ObjectAttributes,
236 IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
237 IN TOKEN_TYPE TokenType,
238 OUT PHANDLE NewToken)
240 FIXME("(0x%08x,0x%08lx,%p,0x%08x,0x%08x,%p),stub!\n",
241 ExistingToken, DesiredAccess, ObjectAttributes,
242 ImpersonationLevel, TokenType, NewToken);
243 dump_ObjectAttributes(ObjectAttributes);
247 /******************************************************************************
248 * NtOpenProcessToken [NTDLL.@]
249 * ZwOpenProcessToken [NTDLL.@]
251 NTSTATUS WINAPI NtOpenProcessToken(
252 HANDLE ProcessHandle,
256 FIXME("(0x%08x,0x%08lx,%p): stub\n",
257 ProcessHandle,DesiredAccess, TokenHandle);
258 *TokenHandle = 0xcafe;
262 /******************************************************************************
263 * NtOpenThreadToken [NTDLL.@]
264 * ZwOpenThreadToken [NTDLL.@]
266 NTSTATUS WINAPI NtOpenThreadToken(
272 FIXME("(0x%08x,0x%08lx,0x%08x,%p): stub\n",
273 ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);
274 *TokenHandle = 0xcafe;
278 /******************************************************************************
279 * NtAdjustPrivilegesToken [NTDLL.@]
280 * ZwAdjustGroupsToken [NTDLL.@]
282 * FIXME: parameters unsafe
284 NTSTATUS WINAPI NtAdjustPrivilegesToken(
285 IN HANDLE TokenHandle,
286 IN BOOLEAN DisableAllPrivileges,
287 IN PTOKEN_PRIVILEGES NewState,
288 IN DWORD BufferLength,
289 OUT PTOKEN_PRIVILEGES PreviousState,
290 OUT PDWORD ReturnLength)
292 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p,%p),stub!\n",
293 TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength);
297 /******************************************************************************
298 * NtQueryInformationToken [NTDLL.@]
299 * ZwQueryInformationToken [NTDLL.@]
302 * Buffer for TokenUser:
303 * 0x00 TOKEN_USER the PSID field points to the SID
307 NTSTATUS WINAPI NtQueryInformationToken(
309 DWORD tokeninfoclass,
311 DWORD tokeninfolength,
314 unsigned int len = 0;
316 FIXME("(%08x,%ld,%p,%ld,%p): stub\n",
317 token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);
319 switch (tokeninfoclass)
322 len = sizeof(TOKEN_USER) + sizeof(SID);
325 len = sizeof(TOKEN_GROUPS);
327 case TokenPrivileges:
328 len = sizeof(TOKEN_PRIVILEGES);
331 len = sizeof(TOKEN_OWNER);
333 case TokenPrimaryGroup:
334 len = sizeof(TOKEN_PRIMARY_GROUP);
336 case TokenDefaultDacl:
337 len = sizeof(TOKEN_DEFAULT_DACL);
340 len = sizeof(TOKEN_SOURCE);
343 len = sizeof (TOKEN_TYPE);
346 case TokenImpersonationLevel:
347 case TokenStatistics:
351 /* FIXME: what if retlen == NULL ? */
354 if (tokeninfolength < len)
355 return STATUS_BUFFER_TOO_SMALL;
357 switch (tokeninfoclass)
362 TOKEN_USER * tuser = tokeninfo;
363 PSID sid = (PSID) (tuser + 1);
364 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
365 RtlInitializeSid(sid, &localSidAuthority, 1);
366 *(RtlSubAuthoritySid(sid, 0)) = SECURITY_INTERACTIVE_RID;
367 tuser->User.Sid = sid;
373 TOKEN_GROUPS *tgroups = tokeninfo;
374 SID_IDENTIFIER_AUTHORITY sid = {SECURITY_NT_AUTHORITY};
376 /* we need to show admin privileges ! */
377 tgroups->GroupCount = 1;
378 RtlAllocateAndInitializeSid( &sid,
380 SECURITY_BUILTIN_DOMAIN_RID,
381 DOMAIN_ALIAS_RID_ADMINS,
383 &(tgroups->Groups->Sid));
386 case TokenPrivileges:
389 TOKEN_PRIVILEGES *tpriv = tokeninfo;
390 tpriv->PrivilegeCount = 1;
401 /******************************************************************************
402 * NtCreateSection [NTDLL.@]
403 * ZwCreateSection [NTDLL.@]
405 NTSTATUS WINAPI NtCreateSection(
406 OUT PHANDLE SectionHandle,
407 IN ACCESS_MASK DesiredAccess,
408 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
409 IN PLARGE_INTEGER MaximumSize OPTIONAL,
410 IN ULONG SectionPageProtection OPTIONAL,
411 IN ULONG AllocationAttributes,
412 IN HANDLE FileHandle OPTIONAL)
414 FIXME("(%p,0x%08lx,%p,%p,0x%08lx,0x%08lx,0x%08x) stub\n",
415 SectionHandle,DesiredAccess, ObjectAttributes,
416 MaximumSize,SectionPageProtection,AllocationAttributes,FileHandle);
417 dump_ObjectAttributes(ObjectAttributes);
421 /******************************************************************************
422 * NtOpenSection [NTDLL.@]
423 * ZwOpenSection [NTDLL.@]
425 NTSTATUS WINAPI NtOpenSection(
426 PHANDLE SectionHandle,
427 ACCESS_MASK DesiredAccess,
428 POBJECT_ATTRIBUTES ObjectAttributes)
430 FIXME("(%p,0x%08lx,%p),stub!\n",
431 SectionHandle,DesiredAccess,ObjectAttributes);
432 dump_ObjectAttributes(ObjectAttributes);
436 /******************************************************************************
437 * NtQuerySection [NTDLL.@]
439 NTSTATUS WINAPI NtQuerySection(
440 IN HANDLE SectionHandle,
441 IN PVOID SectionInformationClass,
442 OUT PVOID SectionInformation,
444 OUT PULONG ResultLength)
446 FIXME("(0x%08x,%p,%p,0x%08lx,%p) stub!\n",
447 SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
451 /******************************************************************************
452 * NtMapViewOfSection [NTDLL.@]
453 * ZwMapViewOfSection [NTDLL.@]
454 * FUNCTION: Maps a view of a section into the virtual address space of a process
457 * SectionHandle Handle of the section
458 * ProcessHandle Handle of the process
459 * BaseAddress Desired base address (or NULL) on entry
460 * Actual base address of the view on exit
461 * ZeroBits Number of high order address bits that must be zero
462 * CommitSize Size in bytes of the initially committed section of the view
463 * SectionOffset Offset in bytes from the beginning of the section to the beginning of the view
464 * ViewSize Desired length of map (or zero to map all) on entry
465 Actual length mapped on exit
466 * InheritDisposition Specified how the view is to be shared with
468 * AllocateType Type of allocation for the pages
469 * Protect Protection for the committed region of the view
471 NTSTATUS WINAPI NtMapViewOfSection(
472 HANDLE SectionHandle,
473 HANDLE ProcessHandle,
477 PLARGE_INTEGER SectionOffset,
479 SECTION_INHERIT InheritDisposition,
480 ULONG AllocationType,
483 FIXME("(0x%08x,0x%08x,%p,0x%08lx,0x%08lx,%p,%p,0x%08x,0x%08lx,0x%08lx) stub\n",
484 SectionHandle,ProcessHandle,BaseAddress,ZeroBits,CommitSize,SectionOffset,
485 ViewSize,InheritDisposition,AllocationType,Protect);
493 /******************************************************************************
494 * NtCreatePort [NTDLL.@]
495 * ZwCreatePort [NTDLL.@]
497 NTSTATUS WINAPI NtCreatePort(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5)
499 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4,x5);
503 /******************************************************************************
504 * NtConnectPort [NTDLL.@]
505 * ZwConnectPort [NTDLL.@]
507 NTSTATUS WINAPI NtConnectPort(DWORD x1,PUNICODE_STRING uni,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
509 FIXME("(0x%08lx,%s,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",
510 x1,debugstr_w(uni->Buffer),x3,x4,x5,x6,x7,x8);
514 /******************************************************************************
515 * NtListenPort [NTDLL.@]
516 * ZwListenPort [NTDLL.@]
518 NTSTATUS WINAPI NtListenPort(DWORD x1,DWORD x2)
520 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
524 /******************************************************************************
525 * NtAcceptConnectPort [NTDLL.@]
526 * ZwAcceptConnectPort [NTDLL.@]
528 NTSTATUS WINAPI NtAcceptConnectPort(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6)
530 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4,x5,x6);
534 /******************************************************************************
535 * NtCompleteConnectPort [NTDLL.@]
536 * ZwCompleteConnectPort [NTDLL.@]
538 NTSTATUS WINAPI NtCompleteConnectPort(DWORD x1)
540 FIXME("(0x%08lx),stub!\n",x1);
544 /******************************************************************************
545 * NtRegisterThreadTerminatePort [NTDLL.@]
546 * ZwRegisterThreadTerminatePort [NTDLL.@]
548 NTSTATUS WINAPI NtRegisterThreadTerminatePort(DWORD x1)
550 FIXME("(0x%08lx),stub!\n",x1);
554 /******************************************************************************
555 * NtRequestWaitReplyPort [NTDLL.@]
556 * ZwRequestWaitReplyPort [NTDLL.@]
558 NTSTATUS WINAPI NtRequestWaitReplyPort(DWORD x1,DWORD x2,DWORD x3)
560 FIXME("(0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3);
564 /******************************************************************************
565 * NtReplyWaitReceivePort [NTDLL.@]
566 * ZwReplyWaitReceivePort [NTDLL.@]
568 NTSTATUS WINAPI NtReplyWaitReceivePort(DWORD x1,DWORD x2,DWORD x3,DWORD x4)
570 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4);
578 /******************************************************************************
579 * NtSetIntervalProfile [NTDLL.@]
580 * ZwSetIntervalProfile [NTDLL.@]
582 NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,DWORD x2) {
583 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
587 /******************************************************************************
588 * NtQueryPerformanceCounter [NTDLL.@]
590 NTSTATUS WINAPI NtQueryPerformanceCounter(
591 IN PLARGE_INTEGER Counter,
592 IN PLARGE_INTEGER Frequency)
594 FIXME("(%p, 0%p) stub\n",
599 /******************************************************************************
600 * NtCreateMailslotFile [NTDLL.@]
601 * ZwCreateMailslotFile [NTDLL.@]
603 NTSTATUS WINAPI NtCreateMailslotFile(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
605 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);
609 /******************************************************************************
610 * NtQuerySystemInformation [NTDLL.@]
611 * ZwQuerySystemInformation [NTDLL.@]
614 * SystemInformationClass Index to a certain information structure
615 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
616 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
617 * SystemConfigurationInformation CONFIGURATION_INFORMATION
618 * observed (class/len):
624 * SystemInformation caller supplies storage for the information structure
625 * Length size of the structure
626 * ResultLength Data written
628 NTSTATUS WINAPI NtQuerySystemInformation(
629 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
630 OUT PVOID SystemInformation,
632 OUT PULONG ResultLength)
634 switch(SystemInformationClass)
637 /* Something to do with the size of the registry *
638 * Since we don't have a size limitation, fake it *
639 * This is almost certainly wrong. *
640 * This sets each of the three words in the struct to 32 MB, *
641 * which is enough to make the IE 5 installer happy. */
642 FIXME("(0x%08x,%p,0x%08lx,%p) faking max registry size of 32 MB\n",
643 SystemInformationClass,SystemInformation,Length,ResultLength);
644 *(DWORD *)SystemInformation = 0x2000000;
645 *(((DWORD *)SystemInformation)+1) = 0x200000;
646 *(((DWORD *)SystemInformation)+2) = 0x200000;
650 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
651 SystemInformationClass,SystemInformation,Length,ResultLength);
652 ZeroMemory (SystemInformation, Length);
655 return STATUS_SUCCESS;
659 /******************************************************************************
660 * NtCreatePagingFile [NTDLL.@]
661 * ZwCreatePagingFile [NTDLL.@]
663 NTSTATUS WINAPI NtCreatePagingFile(
664 IN PUNICODE_STRING PageFileName,
667 OUT PULONG ActualSize)
669 FIXME("(%p(%s),0x%08lx,0x%08lx,%p),stub!\n",
670 PageFileName->Buffer, debugstr_w(PageFileName->Buffer),MiniumSize,MaxiumSize,ActualSize);
674 /******************************************************************************
675 * NtDisplayString [NTDLL.@]
677 * writes a string to the nt-textmode screen eg. during startup
679 NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
684 if (!(ret = RtlUnicodeStringToAnsiString( &stringA, string, TRUE )))
686 MESSAGE( "%.*s", stringA.Length, stringA.Buffer );
687 RtlFreeAnsiString( &stringA );
692 /******************************************************************************
693 * NtPowerInformation [NTDLL.@]
696 NTSTATUS WINAPI NtPowerInformation(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5)
698 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub\n",x1,x2,x3,x4,x5);
702 /******************************************************************************
703 * NtAllocateLocallyUniqueId (NTDLL.@)
705 * FIXME: the server should do that
707 NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
711 FIXME("%p (0x%08lx%08lx)\n", Luid, luid.HighPart, luid.LowPart);
716 Luid->HighPart = luid.HighPart;
717 Luid->LowPart = luid.LowPart;
719 return STATUS_SUCCESS;